Pack200 - remove unused code and fix some minor bugs

git-svn-id: https://svn.apache.org/repos/asf/harmony/enhanced/java/trunk@997336 13f79535-47bb-0310-9956-ffa450edef68
master
Sian January 14 years ago
parent 1588d78053
commit a2730622e5
  1. 12
      src/main/java/org/apache/harmony/pack200/CPMethodOrField.java
  2. 12
      src/main/java/org/apache/harmony/pack200/CPNameAndType.java
  3. 8
      src/main/java/org/apache/harmony/pack200/CpBands.java
  4. 4
      src/main/java/org/apache/harmony/pack200/IcBands.java
  5. 8
      src/main/java/org/apache/harmony/pack200/NewAttribute.java
  6. 29
      src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java
  7. 16
      src/main/java/org/apache/harmony/pack200/PackingOptions.java
  8. 4
      src/main/java/org/apache/harmony/pack200/PopulationCodec.java
  9. 156
      src/main/java/org/apache/harmony/pack200/Segment.java
  10. 36
      src/main/java/org/apache/harmony/pack200/SegmentHeader.java
  11. 5
      src/main/java/org/apache/harmony/unpack200/Archive.java
  12. 41
      src/main/java/org/apache/harmony/unpack200/AttributeLayout.java
  13. 17
      src/main/java/org/apache/harmony/unpack200/BcBands.java
  14. 25
      src/main/java/org/apache/harmony/unpack200/ClassBands.java
  15. 20
      src/main/java/org/apache/harmony/unpack200/CpBands.java
  16. 12
      src/main/java/org/apache/harmony/unpack200/IcTuple.java
  17. 4
      src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java
  18. 8
      src/main/java/org/apache/harmony/unpack200/Segment.java
  19. 12
      src/main/java/org/apache/harmony/unpack200/SegmentHeader.java
  20. 37
      src/main/java/org/apache/harmony/unpack200/SegmentUtils.java
  21. 11
      src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java
  22. 5
      src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java
  23. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java
  24. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/ClassFileEntry.java
  25. 8
      src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java
  26. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/DeprecatedAttribute.java
  27. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java
  28. 6
      src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
  29. 6
      src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
  30. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/OperandManager.java
  31. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
  32. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
  33. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java
  34. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/forms/LocalForm.java
  35. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/forms/LookupSwitchForm.java
  36. 16
      src/main/java/org/apache/harmony/unpack200/bytecode/forms/SwitchForm.java
  37. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/forms/TableSwitchForm.java
  38. 36
      src/main/java/org/apache/harmony/unpack200/bytecode/forms/VariableInstructionForm.java
  39. 4
      src/main/java/org/apache/harmony/unpack200/bytecode/forms/WideForm.java

@ -31,18 +31,6 @@ public class CPMethodOrField extends ConstantPoolEntry implements Comparable {
this.nameAndType = nameAndType;
}
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof CPMethodOrField)) {
return false;
}
return ((CPMethodOrField) obj).className.equals(className)
&& ((CPMethodOrField) obj).nameAndType.equals(nameAndType);
}
public int hashCode() {
return className.hashCode() + nameAndType.hashCode();
}
public String toString() {
return className + ": " + nameAndType;
}

@ -29,18 +29,6 @@ public class CPNameAndType extends ConstantPoolEntry implements Comparable {
this.signature = signature;
}
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof CPNameAndType)) {
return false;
}
return ((CPNameAndType) obj).name.equals(name)
&& ((CPNameAndType) obj).signature.equals(signature);
}
public int hashCode() {
return name.hashCode() + signature.hashCode();
}
public String toString() {
return name + ":" + signature;
}

