summaryrefslogtreecommitdiff
path: root/src/proguard/ProGuard.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/proguard/ProGuard.java')
-rw-r--r--src/proguard/ProGuard.java51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/proguard/ProGuard.java b/src/proguard/ProGuard.java
index 913207a..8c30e10 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-2011 Eric Lafortune (eric@graphics.cornell.edu)
+ * Copyright (c) 2002-2009 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.*;
+import proguard.optimize.Optimizer;
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.7";
+ public static final String VERSION = "ProGuard, version 4.4";
private final Configuration configuration;
private ClassPool programClassPool = new ClassPool();
@@ -77,8 +77,7 @@ public class ProGuard
readInput();
- if (configuration.printSeeds != null ||
- configuration.shrink ||
+ if (configuration.shrink ||
configuration.optimize ||
configuration.obfuscate ||
configuration.preverify)
@@ -237,10 +236,30 @@ 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
{
- new SeedPrinter(ps).write(configuration, programClassPool, libraryClassPool);
+ // 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);
}
finally
{
@@ -426,26 +445,14 @@ public class ProGuard
/**
- * Returns the canonical file name for the given file, or "standard output"
+ * Returns the absolute file name for the given file, or the standard output
* if the file name is empty.
*/
private String fileName(File file)
{
- if (isFile(file))
- {
- try
- {
- return file.getCanonicalPath();
- }
- catch (IOException ex)
- {
- return file.getPath();
- }
- }
- else
- {
- return "standard output";
- }
+ return isFile(file) ?
+ file.getAbsolutePath() :
+ "standard output";
}