diff options
Diffstat (limited to 'src/proguard/ProGuard.java')
-rw-r--r-- | src/proguard/ProGuard.java | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/src/proguard/ProGuard.java b/src/proguard/ProGuard.java index 8c30e10..913207a 100644 --- a/src/proguard/ProGuard.java +++ b/src/proguard/ProGuard.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2011 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -24,7 +24,7 @@ import proguard.classfile.ClassPool; import proguard.classfile.editor.ClassElementSorter; import proguard.classfile.visitor.*; import proguard.obfuscate.Obfuscator; -import proguard.optimize.Optimizer; +import proguard.optimize.*; import proguard.preverify.*; import proguard.shrink.Shrinker; @@ -37,7 +37,7 @@ import java.io.*; */ public class ProGuard { - public static final String VERSION = "ProGuard, version 4.4"; + public static final String VERSION = "ProGuard, version 4.7"; private final Configuration configuration; private ClassPool programClassPool = new ClassPool(); @@ -77,7 +77,8 @@ public class ProGuard readInput(); - if (configuration.shrink || + if (configuration.printSeeds != null || + configuration.shrink || configuration.optimize || configuration.obfuscate || configuration.preverify) @@ -236,30 +237,10 @@ public class ProGuard System.out.println("Printing kept classes, fields, and methods..."); } - // Check if we have at least some keep commands. - if (configuration.keep == null) - { - throw new IOException("You have to specify '-keep' options for the shrinking step."); - } - PrintStream ps = createPrintStream(configuration.printSeeds); try { - // Create a visitor for printing out the seeds. We're printing out - // the program elements that are preserved against shrinking, - // optimization, or obfuscation. - SimpleClassPrinter printer = new SimpleClassPrinter(false, ps); - ClassPoolVisitor classPoolvisitor = - ClassSpecificationVisitorFactory.createClassPoolVisitor(configuration.keep, - new ProgramClassFilter(printer), - new ProgramMemberFilter(printer), - true, - true, - true); - - // Print out the seeds. - programClassPool.accept(classPoolvisitor); - libraryClassPool.accept(classPoolvisitor); + new SeedPrinter(ps).write(configuration, programClassPool, libraryClassPool); } finally { @@ -445,14 +426,26 @@ public class ProGuard /** - * Returns the absolute file name for the given file, or the standard output + * Returns the canonical file name for the given file, or "standard output" * if the file name is empty. */ private String fileName(File file) { - return isFile(file) ? - file.getAbsolutePath() : - "standard output"; + if (isFile(file)) + { + try + { + return file.getCanonicalPath(); + } + catch (IOException ex) + { + return file.getPath(); + } + } + else + { + return "standard output"; + } } |