diff options
Diffstat (limited to 'src/proguard/classfile/io/ProgramClassReader.java')
-rw-r--r-- | src/proguard/classfile/io/ProgramClassReader.java | 79 |
1 files changed, 11 insertions, 68 deletions
diff --git a/src/proguard/classfile/io/ProgramClassReader.java b/src/proguard/classfile/io/ProgramClassReader.java index 01f057f..476a346 100644 --- a/src/proguard/classfile/io/ProgramClassReader.java +++ b/src/proguard/classfile/io/ProgramClassReader.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2011 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2009 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 @@ -46,7 +46,6 @@ implements ClassVisitor, MemberVisitor, ConstantVisitor, AttributeVisitor, - BootstrapMethodInfoVisitor, InnerClassesInfoVisitor, ExceptionInfoVisitor, StackMapFrameVisitor, @@ -251,20 +250,6 @@ implements ClassVisitor, } - public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant) - { - invokeDynamicConstant.u2bootstrapMethodAttributeIndex = dataInput.readUnsignedShort(); - invokeDynamicConstant.u2nameAndTypeIndex = dataInput.readUnsignedShort(); - } - - - public void visitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant) - { - methodHandleConstant.u1referenceKind = dataInput.readUnsignedByte(); - methodHandleConstant.u2referenceIndex = dataInput.readUnsignedShort(); - } - - public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant) { refConstant.u2classIndex = dataInput.readUnsignedShort(); @@ -278,12 +263,6 @@ implements ClassVisitor, } - public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant) - { - methodTypeConstant.u2descriptorIndex = dataInput.readUnsignedShort(); - } - - public void visitNameAndTypeConstant(Clazz clazz, NameAndTypeConstant nameAndTypeConstant) { nameAndTypeConstant.u2nameIndex = dataInput.readUnsignedShort(); @@ -302,21 +281,6 @@ implements ClassVisitor, } - public void visitBootstrapMethodsAttribute(Clazz clazz, BootstrapMethodsAttribute bootstrapMethodsAttribute) - { - // Read the bootstrap methods. - bootstrapMethodsAttribute.u2bootstrapMethodsCount = dataInput.readUnsignedShort(); - - bootstrapMethodsAttribute.bootstrapMethods = new BootstrapMethodInfo[bootstrapMethodsAttribute.u2bootstrapMethodsCount]; - for (int index = 0; index < bootstrapMethodsAttribute.u2bootstrapMethodsCount; index++) - { - BootstrapMethodInfo bootstrapMethodInfo = new BootstrapMethodInfo(); - visitBootstrapMethodInfo(clazz, bootstrapMethodInfo); - bootstrapMethodsAttribute.bootstrapMethods[index] = bootstrapMethodInfo; - } - } - - public void visitSourceFileAttribute(Clazz clazz, SourceFileAttribute sourceFileAttribute) { sourceFileAttribute.u2sourceFileIndex = dataInput.readUnsignedShort(); @@ -338,7 +302,7 @@ implements ClassVisitor, for (int index = 0; index < innerClassesAttribute.u2classesCount; index++) { InnerClassesInfo innerClassesInfo = new InnerClassesInfo(); - visitInnerClassesInfo(clazz, innerClassesInfo); + this.visitInnerClassesInfo(clazz, innerClassesInfo); innerClassesAttribute.classes[index] = innerClassesInfo; } } @@ -408,7 +372,7 @@ implements ClassVisitor, for (int index = 0; index < codeAttribute.u2exceptionTableLength; index++) { ExceptionInfo exceptionInfo = new ExceptionInfo(); - visitExceptionInfo(clazz, method, codeAttribute, exceptionInfo); + this.visitExceptionInfo(clazz, method, codeAttribute, exceptionInfo); codeAttribute.exceptionTable[index] = exceptionInfo; } @@ -434,7 +398,7 @@ implements ClassVisitor, for (int index = 0; index < stackMapAttribute.u2stackMapFramesCount; index++) { FullFrame stackMapFrame = new FullFrame(); - visitFullFrame(clazz, method, codeAttribute, index, stackMapFrame); + this.visitFullFrame(clazz, method, codeAttribute, index, stackMapFrame); stackMapAttribute.stackMapFrames[index] = stackMapFrame; } } @@ -464,7 +428,7 @@ implements ClassVisitor, for (int index = 0; index < lineNumberTableAttribute.u2lineNumberTableLength; index++) { LineNumberInfo lineNumberInfo = new LineNumberInfo(); - visitLineNumberInfo(clazz, method, codeAttribute, lineNumberInfo); + this.visitLineNumberInfo(clazz, method, codeAttribute, lineNumberInfo); lineNumberTableAttribute.lineNumberTable[index] = lineNumberInfo; } } @@ -479,7 +443,7 @@ implements ClassVisitor, for (int index = 0; index < localVariableTableAttribute.u2localVariableTableLength; index++) { LocalVariableInfo localVariableInfo = new LocalVariableInfo(); - visitLocalVariableInfo(clazz, method, codeAttribute, localVariableInfo); + this.visitLocalVariableInfo(clazz, method, codeAttribute, localVariableInfo); localVariableTableAttribute.localVariableTable[index] = localVariableInfo; } } @@ -494,7 +458,7 @@ implements ClassVisitor, for (int index = 0; index < localVariableTypeTableAttribute.u2localVariableTypeTableLength; index++) { LocalVariableTypeInfo localVariableTypeInfo = new LocalVariableTypeInfo(); - visitLocalVariableTypeInfo(clazz, method, codeAttribute, localVariableTypeInfo); + this.visitLocalVariableTypeInfo(clazz, method, codeAttribute, localVariableTypeInfo); localVariableTypeTableAttribute.localVariableTypeTable[index] = localVariableTypeInfo; } } @@ -509,7 +473,7 @@ implements ClassVisitor, for (int index = 0; index < annotationsAttribute.u2annotationsCount; index++) { Annotation annotation = new Annotation(); - visitAnnotation(clazz, annotation); + this.visitAnnotation(clazz, annotation); annotationsAttribute.annotations[index] = annotation; } } @@ -544,7 +508,7 @@ implements ClassVisitor, for (int index = 0; index < u2annotationsCount; index++) { Annotation annotation = new Annotation(); - visitAnnotation(clazz, annotation); + this.visitAnnotation(clazz, annotation); annotations[index] = annotation; } @@ -563,22 +527,6 @@ implements ClassVisitor, } - // Implementations for BootstrapMethodInfoVisitor. - - public void visitBootstrapMethodInfo(Clazz clazz, BootstrapMethodInfo bootstrapMethodInfo) - { - bootstrapMethodInfo.u2methodHandleIndex = dataInput.readUnsignedShort(); - - // Read the bootstrap method arguments. - bootstrapMethodInfo.u2methodArgumentCount = dataInput.readUnsignedShort(); - bootstrapMethodInfo.u2methodArguments = new int[bootstrapMethodInfo.u2methodArgumentCount]; - for (int index = 0; index < bootstrapMethodInfo.u2methodArgumentCount; index++) - { - bootstrapMethodInfo.u2methodArguments[index] = dataInput.readUnsignedShort(); - } - } - - // Implementations for InnerClassesInfoVisitor. public void visitInnerClassesInfo(Clazz clazz, InnerClassesInfo innerClassesInfo) @@ -773,7 +721,7 @@ implements ClassVisitor, { // Read the annotation. Annotation annotationValue = new Annotation(); - visitAnnotation(clazz, annotationValue); + this.visitAnnotation(clazz, annotationValue); annotationElementValue.annotationValue = annotationValue; } @@ -801,19 +749,16 @@ implements ClassVisitor, switch (u1tag) { + case ClassConstants.CONSTANT_Utf8: return new Utf8Constant(); case ClassConstants.CONSTANT_Integer: return new IntegerConstant(); case ClassConstants.CONSTANT_Float: return new FloatConstant(); case ClassConstants.CONSTANT_Long: return new LongConstant(); case ClassConstants.CONSTANT_Double: return new DoubleConstant(); case ClassConstants.CONSTANT_String: return new StringConstant(); - case ClassConstants.CONSTANT_Utf8: return new Utf8Constant(); - case ClassConstants.CONSTANT_InvokeDynamic: return new InvokeDynamicConstant(); - case ClassConstants.CONSTANT_MethodHandle: return new MethodHandleConstant(); case ClassConstants.CONSTANT_Fieldref: return new FieldrefConstant(); case ClassConstants.CONSTANT_Methodref: return new MethodrefConstant(); case ClassConstants.CONSTANT_InterfaceMethodref: return new InterfaceMethodrefConstant(); case ClassConstants.CONSTANT_Class: return new ClassConstant(); - case ClassConstants.CONSTANT_MethodType : return new MethodTypeConstant(); case ClassConstants.CONSTANT_NameAndType: return new NameAndTypeConstant(); default: throw new RuntimeException("Unknown constant type ["+u1tag+"] in constant pool"); @@ -826,9 +771,7 @@ implements ClassVisitor, int u2attributeNameIndex = dataInput.readUnsignedShort(); int u4attributeLength = dataInput.readInt(); String attributeName = clazz.getString(u2attributeNameIndex); - Attribute attribute = - attributeName.equals(ClassConstants.ATTR_BootstrapMethods) ? (Attribute)new BootstrapMethodsAttribute(): attributeName.equals(ClassConstants.ATTR_SourceFile) ? (Attribute)new SourceFileAttribute(): attributeName.equals(ClassConstants.ATTR_SourceDir) ? (Attribute)new SourceDirAttribute(): attributeName.equals(ClassConstants.ATTR_InnerClasses) ? (Attribute)new InnerClassesAttribute(): |