diff options
Diffstat (limited to 'src/proguard/classfile/editor/Utf8Shrinker.java')
-rw-r--r-- | src/proguard/classfile/editor/Utf8Shrinker.java | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/proguard/classfile/editor/Utf8Shrinker.java b/src/proguard/classfile/editor/Utf8Shrinker.java index eda5826..35626d7 100644 --- a/src/proguard/classfile/editor/Utf8Shrinker.java +++ b/src/proguard/classfile/editor/Utf8Shrinker.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 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 @@ -28,7 +28,6 @@ import proguard.classfile.attribute.preverification.*; import proguard.classfile.attribute.visitor.*; import proguard.classfile.constant.*; import proguard.classfile.constant.visitor.ConstantVisitor; -import proguard.classfile.editor.ConstantPoolRemapper; import proguard.classfile.util.SimplifiedVisitor; import proguard.classfile.visitor.*; @@ -47,6 +46,7 @@ implements ClassVisitor, ConstantVisitor, AttributeVisitor, InnerClassesInfoVisitor, + ParameterInfoVisitor, LocalVariableInfoVisitor, LocalVariableTypeInfoVisitor, AnnotationVisitor, @@ -198,6 +198,15 @@ implements ClassVisitor, } + public void visitMethodParametersAttribute(Clazz clazz, Method method, MethodParametersAttribute methodParametersAttribute) + { + markCpUtf8Entry(clazz, methodParametersAttribute.u2attributeNameIndex); + + // Mark the UTF-8 entries referenced by the parameter information. + methodParametersAttribute.parametersAccept(clazz, method, this); + } + + public void visitExceptionsAttribute(Clazz clazz, Method method, ExceptionsAttribute exceptionsAttribute) { markCpUtf8Entry(clazz, exceptionsAttribute.u2attributeNameIndex); @@ -287,6 +296,17 @@ implements ClassVisitor, } + // Implementations for ParameterInfoVisitor. + + public void visitParameterInfo(Clazz clazz, Method method, int parameterIndex, ParameterInfo parameterInfo) + { + if (parameterInfo.u2nameIndex != 0) + { + markCpUtf8Entry(clazz, parameterInfo.u2nameIndex); + } + } + + // Implementations for LocalVariableInfoVisitor. public void visitLocalVariableInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableInfo localVariableInfo) @@ -430,11 +450,10 @@ implements ClassVisitor, // Shift the used constant pool entries together. for (int index = 1; index < length; index++) { - constantIndexMap[index] = counter; - Constant constant = constantPool[index]; - // Don't update the flag if this is the second half of a long entry. + // Is the constant being used? Don't update the flag if this is the + // second half of a long entry. if (constant != null) { isUsed = constant.getTag() != ClassConstants.CONSTANT_Utf8 || @@ -443,8 +462,17 @@ implements ClassVisitor, if (isUsed) { + // Remember the new index. + constantIndexMap[index] = counter; + + // Shift the constant pool entry. constantPool[counter++] = constant; } + else + { + // Remember an invalid index. + constantIndexMap[index] = -1; + } } // Clear the remaining constant pool elements. |