summaryrefslogtreecommitdiff
path: root/src/proguard/classfile/io
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2012-02-27 18:34:24 -0800
committerYing Wang <wangying@google.com>2012-02-27 18:34:24 -0800
commit9f606f95f03a75961498803e24bee6799a7c0885 (patch)
treea45f4d74feda9b76277a0c9ced55ad15d82248a1 /src/proguard/classfile/io
parentcfead78069f3dc32998dc118ee08cab3867acea2 (diff)
downloadproguard-9f606f95f03a75961498803e24bee6799a7c0885.tar.gz
This reverts commit cfead78069f3dc32998dc118ee08cab3867acea2. Bug: 6079915
Diffstat (limited to 'src/proguard/classfile/io')
-rw-r--r--src/proguard/classfile/io/LibraryClassReader.java25
-rw-r--r--src/proguard/classfile/io/ProgramClassReader.java79
-rw-r--r--src/proguard/classfile/io/ProgramClassWriter.java53
-rw-r--r--src/proguard/classfile/io/RuntimeDataInput.java2
-rw-r--r--src/proguard/classfile/io/RuntimeDataOutput.java2
5 files changed, 19 insertions, 142 deletions
diff --git a/src/proguard/classfile/io/LibraryClassReader.java b/src/proguard/classfile/io/LibraryClassReader.java
index 32bb569..f14471c 100644
--- a/src/proguard/classfile/io/LibraryClassReader.java
+++ b/src/proguard/classfile/io/LibraryClassReader.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
@@ -277,18 +277,6 @@ implements ClassVisitor,
}
- public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
- {
- dataInput.skipBytes(4);
- }
-
-
- public void visitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant)
- {
- dataInput.skipBytes(3);
- }
-
-
public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant)
{
dataInput.skipBytes(4);
@@ -301,12 +289,6 @@ implements ClassVisitor,
}
- public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant)
- {
- dataInput.skipBytes(2);
- }
-
-
public void visitNameAndTypeConstant(Clazz clazz, NameAndTypeConstant nameAndTypeConstant)
{
dataInput.skipBytes(4);
@@ -343,19 +325,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");
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():
diff --git a/src/proguard/classfile/io/ProgramClassWriter.java b/src/proguard/classfile/io/ProgramClassWriter.java
index 53995d4..e56f08a 100644
--- a/src/proguard/classfile/io/ProgramClassWriter.java
+++ b/src/proguard/classfile/io/ProgramClassWriter.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
@@ -57,7 +57,7 @@ implements ClassVisitor,
/**
- * Creates a new ProgramClassWriter for writing to the given DataOutput.
+ * Creates a new ProgramClassWriter for reading from the given DataOutput.
*/
public ProgramClassWriter(DataOutput dataOutput)
{
@@ -208,20 +208,6 @@ implements ClassVisitor,
}
- public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
- {
- dataOutput.writeShort(invokeDynamicConstant.u2bootstrapMethodAttributeIndex);
- dataOutput.writeShort(invokeDynamicConstant.u2nameAndTypeIndex);
- }
-
-
- public void visitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant)
- {
- dataOutput.writeByte(methodHandleConstant.u1referenceKind);
- dataOutput.writeShort(methodHandleConstant.u2referenceIndex);
- }
-
-
public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant)
{
dataOutput.writeShort(refConstant.u2classIndex);
@@ -235,12 +221,6 @@ implements ClassVisitor,
}
- public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant)
- {
- dataOutput.writeShort(methodTypeConstant.u2descriptorIndex);
- }
-
-
public void visitNameAndTypeConstant(Clazz clazz, NameAndTypeConstant nameAndTypeConstant)
{
dataOutput.writeShort(nameAndTypeConstant.u2nameIndex);
@@ -283,7 +263,6 @@ implements ClassVisitor,
private class AttributeBodyWriter
extends SimplifiedVisitor
implements AttributeVisitor,
- BootstrapMethodInfoVisitor,
InnerClassesInfoVisitor,
ExceptionInfoVisitor,
StackMapFrameVisitor,
@@ -303,15 +282,6 @@ implements ClassVisitor,
}
- public void visitBootstrapMethodsAttribute(Clazz clazz, BootstrapMethodsAttribute bootstrapMethodsAttribute)
- {
- // Write the bootstrap methods.
- dataOutput.writeShort(bootstrapMethodsAttribute.u2bootstrapMethodsCount);
-
- bootstrapMethodsAttribute.bootstrapMethodEntriesAccept(clazz, this);
- }
-
-
public void visitSourceFileAttribute(Clazz clazz, SourceFileAttribute sourceFileAttribute)
{
dataOutput.writeShort(sourceFileAttribute.u2sourceFileIndex);
@@ -468,7 +438,8 @@ implements ClassVisitor,
for (int index = 0; index < u2annotationsCount; index++)
{
- visitAnnotation(clazz, annotations[index]);
+ Annotation annotation = annotations[index];
+ this.visitAnnotation(clazz, annotation);
}
}
@@ -482,22 +453,6 @@ implements ClassVisitor,
}
- // Implementations for BootstrapMethodInfoVisitor.
-
- public void visitBootstrapMethodInfo(Clazz clazz, BootstrapMethodInfo bootstrapMethodInfo)
- {
- dataOutput.writeShort(bootstrapMethodInfo.u2methodHandleIndex);
-
- // Write the bootstrap method arguments.
- dataOutput.writeShort(bootstrapMethodInfo.u2methodArgumentCount);
-
- for (int index = 0; index < bootstrapMethodInfo.u2methodArgumentCount; index++)
- {
- dataOutput.writeShort(bootstrapMethodInfo.u2methodArguments[index]);
- }
- }
-
-
// Implementations for InnerClassesInfoVisitor.
public void visitInnerClassesInfo(Clazz clazz, InnerClassesInfo innerClassesInfo)
diff --git a/src/proguard/classfile/io/RuntimeDataInput.java b/src/proguard/classfile/io/RuntimeDataInput.java
index 7225ec9..104b7c9 100644
--- a/src/proguard/classfile/io/RuntimeDataInput.java
+++ b/src/proguard/classfile/io/RuntimeDataInput.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
diff --git a/src/proguard/classfile/io/RuntimeDataOutput.java b/src/proguard/classfile/io/RuntimeDataOutput.java
index 75d0642..ffde3af 100644
--- a/src/proguard/classfile/io/RuntimeDataOutput.java
+++ b/src/proguard/classfile/io/RuntimeDataOutput.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