diff options
Diffstat (limited to 'src/proguard/DescriptorKeepChecker.java')
-rw-r--r-- | src/proguard/DescriptorKeepChecker.java | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/src/proguard/DescriptorKeepChecker.java b/src/proguard/DescriptorKeepChecker.java index 1dfaf1a..7849693 100644 --- a/src/proguard/DescriptorKeepChecker.java +++ b/src/proguard/DescriptorKeepChecker.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 @@ -23,7 +23,7 @@ package proguard; import proguard.classfile.*; import proguard.classfile.util.*; import proguard.classfile.visitor.*; -import proguard.optimize.KeepMarker; +import proguard.optimize.*; import java.util.List; @@ -64,7 +64,7 @@ implements MemberVisitor, /** * Checks the classes mentioned in the given keep specifications, printing - * notes if necessary. Returns the number of notes printed. + * notes if necessary. */ public void checkClassSpecifications(List keepSpecifications) { @@ -85,8 +85,11 @@ implements MemberVisitor, programClassPool.accept(classPoolvisitor); libraryClassPool.accept(classPoolvisitor); - // Print out notes about argument types that are not being kept. - programClassPool.classesAccept(new AllMemberVisitor(this)); + // Print out notes about argument types that are not being kept in + // class members that are being kept. + programClassPool.classesAccept( + new AllMemberVisitor( + new KeptMemberFilter(this))); } @@ -94,39 +97,42 @@ implements MemberVisitor, public void visitProgramField(ProgramClass programClass, ProgramField programField) { - if (KeepMarker.isKept(programField)) - { - referencingClass = programClass; - referencingMember = programField; - isField = true; - - // Don't check the type, because it is not required for introspection. - //programField.referencedClassesAccept(this); - } + //referencingClass = programClass; + //referencingMember = programField; + //isField = true; + // + // Don't check the type, because it is not required for introspection. + //programField.referencedClassesAccept(this); } public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) { - if (KeepMarker.isKept(programMethod)) + referencingClass = programClass; + referencingMember = programMethod; + isField = false; + + // Don't check the return type, because it is not required for + // introspection (e.g. the return type of the special Enum methods). + //programMethod.referencedClassesAccept(this); + + Clazz[] referencedClasses = programMethod.referencedClasses; + if (referencedClasses != null) { - referencingClass = programClass; - referencingMember = programMethod; - isField = false; + int count = referencedClasses.length; - // Don't check the return type, because it is not required for - // introspection (e.g. the return type of the special Enum methods). - //programMethod.referencedClassesAccept(this); + // Adapt the count if the return type is a class type (not so + // pretty; assuming test just checks for final ';'). + if (ClassUtil.isInternalClassType(programMethod.getDescriptor(programClass))) + { + count--; + } - Clazz[] referencedClasses = programMethod.referencedClasses; - if (referencedClasses != null) + for (int index = 0; index < count; index++) { - for (int index = 0; index < referencedClasses.length-1; index++) + if (referencedClasses[index] != null) { - if (referencedClasses[index] != null) - { - referencedClasses[index].accept(this); - } + referencedClasses[index].accept(this); } } } |