aboutsummaryrefslogtreecommitdiffstats
path: root/src/proguard/shrink/Shrinker.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/proguard/shrink/Shrinker.java')
-rw-r--r--src/proguard/shrink/Shrinker.java43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/proguard/shrink/Shrinker.java b/src/proguard/shrink/Shrinker.java
index edbc27f..0472c3d 100644
--- a/src/proguard/shrink/Shrinker.java
+++ b/src/proguard/shrink/Shrinker.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-2013 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
@@ -21,7 +21,7 @@
package proguard.shrink;
import proguard.*;
-import proguard.classfile.ClassPool;
+import proguard.classfile.*;
import proguard.classfile.attribute.visitor.*;
import proguard.classfile.visitor.*;
@@ -67,9 +67,20 @@ public class Shrinker
new UsageMarker() :
new ShortestUsageMarker();
+ // Automatically mark the parameterless constructors of seed classes,
+ // mainly for convenience and for backward compatibility.
+ ClassVisitor classUsageMarker =
+ new MultiClassVisitor(new ClassVisitor[]
+ {
+ usageMarker,
+ new NamedMethodVisitor(ClassConstants.INTERNAL_METHOD_NAME_INIT,
+ ClassConstants.INTERNAL_METHOD_TYPE_INIT,
+ usageMarker)
+ });
+
ClassPoolVisitor classPoolvisitor =
ClassSpecificationVisitorFactory.createClassPoolVisitor(configuration.keep,
- usageMarker,
+ classUsageMarker,
usageMarker,
true,
false,
@@ -89,6 +100,8 @@ public class Shrinker
{
new InnerUsageMarker(usageMarker),
new AnnotationUsageMarker(usageMarker),
+ new SignatureUsageMarker(usageMarker),
+ new LocalVariableTypeUsageMarker(usageMarker)
}))));
// Should we explain ourselves?
@@ -113,15 +126,21 @@ public class Shrinker
if (configuration.printUsage != null)
{
- PrintStream ps = isFile(configuration.printUsage) ?
- new PrintStream(new BufferedOutputStream(new FileOutputStream(configuration.printUsage))) :
- System.out;
+ PrintStream ps =
+ configuration.printUsage == Configuration.STD_OUT ? System.out :
+ new PrintStream(
+ new BufferedOutputStream(
+ new FileOutputStream(configuration.printUsage)));
// Print out items that will be removed.
programClassPool.classesAcceptAlphabetically(
new UsagePrinter(usageMarker, true, ps));
- if (ps != System.out)
+ if (ps == System.out)
+ {
+ ps.flush();
+ }
+ else
{
ps.close();
}
@@ -157,14 +176,4 @@ public class Shrinker
return newProgramClassPool;
}
-
-
- /**
- * Returns whether the given file is actually a file, or just a placeholder
- * for the standard output.
- */
- private boolean isFile(File file)
- {
- return file.getPath().length() > 0;
- }
}