diff options
Diffstat (limited to 'src/proguard/obfuscate/Obfuscator.java')
-rw-r--r-- | src/proguard/obfuscate/Obfuscator.java | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/src/proguard/obfuscate/Obfuscator.java b/src/proguard/obfuscate/Obfuscator.java index dce563a..5f58a83 100644 --- a/src/proguard/obfuscate/Obfuscator.java +++ b/src/proguard/obfuscate/Obfuscator.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 @@ -99,19 +99,30 @@ public class Obfuscator libraryClassPool.classesAccept(new AllMemberVisitor(nameMarker)); // Mark attributes that have to be kept. - AttributeUsageMarker requiredAttributeUsageMarker = - new AttributeUsageMarker(); + AttributeVisitor attributeUsageMarker = + new NonEmptyAttributeFilter( + new AttributeUsageMarker()); AttributeVisitor optionalAttributeUsageMarker = configuration.keepAttributes == null ? null : new AttributeNameFilter(new ListParser(new NameParser()).parse(configuration.keepAttributes), - requiredAttributeUsageMarker); + attributeUsageMarker); programClassPool.classesAccept( new AllAttributeVisitor(true, - new RequiredAttributeFilter(requiredAttributeUsageMarker, + new RequiredAttributeFilter(attributeUsageMarker, optionalAttributeUsageMarker))); + // Keep parameter names and types if specified. + if (configuration.keepParameterNames) + { + programClassPool.classesAccept( + new AllMethodVisitor( + new MemberNameFilter( + new AllAttributeVisitor(true, + new ParameterNameMarker(attributeUsageMarker))))); + } + // Remove the attributes that can be discarded. Note that the attributes // may only be discarded after the seeds have been marked, since the // configuration may rely on annotations. @@ -398,23 +409,28 @@ public class Obfuscator programClassPool.classesAccept( new AllConstantVisitor( new AccessFixer())); + + // Fix the access flags of the inner classes information. + programClassPool.classesAccept( + new AllAttributeVisitor( + new AllInnerClassesInfoVisitor( + new InnerClassesAccessFixer()))); } + // Fix the bridge method flags. + programClassPool.classesAccept( + new AllMethodVisitor( + new BridgeMethodFixer())); + // Rename the source file attributes, if requested. if (configuration.newSourceFileAttribute != null) { programClassPool.classesAccept(new SourceFileRenamer(configuration.newSourceFileAttribute)); } - // Mark NameAndType constant pool entries that have to be kept - // and remove the other ones. - programClassPool.classesAccept(new NameAndTypeUsageMarker()); - programClassPool.classesAccept(new NameAndTypeShrinker()); - - // Mark Utf8 constant pool entries that have to be kept - // and remove the other ones. - programClassPool.classesAccept(new Utf8UsageMarker()); - programClassPool.classesAccept(new Utf8Shrinker()); + // Remove unused constants. + programClassPool.classesAccept( + new ConstantPoolShrinker()); } |