diff --git a/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java b/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java index d3deae4..7c1c937 100644 --- a/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java +++ b/src/main/java/org/apache/harmony/pack200/CPMethodOrField.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; } diff --git a/src/main/java/org/apache/harmony/pack200/CPNameAndType.java b/src/main/java/org/apache/harmony/pack200/CPNameAndType.java index 5b4d76b..52c3985 100644 --- a/src/main/java/org/apache/harmony/pack200/CPNameAndType.java +++ b/src/main/java/org/apache/harmony/pack200/CPNameAndType.java @@ -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; } diff --git a/src/main/java/org/apache/harmony/pack200/CpBands.java b/src/main/java/org/apache/harmony/pack200/CpBands.java index 81f7c5d..aad5037 100644 --- a/src/main/java/org/apache/harmony/pack200/CpBands.java +++ b/src/main/java/org/apache/harmony/pack200/CpBands.java @@ -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; diff --git a/src/main/java/org/apache/harmony/pack200/IcBands.java b/src/main/java/org/apache/harmony/pack200/IcBands.java index 6f1c375..8eac217 100644 --- a/src/main/java/org/apache/harmony/pack200/IcBands.java +++ b/src/main/java/org/apache/harmony/pack200/IcBands.java @@ -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(); } diff --git a/src/main/java/org/apache/harmony/pack200/NewAttribute.java b/src/main/java/org/apache/harmony/pack200/NewAttribute.java index a26099c..54b867b 100644 --- a/src/main/java/org/apache/harmony/pack200/NewAttribute.java +++ b/src/main/java/org/apache/harmony/pack200/NewAttribute.java @@ -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; } diff --git a/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java b/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java index 78ded58..29c024f 100644 --- a/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java +++ b/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java @@ -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 diff --git a/src/main/java/org/apache/harmony/pack200/PackingOptions.java b/src/main/java/org/apache/harmony/pack200/PackingOptions.java index db1dd4e..2eae1a7 100644 --- a/src/main/java/org/apache/harmony/pack200/PackingOptions.java +++ b/src/main/java/org/apache/harmony/pack200/PackingOptions.java @@ -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; diff --git a/src/main/java/org/apache/harmony/pack200/PopulationCodec.java b/src/main/java/org/apache/harmony/pack200/PopulationCodec.java index 5a2998b..2ed6456 100644 --- a/src/main/java/org/apache/harmony/pack200/PopulationCodec.java +++ b/src/main/java/org/apache/harmony/pack200/PopulationCodec.java @@ -167,8 +167,4 @@ public class PopulationCodec extends Codec { public Codec getTokenCodec() { return tokenCodec; } - - public int getL() { - return l; - } } diff --git a/src/main/java/org/apache/harmony/pack200/Segment.java b/src/main/java/org/apache/harmony/pack200/Segment.java index 0223d2d..bf96a5d 100644 --- a/src/main/java/org/apache/harmony/pack200/Segment.java +++ b/src/main/java/org/apache/harmony/pack200/Segment.java @@ -464,43 +464,8 @@ public class Segment implements ClassVisitor { name = ""; } nameRU.add(name); - addValueAndTag(value); - } - - 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()); - } + addValueAndTag(value, T, values); } - 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,38 +514,7 @@ 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)); - if (name == null) { - name = ""; - } - nameRU.add(name); - addValueAndTag(value); - } - - public AnnotationVisitor visitAnnotation(String arg0, - String arg1) { - throw new RuntimeException("Not yet supported"); - } - - public AnnotationVisitor visitArray(String arg0) { - throw new RuntimeException("Not yet supported"); -// return null; - } - - public void visitEnd() { - } - - 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); - } - }; + return new ArrayVisitor(caseArrayN, T, nameRU, values); } public void visitEnd() { @@ -603,6 +537,58 @@ public class Segment implements ClassVisitor { values.add(value); } } + + 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 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 AnnotationVisitor visitAnnotation(String arg0, + String arg1) { + throw new RuntimeException("Not yet supported"); + } + + 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() { + } + + 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); + } + } /** * SegmentFieldVisitor implements FieldVisitor to visit the @@ -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(); } diff --git a/src/main/java/org/apache/harmony/pack200/SegmentHeader.java b/src/main/java/org/apache/harmony/pack200/SegmentHeader.java index c06f985..53b158b 100644 --- a/src/main/java/org/apache/harmony/pack200/SegmentHeader.java +++ b/src/main/java/org/apache/harmony/pack200/SegmentHeader.java @@ -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(); } diff --git a/src/main/java/org/apache/harmony/unpack200/Archive.java b/src/main/java/org/apache/harmony/unpack200/Archive.java index 927a4ad..2cb5919 100644 --- a/src/main/java/org/apache/harmony/unpack200/Archive.java +++ b/src/main/java/org/apache/harmony/unpack200/Archive.java @@ -187,8 +187,11 @@ public class Archive { } } if (removePackFile) { - File file = new File(inputFileName); - boolean deleted = file.delete(); + boolean deleted = false; + if(inputFileName != null) { + File file = new File(inputFileName); + deleted = file.delete(); + } if (!deleted) { throw new Pack200Exception("Failed to delete the input file."); } diff --git a/src/main/java/org/apache/harmony/unpack200/AttributeLayout.java b/src/main/java/org/apache/harmony/unpack200/AttributeLayout.java index c263963..e6575b9 100644 --- a/src/main/java/org/apache/harmony/unpack200/AttributeLayout.java +++ b/src/main/java/org/apache/harmony/unpack200/AttributeLayout.java @@ -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) * diff --git a/src/main/java/org/apache/harmony/unpack200/BcBands.java b/src/main/java/org/apache/harmony/unpack200/BcBands.java index 3806173..40eb61e 100644 --- a/src/main/java/org/apache/harmony/unpack200/BcBands.java +++ b/src/main/java/org/apache/harmony/unpack200/BcBands.java @@ -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; - } - } diff --git a/src/main/java/org/apache/harmony/unpack200/ClassBands.java b/src/main/java/org/apache/harmony/unpack200/ClassBands.java index ed5459f..41e7aec 100644 --- a/src/main/java/org/apache/harmony/unpack200/ClassBands.java +++ b/src/main/java/org/apache/harmony/unpack200/ClassBands.java @@ -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]; diff --git a/src/main/java/org/apache/harmony/unpack200/CpBands.java b/src/main/java/org/apache/harmony/unpack200/CpBands.java index b771d4b..942c779 100644 --- a/src/main/java/org/apache/harmony/unpack200/CpBands.java +++ b/src/main/java/org/apache/harmony/unpack200/CpBands.java @@ -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; } diff --git a/src/main/java/org/apache/harmony/unpack200/IcTuple.java b/src/main/java/org/apache/harmony/unpack200/IcTuple.java index fe15724..549b971 100644 --- a/src/main/java/org/apache/harmony/unpack200/IcTuple.java +++ b/src/main/java/org/apache/harmony/unpack200/IcTuple.java @@ -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; diff --git a/src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java b/src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java index 61b3a8e..369565a 100644 --- a/src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java +++ b/src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java @@ -152,11 +152,11 @@ public class MetadataBandGroup { attributes.add(getParameterAttribute(param_NB[i], name_RU_Iterator)); } - } else { // type.equals("AD") - for (int i = 0; i < T.length; i++) { - attributes.add(new AnnotationDefaultAttribute( - new ElementValue(T[i], getNextValue(T[i])))); - } + } + } else if(type.equals("AD")){ + for (int i = 0; i < T.length; i++) { + attributes.add(new AnnotationDefaultAttribute( + new ElementValue(T[i], getNextValue(T[i])))); } } } diff --git a/src/main/java/org/apache/harmony/unpack200/Segment.java b/src/main/java/org/apache/harmony/unpack200/Segment.java index c2cfa48..a95307a 100644 --- a/src/main/java/org/apache/harmony/unpack200/Segment.java +++ b/src/main/java/org/apache/harmony/unpack200/Segment.java @@ -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); diff --git a/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java b/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java index d48e104..d8af070 100644 --- a/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java +++ b/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java @@ -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; } diff --git a/src/main/java/org/apache/harmony/unpack200/SegmentUtils.java b/src/main/java/org/apache/harmony/unpack200/SegmentUtils.java index c47a790..9590ba0 100644 --- a/src/main/java/org/apache/harmony/unpack200/SegmentUtils.java +++ b/src/main/java/org/apache/harmony/unpack200/SegmentUtils.java @@ -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); - } - } - } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java b/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java index 7ce6683..d621923 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java @@ -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(); } /* diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java b/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java index bcdcbe3..2e7a93c 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java @@ -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); diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java b/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java index c48ac21..7ce3606 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java @@ -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); diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/ClassFileEntry.java b/src/main/java/org/apache/harmony/unpack200/bytecode/ClassFileEntry.java index 440ed6b..2eb2185 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/ClassFileEntry.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/ClassFileEntry.java @@ -46,10 +46,6 @@ public abstract class ClassFileEntry { resolved = true; } - protected boolean isResolved() { - return resolved; - } - protected int objectHashCode() { return super.hashCode(); } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java b/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java index 42bba52..0878da9 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java @@ -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; diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/DeprecatedAttribute.java b/src/main/java/org/apache/harmony/unpack200/bytecode/DeprecatedAttribute.java index e302565..983cfde 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/DeprecatedAttribute.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/DeprecatedAttribute.java @@ -61,8 +61,4 @@ public class DeprecatedAttribute extends Attribute { return "Deprecated Attribute"; } - public boolean equals(Object obj) { - return this == obj; - } - } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java b/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java index 9f9b0cf..f53ef42 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java @@ -88,8 +88,4 @@ public class EnclosingMethodAttribute extends Attribute { return "EnclosingMethod"; } - public boolean equals(Object obj) { - return this == obj; - } - } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java b/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java index f8156c4..ed27fb2 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java @@ -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; - } } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java b/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java index e6662ce..7cb848b 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java @@ -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; - } - } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/OperandManager.java b/src/main/java/org/apache/harmony/unpack200/bytecode/OperandManager.java index d4a0acb..85082ff 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/OperandManager.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/OperandManager.java @@ -196,10 +196,6 @@ public class OperandManager { this.segment = segment; } - public Segment getSegment() { - return segment; - } - public SegmentConstantPool globalConstantPool() { return segment.getConstantPool(); } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java b/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java index 9d38991..9e82a6e 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java @@ -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); diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java b/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java index 02ccd3e..d15e3a7 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java @@ -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); diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java b/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java index 02bdb43..49cfdc7 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java @@ -76,8 +76,4 @@ public class SignatureAttribute extends Attribute { return "Signature: " + signature; } - - public boolean equals(Object obj) { - return this == obj; - } } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/LocalForm.java b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/LocalForm.java index 85c70d4..cc929f3 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/LocalForm.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/LocalForm.java @@ -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); } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/LookupSwitchForm.java b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/LookupSwitchForm.java index af8757f..2a5f023 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/LookupSwitchForm.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/LookupSwitchForm.java @@ -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) * diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/SwitchForm.java b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/SwitchForm.java index b2287c5..f812267 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/SwitchForm.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/SwitchForm.java @@ -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) * diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/TableSwitchForm.java b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/TableSwitchForm.java index 7265bad..30d7145 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/TableSwitchForm.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/TableSwitchForm.java @@ -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) * diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/VariableInstructionForm.java b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/VariableInstructionForm.java index 1d1be2f..6036273 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/VariableInstructionForm.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/VariableInstructionForm.java @@ -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. diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/WideForm.java b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/WideForm.java index b819154..ba6d607 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/forms/WideForm.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/forms/WideForm.java @@ -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) *