Author: sjanuary
Date: Wed Apr 2 03:50:18 2008
New Revision: 643840
URL: http://svn.apache.org/viewvc?rev=643840&view=rev
Log:
Apply patch for HARMONY-5677 ([classlib][pack200] Removed unnecessary sort code)
Removed:
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassPoolSet.java
Modified:
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ByteCode.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NarrowClassRefForm.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/SingleByteReferenceForm.java
harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CPUTF8Test.java
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java
Wed Apr 2 03:50:18 2008
@@ -291,7 +291,9 @@
}
}
+ protected ConstantPoolEntry cachedCpAll[] = {};
public ConstantPoolEntry[] getCpAll() throws Pack200Exception {
+ if(cachedCpAll.length == 0) {
ArrayList cpAll = new ArrayList();
// TODO: this is 1.5-specific. Try to get rid
// of it.
@@ -325,11 +327,10 @@
for(int index=0; index < bands.getCpIMethodClass().length; index++) {
cpAll.add(getConstantPoolEntry(CP_IMETHOD, index));
}
-
ConstantPoolEntry[] result = new ConstantPoolEntry[cpAll.size()];
cpAll.toArray(result);
- return result;
+ cachedCpAll = result;
}
-
-
+ return cachedCpAll;
}
+}
\ No newline at end of file
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ByteCode.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ByteCode.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ByteCode.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ByteCode.java
Wed Apr 2 03:50:18 2008
@@ -133,13 +133,6 @@
setOperand2Bytes(pool.indexOf(nested[index]), getNestedPosition(index)[0]);
break;
- case 4:
- // TODO: need to handle wides?
- SegmentUtils.debug("Need to handle wides");
- throw new Error("Instruction argument not handled");
- // figure out and if so, handle and put a break here.
- // break;
-
default:
SegmentUtils.debug("Unhandled resolve " + this);
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java
Wed Apr 2 03:50:18 2008
@@ -84,11 +84,4 @@
protected void writeBody(DataOutputStream dos) throws IOException {
dos.writeShort(index);
}
-
- public String comparisonString() {
- // TODO: what to do about inner classes?
- if(name==null) {return "null:name (probably an inner class?)";};
- return getName();
- }
-
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java
Wed Apr 2 03:50:18 2008
@@ -53,7 +53,4 @@
protected Object getValue() {
return value;
}
-
-
-
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java
Wed Apr 2 03:50:18 2008
@@ -25,7 +25,6 @@
transient int classNameIndex;
private CPNameAndType nameAndType;
transient int nameAndTypeIndex;
- private String cachedComparisonString = null;
public CPFieldRef(CPClass className, CPNameAndType descriptor) {
super(ConstantPoolEntry.CP_Fieldref);
@@ -52,13 +51,6 @@
public String toString() {
return "FieldRef: " + className + "#" + nameAndType;
}
-
- public String comparisonString() {
- if(cachedComparisonString == null) {
- cachedComparisonString = (className.getName() + Character.MAX_VALUE) + nameAndType.descriptor
+ Character.MAX_VALUE + nameAndType.name;
- }
- return cachedComparisonString;
- }
public int hashCode() {
final int PRIME = 31;
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java
Wed Apr 2 03:50:18 2008
@@ -31,8 +31,6 @@
transient int nameIndex;
- protected String cachedComparisonString = null;
-
public CPNameAndType(CPUTF8 name, CPUTF8 descriptor, int domain) {
super(ConstantPoolEntry.CP_NameAndType);
this.name = name;
@@ -106,47 +104,4 @@
public int invokeInterfaceCount() {
return 1 + SegmentUtils.countInvokeInterfaceArgs(descriptor.underlyingString());
}
-
-
- /* (non-Javadoc)
- * @see org.apache.harmony.pack200.bytecode.ConstantPoolEntry#comparisonString()
- */
- public String comparisonString() {
- // First come those things which don't have an
- // associated signature. Then come the native signatures,
- // then finally the class signatures.
- // TODO: I think Character.MAX_VALUE is no longer the
- // biggest character, what with the weird codepage thing
- // going on. How to sort these things so that even if
- // they're in some oddball codepage they'll still end
- // up sorted correctly?
- if(cachedComparisonString != null) {
- return cachedComparisonString;
- }
- String descriptorString = descriptor.underlyingString();
- StringBuffer comparisonBuffer = new StringBuffer();
- if((descriptorString.indexOf("(")) == -1) {
- // it's a variable reference
- comparisonBuffer.append(descriptor.underlyingString());
- } else {
- // it's a signature. Append something that will
- // make the comparison buffer bigger than all
- // non-signature references.
- comparisonBuffer.append(Character.MAX_VALUE);
- // do the natives first
- if(descriptorString.length() <= 4) {
- // it's a native signature
- comparisonBuffer.append(descriptor.underlyingString());
- } else {
- // it's a non-native signature. Append something
- // that will make the comparison buffer bigger
- // than all native signature references.
- comparisonBuffer.append(Character.MAX_VALUE);
- comparisonBuffer.append(descriptor.underlyingString());
- }
- }
- comparisonBuffer.append(name.underlyingString());
- cachedComparisonString = comparisonBuffer.toString();
- return cachedComparisonString;
- }
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java
Wed Apr 2 03:50:18 2008
@@ -26,7 +26,6 @@
protected CPNameAndType nameAndType;
transient int nameAndTypeIndex;
- private String resolvedComparisonString = null;
public CPRef(byte type, CPClass className, CPNameAndType descriptor) {
super(type);
@@ -81,54 +80,22 @@
classNameIndex = pool.indexOf(className);
}
- public String comparisonString() {
- // This one is tricky. The sorting appears to be
- // done based on the indices of the method descriptor
- // and class name in the classpool *after* sorting them.
-
- // If we haven't yet been resolved, just do a normal
- // compare (so things like .contains() work).
- if(!isResolved()) {
- return super.comparisonString();
- }
-
- // If we get here, the receiver has been resolved; there
- // is a different sort order.
- if(resolvedComparisonString != null) {
- return resolvedComparisonString;
- }
-
- StringBuffer result = new StringBuffer();
- // Pad all numbers to 6 digits so they sort correctly.
- int padLength = 6;
- int classIndexLength = ("" + classNameIndex).length();
- int nameAndTypeIndexLength = ("" + nameAndTypeIndex).length();
-
- for(int index=0; index < (padLength - classIndexLength); index++) {
- result.append('0');
- }
- result.append("" + classNameIndex);
- result.append(":");
- for(int index=0; index < (padLength - nameAndTypeIndexLength); index++) {
- result.append('0');
- }
- result.append("" + nameAndTypeIndex);
- resolvedComparisonString = result.toString();
- return resolvedComparisonString;
- }
-
+ protected String cachedToString = null;
public String toString() {
- String type;
- if (getTag() == ConstantPoolEntry.CP_Fieldref) {
- type = "FieldRef"; //$NON-NLS-1$
- } else if (getTag() == ConstantPoolEntry.CP_Methodref) {
- type = "MethoddRef"; //$NON-NLS-1$
- } else if (getTag() == ConstantPoolEntry.CP_InterfaceMethodref) {
- type = "InterfaceMethodRef"; //$NON-NLS-1$
- } else {
- type = "unknown"; //$NON-NLS-1$
- }
- return type + ": " + className + "#" + nameAndType; //$NON-NLS-1$ //$NON-NLS-2$
+ if(cachedToString == null) {
+ String type;
+ if (getTag() == ConstantPoolEntry.CP_Fieldref) {
+ type = "FieldRef"; //$NON-NLS-1$
+ } else if (getTag() == ConstantPoolEntry.CP_Methodref) {
+ type = "MethoddRef"; //$NON-NLS-1$
+ } else if (getTag() == ConstantPoolEntry.CP_InterfaceMethodref) {
+ type = "InterfaceMethodRef"; //$NON-NLS-1$
+ } else {
+ type = "unknown"; //$NON-NLS-1$
+ }
+ cachedToString = type + ": " + className + "#" + nameAndType; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return cachedToString;
}
protected void writeBody(DataOutputStream dos) throws IOException {
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java
Wed Apr 2 03:50:18 2008
@@ -23,7 +23,6 @@
private transient int nameIndex;
private CPUTF8 name;
- private boolean mustStartClassPool = false;
public CPString(CPUTF8 value) {
super(ConstantPoolEntry.CP_String, value);
@@ -53,29 +52,4 @@
protected ClassFileEntry[] getNestedClassFileEntries() {
return new ClassFileEntry[] { name };
}
-
- public String comparisonString() {
- return ((CPUTF8)getValue()).underlyingString();
- }
-
- /**
- * Set whether the receiver must be at the start of the
- * class pool. Anything which is the target of a single-
- * byte ldc (bytecode 18, String) command must be at
- * the start of the class pool.
- *
- * @param b boolean true if the receiver must be at
- * the start of the class pool, otherwise false.
- */
- public void mustStartClassPool(boolean b) {
- mustStartClassPool = b;
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.harmony.pack200.bytecode.ClassFileEntry#mustStartClassPool()
- */
- public boolean mustStartClassPool() {
- return mustStartClassPool;
- }
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java
Wed Apr 2 03:50:18 2008
@@ -24,8 +24,6 @@
private String utf8;
- private String cachedSignatureComparisonString = null;
-
public CPUTF8(String utf8, int domain) {
super(ConstantPoolEntry.CP_UTF8);
this.utf8 = utf8;
@@ -82,48 +80,4 @@
public String underlyingString() {
return utf8;
}
-
- public String comparisonString() {
- // Should use either normalComparisonString or signatureComparisonString.
- // If we get here, that might indicate an error.
- throw new Error("Should use specific kinds of comparisonString() on CPUTF8s");
- }
-
- public String normalComparisonString() {
- // TODO: what to do about inner classes?
- if(utf8==null) {return "null:utf8 (probably an inner class?)";};
- return utf8;
- }
-
- public String signatureComparisonString() {
- if(cachedSignatureComparisonString != null) {
- return cachedSignatureComparisonString;
- }
- // TODO: what to do about inner classes?
- if(utf8==null) {return "null:utf8 (probably an inner class?)";};
- StringBuffer alphaChars = new StringBuffer();
- StringBuffer extraChars = new StringBuffer();
- if(utf8.length() > 0){
- if(utf8.charAt(0) == '(') {
- // Things with return values (which apparently
- // always begin with '(') sort after things
- // without return values.
- // TODO: need a better way for this - possibly in the comparator?
- alphaChars.append(Character.MAX_VALUE);
- }
- }
- // TODO: need a better way for this - possibly in the comparator?
- extraChars.append(Character.MAX_VALUE);
- for(int index=0; index < utf8.length(); index++) {
- if( (utf8.charAt(index) == '(') || (utf8.charAt(index) == ')') || (utf8.charAt(index)
== '[') || (utf8.charAt(index) == ']') ) {
- extraChars.append(utf8.charAt(index));
- } else {
- alphaChars.append(utf8.charAt(index));
- }
- }
- extraChars.append(Character.MAX_VALUE);
- extraChars.append(utf8); // make sure the chars are distinct
- cachedSignatureComparisonString = alphaChars.toString() + extraChars.toString();
- return(cachedSignatureComparisonString);
- }
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
Wed Apr 2 03:50:18 2008
@@ -44,7 +44,6 @@
public static final int DOMAIN_ATTRIBUTEASCIIZ = 12;
public static final int NUM_DOMAINS = DOMAIN_ATTRIBUTEASCIIZ + 1;
- protected ClassPoolSet classPoolSet = new ClassPoolSet();
protected HashSet entriesContainsSet = new HashSet();
protected HashSet othersContainsSet = new HashSet();
@@ -81,8 +80,6 @@
if (!entriesContainsSet.contains(entry)) {
entriesContainsSet.add(entry);
entries.add(entry);
- if (entry instanceof CPLong ||entry instanceof CPDouble)
- entries.add(entry); //these get 2 slots because of their size
}
} else {
if (!othersContainsSet.contains(entry)) {
@@ -112,17 +109,6 @@
}
}
- public int indexOfOld(ClassFileEntry entry) {
- if (!resolved)
- throw new IllegalStateException("Constant pool is not yet resolved; this does
not make any sense");
- int entryIndex = entries.indexOf(entry);
- // If the entry isn't found, answer -1. Otherwise answer the entry.
- if(entryIndex != -1) {
- return entryIndex + 1;
- }
- return -1;
- }
-
public int indexOf(ClassFileEntry entry) {
if (!resolved)
throw new IllegalStateException("Constant pool is not yet resolved; this does
not make any sense");
@@ -148,48 +134,56 @@
}
public void resolve(Segment segment) {
- classPoolSet = new ClassPoolSet();
- Iterator it = entries.iterator();
- while(it.hasNext()) {
- classPoolSet.add(it.next());
- }
- entries = new ArrayList(entries.size());
- Iterator sortedIterator = classPoolSet.iterator();
- while(sortedIterator.hasNext()) {
- ConstantPoolEntry entry = (ConstantPoolEntry)sortedIterator.next();
- entries.add(entry);
- // need to do this both here and in the sort below
- // so the indices are correct.
- if (entry instanceof CPLong ||entry instanceof CPDouble)
- entries.add(entry); //these get 2 slots because of their size
+ Iterator it;
+ resolved= true;
+ it = entries.iterator();
+ while (it.hasNext()) {
+ ClassFileEntry entry = (ClassFileEntry) it.next();
+ entry.resolve(this);
+ }
+ it = others.iterator();
+ while (it.hasNext()) {
+ ClassFileEntry entry = (ClassFileEntry) it.next();
+ entry.resolve(this);
}
- resolve();
+
+ sortClassPool(segment);
}
- public void resolve() {
- resolved= true;
+ /**
+ * Answer the collection of CPClasses currently held
+ * by the ClassPoolSet. This is used to calculate relevant
+ * classes when generating the set of relevant inner
+ * classes (ic_relevant())
+ * @return ArrayList collection of all classes.
+ *
+ * NOTE: when this list is answered, the classes may not
+ * yet be resolved.
+ */
+ public List allClasses() {
+ List classesList = new ArrayList();
Iterator it = entries.iterator();
- while (it.hasNext()) {
- ClassFileEntry entry = (ClassFileEntry) it.next();
- entry.resolve(this);
- }
- it = others.iterator();
- while (it.hasNext()) {
- ClassFileEntry entry = (ClassFileEntry) it.next();
- entry.resolve(this);
+ while(it.hasNext()) {
+ ConstantPoolEntry entry = (ConstantPoolEntry)it.next();
+ if(entry.getDomain() == DOMAIN_CLASSREF) {
+ classesList.add(entry);
+ }
}
+ return classesList;
+ }
+ protected void sortClassPool(Segment segment) {
// Now that everything has been resolved, do one
// final sort of the class pool. This fixes up
- // references, which are sorted by index in the
- // class pool.
+ // references to objects which need to be at the
+ // start of the class pool
// Since we resorted, need to initialize index cache
initializeIndexCache();
- it = entries.iterator();
- ClassPoolSet startOfPool = new ClassPoolSet();
- ClassPoolSet finalSort = new ClassPoolSet();
+ Iterator it = entries.iterator();
+ ArrayList startOfPool = new ArrayList();
+ ArrayList finalSort = new ArrayList();
while(it.hasNext()) {
ClassFileEntry nextEntry = (ClassFileEntry)it.next();
if(nextEntry.mustStartClassPool()) {
@@ -231,27 +225,5 @@
ClassFileEntry entry = (ClassFileEntry)it.next();
entry.resolve(this);
}
- }
-
- /**
- * Answer the collection of CPClasses currently held
- * by the ClassPoolSet. This is used to calculate relevant
- * classes when generating the set of relevant inner
- * classes (ic_relevant())
- * @return ArrayList collection of all classes.
- *
- * NOTE: when this list is answered, the classes may not
- * yet be resolved.
- */
- public List allClasses() {
- List classesList = new ArrayList();
- Iterator it = entries.iterator();
- while(it.hasNext()) {
- ConstantPoolEntry entry = (ConstantPoolEntry)it.next();
- if(entry.getDomain() == DOMAIN_CLASSREF) {
- classesList.add(entry);
- }
- }
- return classesList;
}
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java
Wed Apr 2 03:50:18 2008
@@ -57,21 +57,9 @@
byte tag;
protected int domain = ClassConstantPool.DOMAIN_UNDEFINED;
- private static int creationOrderCount = 100;
- protected String cachedConstantPoolComparisonString = null;
-
- public String comparisonString() {
- if(cachedConstantPoolComparisonString == null) {
- cachedConstantPoolComparisonString = toString();
- }
- return cachedConstantPoolComparisonString;
- }
-
- public int creationOrder = -1;
ConstantPoolEntry(byte tag) {
this.tag = tag;
- this.creationOrder = creationOrderCount++;
}
public abstract boolean equals(Object obj);
@@ -96,4 +84,25 @@
}
protected abstract void writeBody(DataOutputStream dos) throws IOException;
+
+ private boolean mustStartClassPool = false;
+ /**
+ * Set whether the receiver must be at the start of the
+ * class pool. Anything which is the target of a single-
+ * byte ldc (bytecode 18) command must be at the start
+ * of the class pool.
+ *
+ * @param b boolean true if the receiver must be at
+ * the start of the class pool, otherwise false.
+ */
+ public void mustStartClassPool(boolean b) {
+ mustStartClassPool = b;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.harmony.pack200.bytecode.ClassFileEntry#mustStartClassPool()
+ */
+ public boolean mustStartClassPool() {
+ return mustStartClassPool;
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NarrowClassRefForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NarrowClassRefForm.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NarrowClassRefForm.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NarrowClassRefForm.java
Wed Apr 2 03:50:18 2008
@@ -18,6 +18,7 @@
import org.apache.harmony.pack200.Pack200Exception;
import org.apache.harmony.pack200.bytecode.ByteCode;
+import org.apache.harmony.pack200.bytecode.CPClass;
import org.apache.harmony.pack200.bytecode.OperandManager;
/**
@@ -40,6 +41,7 @@
super.setNestedEntries(byteCode, operandManager, offset);
if(!widened) {
byteCode.setNestedPositions(new int[][] {{0,1}});
+ ((CPClass)byteCode.getNestedClassFileEntries()[0]).mustStartClassPool(true);
}
}
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/SingleByteReferenceForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/SingleByteReferenceForm.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/SingleByteReferenceForm.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/SingleByteReferenceForm.java
Wed Apr 2 03:50:18 2008
@@ -18,6 +18,7 @@
import org.apache.harmony.pack200.Pack200Exception;
import org.apache.harmony.pack200.bytecode.ByteCode;
+import org.apache.harmony.pack200.bytecode.ConstantPoolEntry;
import org.apache.harmony.pack200.bytecode.OperandManager;
/**
@@ -45,6 +46,7 @@
byteCode.setNestedPositions(new int[][] {{0,2}});
} else {
byteCode.setNestedPositions(new int[][] {{0,1}});
+ ((ConstantPoolEntry)byteCode.getNestedClassFileEntries()[0]).mustStartClassPool(true);
}
}
}
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CPUTF8Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CPUTF8Test.java?rev=643840&r1=643839&r2=643840&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CPUTF8Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CPUTF8Test.java
Wed Apr 2 03:50:18 2008
@@ -23,20 +23,6 @@
public class CPUTF8Test extends TestCase {
- public void testUnequalCompareStrings() {
- CPUTF8 one = new CPUTF8("(III)V", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
- CPUTF8 two = new CPUTF8("((I[II)V", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
- CPUTF8 three = new CPUTF8("([III)V", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
- assertFalse(one.normalComparisonString().equals(two.normalComparisonString()));
- assertFalse(one.signatureComparisonString().equals(two.signatureComparisonString()));
-
- assertFalse(one.normalComparisonString().equals(three.normalComparisonString()));
- assertFalse(one.signatureComparisonString().equals(three.signatureComparisonString()));
-
- assertFalse(two.normalComparisonString().equals(three.normalComparisonString()));
- assertFalse(two.signatureComparisonString().equals(three.signatureComparisonString()));
- }
-
public void testEquality() {
CPUTF8 one = new CPUTF8("(III)V", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
CPUTF8 two = new CPUTF8("((I[II)V", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
|