@ -499,14 +499,6 @@ public class CpBands extends BandSet {
return cpUtf8;
}
public void addCPNameAndType(String name, String signature) {
getCPNameAndType(name, signature);
}
public void addCPSignature(String signature) {
getCPSignature(signature);
}
public CPSignature getCPSignature(String signature) {
if(signature == null) {
return null;

@ -170,10 +170,6 @@ public class IcBands extends BandSet {
return false;
}
public int hashCode() {
return (C.hashCode() * 37) + F;
}
public String toString() {
return C.toString();
}

@ -112,13 +112,13 @@ public class NewAttribute extends Attribute {
public boolean isUnknown(int context) {
switch(context) {
case AttributeDefinitionBands.CONTEXT_CLASS:
return contextClass;
return !contextClass;
case AttributeDefinitionBands.CONTEXT_METHOD:
return contextMethod;
return !contextMethod;
case AttributeDefinitionBands.CONTEXT_FIELD:
return contextField;
return !contextField;
case AttributeDefinitionBands.CONTEXT_CODE:
return contextCode;
return !contextCode;
}
return false;
}

@ -16,9 +16,6 @@
*/
package org.apache.harmony.pack200;
import java.io.IOException;
import java.io.InputStream;
import org.objectweb.asm.ClassReader;
/**
@ -40,32 +37,6 @@ public class Pack200ClassReader extends ClassReader {
super(b);
}
/**
* @param is
* the input stream of class file
* @throws IOException
*/
public Pack200ClassReader(InputStream is) throws IOException {
super(is);
}
/**
* @param name
* @throws IOException
*/
public Pack200ClassReader(String name) throws IOException {
super(name);
}
/**
* @param b
* @param off
* @param len
*/
public Pack200ClassReader(byte[] b, int off, int len) {
super(b, off, len);
}
public int readUnsignedShort(int index) {
// Doing this to check whether last load-constant instruction was ldc (18) or ldc_w (19)
// TODO: Assess whether this impacts on performance

@ -185,10 +185,6 @@ public class PackingOptions {
passFiles.add(passFileName);
}
public void removePassFile(String passFileName) {
passFiles.remove(passFileName);
}
public String getUnknownAttributeAction() {
return unknownAttributeAction;
}
@ -317,6 +313,9 @@ public class PackingOptions {
}
public String getUnknownClassAttributeAction(String type) {
if (classAttributeActions == null) {
return unknownAttributeAction;
}
String action = (String) classAttributeActions.get(type);
if(action == null) {
action = unknownAttributeAction;
@ -325,6 +324,9 @@ public class PackingOptions {
}
public String getUnknownMethodAttributeAction(String type) {
if (methodAttributeActions == null) {
return unknownAttributeAction;
}
String action = (String) methodAttributeActions.get(type);
if(action == null) {
action = unknownAttributeAction;
@ -333,6 +335,9 @@ public class PackingOptions {
}
public String getUnknownFieldAttributeAction(String type) {
if (fieldAttributeActions == null) {
return unknownAttributeAction;
}
String action = (String) fieldAttributeActions.get(type);
if(action == null) {
action = unknownAttributeAction;
@ -341,6 +346,9 @@ public class PackingOptions {
}
public String getUnknownCodeAttributeAction(String type) {
if (codeAttributeActions == null) {
return unknownAttributeAction;
}
String action = (String) codeAttributeActions.get(type);
if(action == null) {
action = unknownAttributeAction;

@ -167,8 +167,4 @@ public class PopulationCodec extends Codec {
public Codec getTokenCodec() {
return tokenCodec;
}
public int getL() {
return l;
}
}

@ -464,43 +464,8 @@ public class Segment implements ClassVisitor {
name = "";
}
nameRU.add(name);
addValueAndTag(value);
addValueAndTag(value, T, values);
}
private void addValueAndTag(Object value) {
if(value instanceof Integer) {
T.add("I");
values.add(value);
} else if (value instanceof Double) {
T.add("D");
values.add(value);
} else if (value instanceof Float) {
T.add("F");
values.add(value);
} else if (value instanceof Long) {
T.add("J");
values.add(value);
} else if (value instanceof Byte) {
T.add("B");
values.add(new Integer(((Byte)value).intValue()));
} else if (value instanceof Character) {
T.add("C");
values.add(new Integer(((Character)value).charValue()));
} else if (value instanceof Short) {
T.add("S");
values.add(new Integer(((Short)value).intValue()));
} else if (value instanceof Boolean) {
T.add("Z");
values.add(new Integer(((Boolean)value).booleanValue() ? 1 : 0));
} else if (value instanceof String) {
T.add("s");
values.add(value);
} else if (value instanceof Type) {
T.add("c");
values.add(((Type)value).toString());
}
}
public AnnotationVisitor visitAnnotation(String name, String desc) {
T.add("@");
if (name == null) {
@ -514,7 +479,7 @@ public class Segment implements ClassVisitor {
Integer numPairs = (Integer) nestPairN.remove(nestPairN.size() - 1);
nestPairN.add(new Integer(numPairs.intValue() + 1));
nestNameRU.add(name);
addValueAndTag(value);
addValueAndTag(value, T, values);
}
public AnnotationVisitor visitAnnotation(String arg0,
@ -549,56 +514,77 @@ public class Segment implements ClassVisitor {
}
nameRU.add(name);
caseArrayN.add(new Integer(0));
return new AnnotationVisitor() {
public void visit(String name, Object value) {
Integer numCases = (Integer) caseArrayN.remove(caseArrayN.size() - 1);
caseArrayN.add(new Integer(numCases.intValue() + 1));
return new ArrayVisitor(caseArrayN, T, nameRU, values);
}
public void visitEnd() {
if (desc == null) {
Segment.this.classBands.addAnnotationDefault(nameRU, T, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
} else if(parameter != -1) {
Segment.this.classBands.addParameterAnnotation(parameter, desc, visible, nameRU, T, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
} else {
Segment.this.classBands.addAnnotation(context, desc, visible, nameRU, T, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
}
}
public void visitEnum(String name, String desc, String value) {
T.add("e");
if (name == null) {
name = "";
}
nameRU.add(name);
addValueAndTag(value);
values.add(desc);
values.add(value);
}
}
public AnnotationVisitor visitAnnotation(String arg0,
String arg1) {
throw new RuntimeException("Not yet supported");
public class ArrayVisitor implements AnnotationVisitor {
private int indexInCaseArrayN;
private List caseArrayN;
private List values;
private List nameRU;
private List T;
public ArrayVisitor(List caseArrayN, List T, List nameRU, List values) {
this.caseArrayN = caseArrayN;
this.T = T;
this.nameRU = nameRU;
this.values = values;
this.indexInCaseArrayN = caseArrayN.size() - 1;
}
public AnnotationVisitor visitArray(String arg0) {
throw new RuntimeException("Not yet supported");
// return null;
public void visit(String name, Object value) {
Integer numCases = (Integer) caseArrayN.remove(indexInCaseArrayN);
caseArrayN.add(indexInCaseArrayN, new Integer(numCases.intValue() + 1));
if (name == null) {
name = "";
}
addValueAndTag(value, T, values);
}
public void visitEnd() {
public AnnotationVisitor visitAnnotation(String arg0,
String arg1) {
throw new RuntimeException("Not yet supported");
}
public void visitEnum(String name, String desc, String value) {
Integer numCases = (Integer) caseArrayN.remove(caseArrayN.size() - 1);
caseArrayN.add(new Integer(numCases.intValue() + 1));
T.add("e");
values.add(desc);
values.add(value);
public AnnotationVisitor visitArray(String name) {
T.add("[");
if (name == null) {
name = "";
}
};
nameRU.add(name);
caseArrayN.add(new Integer(0));
return new ArrayVisitor(caseArrayN, T, nameRU, values);
}
public void visitEnd() {
if (desc == null) {
Segment.this.classBands.addAnnotationDefault(nameRU, T, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
} else if(parameter != -1) {
Segment.this.classBands.addParameterAnnotation(parameter, desc, visible, nameRU, T, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
} else {
Segment.this.classBands.addAnnotation(context, desc, visible, nameRU, T, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
}
}
public void visitEnum(String name, String desc, String value) {
Integer numCases = (Integer) caseArrayN.remove(caseArrayN.size() - 1);
caseArrayN.add(new Integer(numCases.intValue() + 1));
T.add("e");
if (name == null) {
name = "";
}
nameRU.add(name);
values.add(desc);
values.add(value);
}
@ -645,6 +631,42 @@ public class Segment implements ClassVisitor {
}
}
// helper method for annotation visitors
private void addValueAndTag(Object value, List T, List values) {
if(value instanceof Integer) {
T.add("I");
values.add(value);
} else if (value instanceof Double) {
T.add("D");
values.add(value);
} else if (value instanceof Float) {
T.add("F");
values.add(value);
} else if (value instanceof Long) {
T.add("J");
values.add(value);
} else if (value instanceof Byte) {
T.add("B");
values.add(new Integer(((Byte)value).intValue()));
} else if (value instanceof Character) {
T.add("C");
values.add(new Integer(((Character)value).charValue()));
} else if (value instanceof Short) {
T.add("S");
values.add(new Integer(((Short)value).intValue()));
} else if (value instanceof Boolean) {
T.add("Z");
values.add(new Integer(((Boolean)value).booleanValue() ? 1 : 0));
} else if (value instanceof String) {
T.add("s");
values.add(value);
} else if (value instanceof Type) {
T.add("c");
values.add(((Type)value).toString());
}
}
public boolean lastConstantHadWideIndex() {
return currentClassReader.lastConstantHadWideIndex();
}

@ -64,8 +64,8 @@ public class SegmentHeader extends BandSet {
private int file_count;
private boolean deflate_hint;
private boolean have_file_modtime = true;
private boolean have_file_options = true;
private final boolean have_file_modtime = true;
private final boolean have_file_options = true;
private boolean have_file_size_hi;
private boolean have_class_flags_hi;
private boolean have_field_flags_hi;
@ -190,22 +190,6 @@ public class SegmentHeader extends BandSet {
this.have_all_code_flags = have_all_code_flags;
}
public void setArchive_size_hi(int archive_size_hi) {
this.archive_size_hi = archive_size_hi;
}
public void setArchive_size_lo(int archive_size_lo) {
this.archive_size_lo = archive_size_lo;
}
public void setArchive_next_count(int archive_next_count) {
this.archive_next_count = archive_next_count;
}
public void setArchive_modtime(int archive_modtime) {
this.archive_modtime = archive_modtime;
}
public int getArchive_modtime() {
return archive_modtime;
}
@ -218,18 +202,6 @@ public class SegmentHeader extends BandSet {
this.deflate_hint = deflate_hint;
}
public void setHave_file_modtime(boolean have_file_modtime) {
this.have_file_modtime = have_file_modtime;
}
public void setHave_file_options(boolean have_file_options) {
this.have_file_options = have_file_options;
}
public void setHave_file_size_hi(boolean have_file_size_hi) {
this.have_file_size_hi = have_file_size_hi;
}
public void setHave_class_flags_hi(boolean have_class_flags_hi) {
this.have_class_flags_hi = have_class_flags_hi;
}
@ -361,10 +333,6 @@ public class SegmentHeader extends BandSet {
}
}
public int getDefaultMinorVersion() {
return 0;
}
public int getDefaultMajorVersion() {
return majverCounter.getMostCommon();
}

@ -187,8 +187,11 @@ public class Archive {
}
}
if (removePackFile) {
boolean deleted = false;
if(inputFileName != null) {
File file = new File(inputFileName);
boolean deleted = file.delete();
deleted = file.delete();
}
if (!deleted) {
throw new Pack200Exception("Failed to delete the input file.");
}

@ -145,31 +145,6 @@ public class AttributeLayout implements IMatcher {
this.isDefault = isDefault;
}
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final AttributeLayout other = (AttributeLayout) obj;
if (layout == null) {
if (other.layout != null)
return false;
} else if (!layout.equals(other.layout))
return false;
if (index != other.index)
return false;
if (context != other.context)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
public Codec getCodec() {
if (layout.indexOf('O') >= 0) {
return Codec.BRANCH5;
@ -226,22 +201,6 @@ public class AttributeLayout implements IMatcher {
return r;
}
public boolean isClass() {
return context == CONTEXT_CLASS;
}
public boolean isCode() {
return context == CONTEXT_CODE;
}
public boolean isField() {
return context == CONTEXT_FIELD;
}
public boolean isMethod() {
return context == CONTEXT_METHOD;
}
/*
* (non-Javadoc)
*

@ -586,21 +586,4 @@ public class BcBands extends BandSet {
public int[] getBcThisMethod() {
return bcThisMethod;
}
public int[] getBcEscRef() {
return bcEscRef;
}
public int[] getBcEscRefSize() {
return bcEscRefSize;
}
public int[] getBcEscSize() {
return bcEscSize;
}
public int[][] getBcEscByte() {
return bcEscByte;
}
}

@ -1037,6 +1037,8 @@ public class ClassBands extends BandSet {
mbg[i].name_RU = parseCPUTF8References(contextName
+ "_" + rxa + "_name_RU", in, Codec.UNSIGNED5,
pairCount);
} else {
pairCount = RxACount[i];
}
mbg[i].T = decodeBandInt(contextName + "_" + rxa + "_T", in,
Codec.BYTE1, pairCount + backwardsCallCounts[i]);
@ -1116,17 +1118,7 @@ public class ClassBands extends BandSet {
int backwardsCallsUsed = 0;
String[] RxA = new String[] { "RVA", "RIA", "RVPA", "RIPA", "AD" };
int[] rxaCounts = new int[] { 0, 0, 0, 0, 0 };
int[] backwardsCalls = new int[5];
int methodAttrIndex = 0;
for (int i = 0; i < backwardsCalls.length; i++) {
if (rxaCounts[i] > 0) {
backwardsCallsUsed++;
backwardsCalls[i] = methodAttrCalls[methodAttrIndex];
methodAttrIndex++;
} else {
backwardsCalls[i] = 0;
}
}
AttributeLayout rvaLayout = attrMap.getAttributeLayout(
AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
AttributeLayout.CONTEXT_METHOD);
@ -1151,6 +1143,17 @@ public class ClassBands extends BandSet {
rxaCounts[i] = SegmentUtils
.countMatches(methodFlags, rxaLayouts[i]);
}
int[] backwardsCalls = new int[5];
int methodAttrIndex = 0;
for (int i = 0; i < backwardsCalls.length; i++) {
if (rxaCounts[i] > 0) {
backwardsCallsUsed++;
backwardsCalls[i] = methodAttrCalls[methodAttrIndex];
methodAttrIndex++;
} else {
backwardsCalls[i] = 0;
}
}
MetadataBandGroup[] mbgs = parseMetadata(in, RxA, rxaCounts,
backwardsCalls, "method");
List[] attributeLists = new List[RxA.length];

@ -477,30 +477,14 @@ public class CpBands extends BandSet {
return cpDescriptor;
}
public double[] getCpDouble() {
return cpDouble;
}
public String[] getCpFieldClass() {
return cpFieldClass;
}
public String[] getCpFieldDescriptor() {
return cpFieldDescriptor;
}
public float[] getCpFloat() {
return cpFloat;
}
public String[] getCpIMethodClass() {
return cpIMethodClass;
}
public String[] getCpIMethodDescriptor() {
return cpIMethodDescriptor;
}
public int[] getCpInt() {
return cpInt;
}
@ -521,10 +505,6 @@ public class CpBands extends BandSet {
return cpSignature;
}
public String[] getCpString() {
return cpString;
}
public String[] getCpUTF8() {
return cpUTF8;
}

@ -61,10 +61,6 @@ public class IcTuple {
initializeClassStrings();
}
public IcTuple(String C, int F, int cIndex) {
this(C, F, null, null, cIndex, -1, -1, -1);
}
public static final int NESTED_CLASS_FLAG = 0x00010000;
protected String C; // this class
protected int F; // flags
@ -344,14 +340,6 @@ public class IcTuple {
return tIndex;
}
public String realOuterClassString() {
int firstDollarPosition = cachedOuterClassString.indexOf('$');
if (firstDollarPosition <= 0) {
return cachedOuterClassString;
}
return cachedOuterClassString.substring(0, firstDollarPosition);
}
public int thisClassIndex() {
if(predicted()) {
return cIndex;

@ -152,14 +152,14 @@ public class MetadataBandGroup {
attributes.add(getParameterAttribute(param_NB[i],
name_RU_Iterator));
}
} else { // type.equals("AD")
}
} else if(type.equals("AD")){
for (int i = 0; i < T.length; i++) {
attributes.add(new AnnotationDefaultAttribute(
new ElementValue(T[i], getNextValue(T[i]))));
}
}
}
}
return attributes;
}

@ -150,7 +150,12 @@ public class Segment {
AttributeLayout.ATTRIBUTE_SOURCE_FILE,
AttributeLayout.CONTEXT_CLASS);
if (SOURCE_FILE.matches(classBands.getRawClassFlags()[classNum])) {
int firstDollar = SegmentUtils.indexOfFirstDollar(fullName);
int firstDollar = -1;
for (int index = 0; index < fullName.length(); index++) {
if (fullName.charAt(index) <= '$') {
firstDollar = index;
}
}
String fileName = null;
if (firstDollar > -1 && (i <= firstDollar)) {
@ -225,7 +230,6 @@ public class Segment {
// methodDescr and methodFlags used to create this
for (i = 0; i < cfMethods.length; i++) {
int descriptorIndex = classBands.getMethodDescrInts()[classNum][i];
// int colon = descriptorStr.indexOf(':');
int nameIndex = cpBands.getCpDescriptorNameInts()[descriptorIndex];
int typeIndex = cpBands.getCpDescriptorTypeInts()[descriptorIndex];
CPUTF8 name = cpBands.cpUTF8Value(nameIndex);

@ -165,14 +165,6 @@ public class SegmentHeader {
return archiveModtime;
}
public int getArchiveMajor() {
return archiveMajor;
}
public int getArchiveMinor() {
return archiveMinor;
}
public int getAttributeDefinitionCount() {
return attributeDefinitionCount;
}
@ -241,10 +233,6 @@ public class SegmentHeader {
return innerClassCount;
}
public void setNumberOfFiles(int numberOfFiles) {
this.numberOfFiles = numberOfFiles;
}
public long getArchiveSize() {
return archiveSize;
}

@ -124,41 +124,4 @@ public final class SegmentUtils {
return count;
}
/**
* Answer the index of the first character <= '$' in the parameter. This is
* used instead of indexOf('$') because inner classes may be separated by
* any character <= '$' (in other words, Foo#Bar is as valid as Foo$Bar). If
* no $ character is found, answer -1.
*
* @param string
* String to search for $
* @return first index of $ character, or -1 if not found
*/
public static int indexOfFirstDollar(String string) {
for (int index = 0; index < string.length(); index++) {
if (string.charAt(index) <= '$') {
return index;
}
}
return -1;
}
private SegmentUtils() {
// Intended to be a helper class
}
/**
* This is a debugging message to aid the developer in writing this class.
* If the property 'debug.unpack200' is set, this will generate messages to
* stderr; otherwise, it will be silent.
*
* @param message
* @deprecated this may be removed from production code
*/
public static void debug(String message) {
if (System.getProperty("debug.unpack200") != null) {
System.err.println(message);
}
}
}

@ -100,17 +100,8 @@ public class ByteCode extends ClassFileEntry {
return getByteCodeForm().getOpcode();
}
private boolean hashcodeComputed;
private int cachedHashCode;
private void generateHashCode() {
cachedHashCode = objectHashCode();
}
public int hashCode() {
if (!hashcodeComputed)
generateHashCode();
return cachedHashCode;
return objectHashCode();
}
/*

@ -76,11 +76,6 @@ public abstract class CPRef extends ConstantPoolEntry {
return entries;
}
public int hashCode() {
final int PRIME = 37;
return (PRIME * className.hashCode()) + nameAndType.hashCode();
}
protected void resolve(ClassConstantPool pool) {
super.resolve(pool);
nameAndTypeIndex = pool.indexOf(nameAndType);

@ -39,10 +39,6 @@ public class ClassConstantPool {
protected Map indexCache;
public String toString() {
return entries.toString();
}
private final List others = new ArrayList(500);
private final List entries = new ArrayList(500);

@ -46,10 +46,6 @@ public abstract class ClassFileEntry {
resolved = true;
}
protected boolean isResolved() {
return resolved;
}
protected int objectHashCode() {
return super.hashCode();
}

@ -173,14 +173,6 @@ public class CodeAttribute extends BCIRenumberedAttribute {
}
}
public List attributes() {
return attributes;
}
public boolean equals(Object obj) {
return this == obj;
}
protected int[] getStartPCs() {
// Do nothing here as we've overriden renumber
return null;

@ -61,8 +61,4 @@ public class DeprecatedAttribute extends Attribute {
return "Deprecated Attribute";
}
public boolean equals(Object obj) {
return this == obj;
}
}

@ -88,8 +88,4 @@ public class EnclosingMethodAttribute extends Attribute {
return "EnclosingMethod";
}
public boolean equals(Object obj) {
return this == obj;
}
}

@ -28,7 +28,7 @@ import org.apache.harmony.pack200.Pack200Exception;
*/
public class LocalVariableTableAttribute extends BCIRenumberedAttribute {
private int local_variable_table_length;
private final int local_variable_table_length;
private final int[] start_pcs;
private final int[] lengths;
private int[] name_indexes;
@ -164,8 +164,4 @@ public class LocalVariableTableAttribute extends BCIRenumberedAttribute {
lengths[index] = revisedLength;
}
}
public boolean equals(Object obj) {
return this == obj;
}
}

@ -28,7 +28,7 @@ import org.apache.harmony.pack200.Pack200Exception;
*/
public class LocalVariableTypeTableAttribute extends BCIRenumberedAttribute {
private int local_variable_type_table_length;
private final int local_variable_type_table_length;
private final int[] start_pcs;
private final int[] lengths;
private int[] name_indexes;
@ -165,8 +165,4 @@ public class LocalVariableTypeTableAttribute extends BCIRenumberedAttribute {
+ " varaibles";
}
public boolean equals(Object obj) {
return this == obj;
}
}

@ -196,10 +196,6 @@ public class OperandManager {
this.segment = segment;
}
public Segment getSegment() {
return segment;
}
public SegmentConstantPool globalConstantPool() {
return segment.getConstantPool();
}

@ -69,10 +69,6 @@ public class RuntimeVisibleorInvisibleAnnotationsAttribute extends
+ " annotations";
}
public boolean equals(Object obj) {
return this == obj;
}
protected ClassFileEntry[] getNestedClassFileEntries() {
List nested = new ArrayList();
nested.add(attributeName);

@ -110,10 +110,6 @@ public class RuntimeVisibleorInvisibleParameterAnnotationsAttribute extends
}
public boolean equals(Object obj) {
return this == obj;
}
protected ClassFileEntry[] getNestedClassFileEntries() {
List nested = new ArrayList();
nested.add(attributeName);

@ -76,8 +76,4 @@ public class SignatureAttribute extends Attribute {
return "Signature: " + signature;
}
public boolean equals(Object obj) {
return this == obj;
}
}

@ -26,10 +26,6 @@ import org.apache.harmony.unpack200.bytecode.OperandManager;
*/
public class LocalForm extends ByteCodeForm {
public LocalForm(int opcode, String name) {
super(opcode, name);
}
public LocalForm(int opcode, String name, int[] rewrite) {
super(opcode, name, rewrite);
}

@ -25,10 +25,6 @@ public class LookupSwitchForm extends SwitchForm {
super(opcode, name);
}
public LookupSwitchForm(int opcode, String name, int[] rewrite) {
super(opcode, name, rewrite);
}
/*
* (non-Javadoc)
*

@ -18,7 +18,6 @@ package org.apache.harmony.unpack200.bytecode.forms;
import org.apache.harmony.unpack200.bytecode.ByteCode;
import org.apache.harmony.unpack200.bytecode.CodeAttribute;
import org.apache.harmony.unpack200.bytecode.OperandManager;
public abstract class SwitchForm extends VariableInstructionForm {
@ -26,21 +25,6 @@ public abstract class SwitchForm extends VariableInstructionForm {
super(opcode, name);
}
public SwitchForm(int opcode, String name, int[] rewrite) {
super(opcode, name, rewrite);
}
/*
* (non-Javadoc)
*
* @see org.apache.harmony.unpack200.bytecode.forms.ByteCodeForm#setByteCodeOperands(org.apache.harmony.unpack200.bytecode.ByteCode,
* org.apache.harmony.unpack200.bytecode.OperandTable,
* org.apache.harmony.unpack200.SegmentConstantPool)
*/
public void setByteCodeOperands(ByteCode byteCode,
OperandManager operandManager, int codeLength) {
}
/*
* (non-Javadoc)
*

@ -25,10 +25,6 @@ public class TableSwitchForm extends SwitchForm {
super(opcode, name);
}
public TableSwitchForm(int opcode, String name, int[] rewrite) {
super(opcode, name, rewrite);
}
/*
* (non-Javadoc)
*

@ -27,10 +27,6 @@ public abstract class VariableInstructionForm extends ByteCodeForm {
super(opcode, name);
}
public VariableInstructionForm(int opcode, String name, int[] rewrite) {
super(opcode, name, rewrite);
}
/**
* Given an int operand, set the rewrite bytes for the next available
* operand position and the three immediately following it to a
@ -64,38 +60,6 @@ public abstract class VariableInstructionForm extends ByteCodeForm {
setRewrite4Bytes(operand, firstOperandPosition, rewrite);
}
/**
* Given an int operand, set the rewrite bytes for the next available
* operand position and the byte immediately following it to a high-byte,
* low-byte encoding of the operand.
*
* Note that unlike the ByteCode setOperand* operations, this starts with an
* actual bytecode rewrite array (rather than a ByteCodeForm prototype
* rewrite array). Also, this method overwrites -1 values in the rewrite
* array - so if you start with an array that looks like: {100, -1, -1, -1,
* -1, 200, -1, -1, -1, -1} then calling setRewrite2Bytes(0, rewrite) the
* first time will convert it to: {100, 0, 0, -1, -1, 200, -1, -1, -1, -1}
* Calling setRewrite2Bytes(0, rewrite) a second time will convert it to:
* {100, 0, 0, 0, 0, 200, -1, -1, -1, -1}
*
* @param operand
* int to set the rewrite bytes to
* @param rewrite
* int[] bytes to rewrite
*/
public void setRewrite2Bytes(int operand, int[] rewrite) {
int firstOperandPosition = -1;
// Find the first -1 in the rewrite array
for (int index = 0; index < rewrite.length - 3; index++) {
if ((rewrite[index] == -1) && (rewrite[index + 1] == -1)) {
firstOperandPosition = index;
break;
}
}
setRewrite2Bytes(operand, firstOperandPosition, rewrite);
}
/**
* This method writes operand directly into the rewrite array at index
* position specified.

@ -30,10 +30,6 @@ public class WideForm extends VariableInstructionForm {
super(opcode, name);
}
public WideForm(int opcode, String name, int[] rewrite) {
super(opcode, name, rewrite);
}
/*
* (non-Javadoc)
*

Loading…
Cancel
Save