diff options
author | Narayan Kamath <narayan@google.com> | 2013-11-26 18:01:36 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-11-26 18:01:36 +0000 |
commit | b005651c72190ee37f463417143cd2e612cafce6 (patch) | |
tree | 7d42e31a97264803b1147ef6001e8a5e6968a122 /src/proguard/shrink/Shrinker.java | |
parent | 54f59ac04f3e21d5aecdd46bb1e7f4577924ab92 (diff) | |
parent | 8a6199f0c36a778f22394364347a301b0b28e94b (diff) | |
download | external_proguard-b005651c72190ee37f463417143cd2e612cafce6.tar.gz external_proguard-b005651c72190ee37f463417143cd2e612cafce6.tar.bz2 external_proguard-b005651c72190ee37f463417143cd2e612cafce6.zip |
Merge "Upgrade Proguard to 4.10."
Diffstat (limited to 'src/proguard/shrink/Shrinker.java')
-rw-r--r-- | src/proguard/shrink/Shrinker.java | 43 |
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; - } } |