harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r632326 [1/2] - in /harmony/enhanced/classlib/trunk/modules/pack200/src: main/java/org/apache/harmony/pack200/ main/java/org/apache/harmony/pack200/bytecode/ main/java/org/apache/harmony/pack200/bytecode/forms/ test/java/org/apache/harmony/...
Date Fri, 29 Feb 2008 14:25:03 GMT
Author: sjanuary
Date: Fri Feb 29 06:24:57 2008
New Revision: 632326

URL: http://svn.apache.org/viewvc?rev=632326&view=rev
Log:
Changes how constants are created in pack200 to avoid duplicates

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
    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/AnnotationDefaultAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationsAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/BCIRenumberedAttribute.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/CPDouble.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPField.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/CPFloat.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInterfaceMethodRef.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethodRef.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/CodeAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantValueAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/EnclosingMethodAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/InnerClassesAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LineNumberTableAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTableAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTypeTableAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/NewAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SignatureAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/StringRefForm.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ClassFileEntryTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java Fri Feb 29 06:24:57 2008
@@ -497,7 +497,7 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPInteger(new Integer(reference[index]));
+            result[i1] = segment.getCpBands().cpIntegerValue(new Integer(reference[index]));
         }
         return result;
     }
@@ -511,7 +511,7 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPDouble(new Double(reference[index]));
+            result[i1] = segment.getCpBands().cpDoubleValue(new Double(reference[index]));
         }
         return result;
     }
@@ -525,7 +525,7 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPFloat(new Float(reference[index]));
+            result[i1] = segment.getCpBands().cpFloatValue(new Float(reference[index]));
         }
         return result;
     }
@@ -539,7 +539,7 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPLong(new Long(reference[index]));
+            result[i1] = segment.getCpBands().cpLongValue(new Long(reference[index]));
         }
         return result;
     }
@@ -553,7 +553,7 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPUTF8(reference[index], ClassConstantPool.DOMAIN_UNDEFINED);
+            result[i1] = segment.getCpBands().cpUTF8Value(reference[index], ClassConstantPool.DOMAIN_NORMALASCIIZ);
         }
         return result;
     }
@@ -574,7 +574,7 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result1[i1] = new CPUTF8(reference[index], ClassConstantPool.DOMAIN_UNDEFINED);
+            result1[i1] = segment.getCpBands().cpUTF8Value(reference[index], ClassConstantPool.DOMAIN_NORMALASCIIZ);
         }
         CPUTF8[] refs = result1;
         int pos = 0;
@@ -596,58 +596,69 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPString(reference[index]);
+            result[i1] = segment.getCpBands().cpStringValue(reference[index]);
         }
         return result;
     }
 
     public CPInterfaceMethodRef[] parseCPInterfaceMethodRefReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        String[] reference = segment.getCpBands().getCpIMethodClass();
-        String[] descriptors = segment.getCpBands().getCpIMethodDescriptor();
+        CpBands cpBands = segment.getCpBands();
+        String[] reference = cpBands.getCpIMethodClass();
+        String[] descriptors = cpBands.getCpIMethodDescriptor();
         int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
         CPInterfaceMethodRef[] result = new CPInterfaceMethodRef[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
-                        "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPInterfaceMethodRef(reference[index], descriptors[index]);
+                        "Something has gone wrong during parsing references, index = "
+                                + index + ", array size = " + reference.length);
+            result[i1] = new CPInterfaceMethodRef(cpBands
+                    .cpClassValue(reference[index]), cpBands
+                    .cpNameAndTypeValue(descriptors[index]));
         }
         return result;
     }
 
     public CPMethodRef[] parseCPMethodRefReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        String[] reference = segment.getCpBands().getCpMethodClass();
-        String[] descriptors = segment.getCpBands().getCpMethodDescriptor();
+        CpBands cpBands = segment.getCpBands();
+        String[] reference = cpBands.getCpMethodClass();
+        String[] descriptors = cpBands.getCpMethodDescriptor();
         int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
         CPMethodRef[] result = new CPMethodRef[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
-                        "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPMethodRef(reference[index], descriptors[index]);
+                        "Something has gone wrong during parsing references, index = "
+                                + index + ", array size = " + reference.length);
+            result[i1] = new CPMethodRef(cpBands.cpClassValue(reference[index]),
+                    cpBands.cpNameAndTypeValue(descriptors[index]));
         }
         return result;
     }
 
     public CPFieldRef[] parseCPFieldRefReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        String[] reference = segment.getCpBands().getCpFieldClass();
-        String[] descriptors = segment.getCpBands().getCpFieldDescriptor();
+        CpBands cpBands = segment.getCpBands();
+        String[] reference = cpBands.getCpFieldClass();
+        String[] descriptors = cpBands.getCpFieldDescriptor();
         int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
         CPFieldRef[] result = new CPFieldRef[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
-                        "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPFieldRef(reference[index], descriptors[index]);
+                        "Something has gone wrong during parsing references, index = "
+                                + index + ", array size = " + reference.length);
+            result[i1] = new CPFieldRef(cpBands.cpClassValue(reference[index]),
+                    cpBands.cpNameAndTypeValue(descriptors[index]));
         }
         return result;
     }
 
     public CPNameAndType[] parseCPDescriptorReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        String[] reference = segment.getCpBands().getCpDescriptor();
+        CpBands cpBands = segment.getCpBands();
+        String[] reference = cpBands.getCpDescriptor();
         int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
         CPNameAndType[] result = new CPNameAndType[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
@@ -655,7 +666,7 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPNameAndType(reference[index]);
+            result[i1] = cpBands.cpNameAndTypeValue(reference[index]);
         }
         return result;
     }
@@ -669,7 +680,7 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPUTF8(reference[index], ClassConstantPool.DOMAIN_UNDEFINED);
+            result[i1] = segment.getCpBands().cpUTF8Value(reference[index], ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
         }
         return result;
     }
@@ -683,7 +694,7 @@
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
-            result[i1] = new CPClass(reference[index]);
+            result[i1] = segment.getCpBands().cpClassValue(reference[index]);
         }
         return result;
     }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java Fri Feb 29 06:24:57 2008
@@ -386,7 +386,7 @@
                     if(handlerCount != null) {
                         for (int j = 0; j < handlerCount[i]; j++) {
                             String handlerClass = handlerClassTypes[i][j];
-                            CPClass cpHandlerClass = new CPClass(handlerClass);
+                            CPClass cpHandlerClass = segment.getCpBands().cpClassValue(handlerClass);
                             ExceptionTableEntry entry = new ExceptionTableEntry(
                                     handlerStartPCs[i][j], handlerEndPCs[i][j],
                                     handlerCatchPCs[i][j], cpHandlerClass);

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java Fri Feb 29 06:24:57 2008
@@ -24,9 +24,15 @@
 
 import org.apache.harmony.pack200.bytecode.Attribute;
 import org.apache.harmony.pack200.bytecode.CPClass;
+import org.apache.harmony.pack200.bytecode.CPDouble;
+import org.apache.harmony.pack200.bytecode.CPFloat;
+import org.apache.harmony.pack200.bytecode.CPInteger;
+import org.apache.harmony.pack200.bytecode.CPLong;
 import org.apache.harmony.pack200.bytecode.CPNameAndType;
+import org.apache.harmony.pack200.bytecode.CPString;
 import org.apache.harmony.pack200.bytecode.CPUTF8;
 import org.apache.harmony.pack200.bytecode.ClassConstantPool;
+import org.apache.harmony.pack200.bytecode.ClassFileEntry;
 import org.apache.harmony.pack200.bytecode.ConstantValueAttribute;
 import org.apache.harmony.pack200.bytecode.EnclosingMethodAttribute;
 import org.apache.harmony.pack200.bytecode.ExceptionsAttribute;
@@ -228,8 +234,8 @@
                         type = "I";
                     Object value = constantValueLayout.getValue(result, type,
                             cpBands.getConstantPool());
-                    fieldAttributes[i][j]
-                            .add(new ConstantValueAttribute(value));
+                    fieldAttributes[i][j].add(new ConstantValueAttribute(
+                            getClassFileEntry(value)));
                     constantValueIndex++;
                 }
                 if (signatureLayout.matches(flag)) {
@@ -238,7 +244,7 @@
                     String desc = fieldDescr[i][j];
                     int colon = desc.indexOf(':');
                     String type = desc.substring(colon + 1);
-                    CPUTF8 value = new CPUTF8((String) signatureLayout.getValue(result, type,
+                    CPUTF8 value = cpBands.cpUTF8Value((String) signatureLayout.getValue(result, type,
                             cpBands.getConstantPool()), ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
                     fieldAttributes[i][j]
                             .add(new SignatureAttribute(value));
@@ -256,6 +262,24 @@
         }
     }
 
+    private ClassFileEntry getClassFileEntry(Object value) {
+        ClassFileEntry entry = null;
+        if (value instanceof ClassFileEntry) {
+            entry = (ClassFileEntry)value;
+        } else if (value instanceof java.lang.Integer) {
+            entry = cpBands.cpIntegerValue((Integer) value);
+        } else if (value instanceof java.lang.Long) {
+            entry = cpBands.cpLongValue((Long) value);
+        } else if (value instanceof java.lang.Float) {
+            entry = cpBands.cpFloatValue((Float) value);
+        } else if (value instanceof java.lang.Double) {
+            entry = cpBands.cpDoubleValue((Double) value);
+        } else if (value instanceof java.lang.String) {
+            entry = cpBands.cpStringValue((String) value);
+        }
+        return entry;
+    }
+
     private void parseMethodBands(InputStream in) throws IOException,
             Pack200Exception {
         methodDescr = parseReferences("method_descr", in, Codec.MDELTA5,
@@ -344,7 +368,7 @@
                     String[] exceptions = methodExceptionsRS[methodExceptionsIndex];
                     CPClass[] exceptionClasses = new CPClass[n];
                     for (int k = 0; k < n; k++) {
-                        exceptionClasses[k] = new CPClass(exceptions[k]);
+                        exceptionClasses[k] = cpBands.cpClassValue(exceptions[k]);
                     }
                     methodAttributes[i][j].add(new ExceptionsAttribute(
                             exceptionClasses));
@@ -362,8 +386,8 @@
                         type = "I";
                     Object value = methodSignatureLayout.getValue(result, type, cpBands
                             .getConstantPool());
-                    methodAttributes[i][j]
-                            .add(new ConstantValueAttribute(value));
+                    methodAttributes[i][j].add(new ConstantValueAttribute(
+                            getClassFileEntry(value)));
                     methodSignatureIndex++;
                 }
                 // Non-predefined attributes
@@ -561,12 +585,12 @@
                     // Add .java to the end
                     value = className + ".java";
                 }
-                classAttributes[i].add(new SourceFileAttribute(value));
+                classAttributes[i].add(new SourceFileAttribute(cpBands.cpUTF8Value(value, ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ)));
                 sourceFileIndex++;
             }
             if (enclosingMethodLayout.matches(flag)) {
-                CPClass theClass = new CPClass(enclosingMethodRC[enclosingMethodIndex]);
-                CPNameAndType theMethod = new CPNameAndType(enclosingMethodRDN[enclosingMethodIndex]);
+                CPClass theClass = cpBands.cpClassValue(enclosingMethodRC[enclosingMethodIndex]);
+                CPNameAndType theMethod = cpBands.cpNameAndTypeValue(enclosingMethodRDN[enclosingMethodIndex]);
                 classAttributes[i].add(new EnclosingMethodAttribute(theClass, theMethod));
                 enclosingMethodIndex++;
             }
@@ -574,7 +598,8 @@
                 long result = classSignature[signatureIndex];
                 Object value = signatureLayout.getValue(result, cpBands
                         .getConstantPool());
-                classAttributes[i].add(new ConstantValueAttribute(value));
+                classAttributes[i].add(new ConstantValueAttribute(
+                        getClassFileEntry(value)));
                 signatureIndex++;
             }
             if (innerClassLayout.matches(flag)) {
@@ -887,7 +912,7 @@
         for (int i = 0; i < strings.length; i++) {
             cpUTF8s[i] = new CPUTF8[strings[i].length];
             for (int j = 0; j < strings[i].length; j++) {
-                cpUTF8s[i][j] = new CPUTF8(strings[i][j], ClassConstantPool.DOMAIN_NORMALASCIIZ);
+                cpUTF8s[i][j] = cpBands.cpUTF8Value(strings[i][j], ClassConstantPool.DOMAIN_NORMALASCIIZ);
             }
         }
         return cpUTF8s;
@@ -898,7 +923,7 @@
     private CPUTF8[] stringsToCPUTF8(String[] strings) {
         CPUTF8[] cpUTF8s = new CPUTF8[strings.length];
         for (int i = 0; i < strings.length; i++) {
-            cpUTF8s[i] = new CPUTF8(strings[i], ClassConstantPool.DOMAIN_UNDEFINED);
+            cpUTF8s[i] = cpBands.cpUTF8Value(strings[i], ClassConstantPool.DOMAIN_NORMALASCIIZ);
         }
         return cpUTF8s;
     }
@@ -950,7 +975,7 @@
             int[] backwardsCallCounts, String contextName) throws IOException, Pack200Exception {
         MetadataBandGroup[] mbg = new MetadataBandGroup[RxA.length];
         for (int i = 0; i < RxA.length; i++) {
-            mbg[i] = new MetadataBandGroup(RxA[i]);
+            mbg[i] = new MetadataBandGroup(RxA[i], cpBands);
             String rxa = RxA[i];
             if (rxa.indexOf("P") >= 0) {
                 mbg[i].param_NB = decodeBandInt(contextName + "_" + rxa

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java Fri Feb 29 06:24:57 2008
@@ -19,6 +19,17 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.harmony.pack200.bytecode.CPClass;
+import org.apache.harmony.pack200.bytecode.CPDouble;
+import org.apache.harmony.pack200.bytecode.CPFloat;
+import org.apache.harmony.pack200.bytecode.CPInteger;
+import org.apache.harmony.pack200.bytecode.CPLong;
+import org.apache.harmony.pack200.bytecode.CPNameAndType;
+import org.apache.harmony.pack200.bytecode.CPString;
+import org.apache.harmony.pack200.bytecode.CPUTF8;
+import org.apache.harmony.pack200.bytecode.ClassConstantPool;
 
 public class CpBands extends BandSet {
 
@@ -26,39 +37,33 @@
         return pool;
     }
 
-
     private final SegmentConstantPool pool = new SegmentConstantPool(this);
 
     private String[] cpClass;
-
     private String[] cpDescriptor;
-
     private double[] cpDouble;
-
     private String[] cpFieldClass;
-
     private String[] cpFieldDescriptor;
-
     private float[] cpFloat;
-
     private String[] cpIMethodClass;
-
     private String[] cpIMethodDescriptor;
-
     private int[] cpInt;
-
     private long[] cpLong;
-
     private String[] cpMethodClass;
-
     private String[] cpMethodDescriptor;
-
     private String[] cpSignature;
-
     private String[] cpString;
-
     private String[] cpUTF8;
 
+    private HashMap[] stringsToCPUTF8 = new HashMap[ClassConstantPool.NUM_DOMAINS];
+    private HashMap stringsToCPStrings = new HashMap();
+    private HashMap longsToCPLongs = new HashMap();
+    private HashMap integersToCPIntegers = new HashMap();
+    private HashMap floatsToCPFloats = new HashMap();
+    private HashMap stringsToCPClass = new HashMap();
+    private HashMap doublesToCPDoubles = new HashMap();
+    private HashMap descriptorsToCPNameAndTypes = new HashMap();
+
 
     public CpBands(Segment segment) {
         super(segment);
@@ -419,4 +424,107 @@
         return cpUTF8;
     }
 
-}
+    public CPUTF8 cpUTF8Value(String string, int domain) {
+        if(stringsToCPUTF8[domain] == null) {
+            stringsToCPUTF8[domain] = new HashMap();
+        }
+        CPUTF8 cputf8 = (CPUTF8) stringsToCPUTF8[domain].get(string);
+        if(cputf8 == null) {
+            cputf8 = new CPUTF8(string, domain);
+            stringsToCPUTF8[domain].put(string, cputf8);
+        }
+        return cputf8;
+    }
+
+    public CPString cpStringValue(String string) {
+        CPString cpString = (CPString) stringsToCPStrings.get(string);
+        if(cpString == null) {
+            cpString = new CPString(cpUTF8Value(string, ClassConstantPool.DOMAIN_NORMALASCIIZ));
+            stringsToCPStrings.put(string, cpString);
+        }
+        return cpString;
+    }
+
+    public CPLong cpLongValue(Long l) {
+        CPLong cpLong = (CPLong) longsToCPLongs.get(l);
+        if(cpLong == null) {
+            cpLong = new CPLong(l);
+            longsToCPLongs.put(l, cpLong);
+        }
+        return cpLong;
+    }
+
+    public CPInteger cpIntegerValue(Integer i) {
+        CPInteger cpInteger = (CPInteger) integersToCPIntegers.get(i);
+        if(cpInteger == null) {
+            cpInteger = new CPInteger(i);
+            integersToCPIntegers.put(i, cpInteger);
+        }
+        return cpInteger;
+    }
+
+    public CPFloat cpFloatValue(Float f) {
+        CPFloat cpFloat = (CPFloat) floatsToCPFloats.get(f);
+        if(cpFloat == null) {
+            cpFloat = new CPFloat(f);
+            floatsToCPFloats.put(f, cpFloat);
+        }
+        return cpFloat;
+    }
+
+    public CPClass cpClassValue(String string) {
+        CPClass cpString = (CPClass) stringsToCPClass.get(string);
+        if(cpString == null) {
+            cpString = new CPClass(cpUTF8Value(string, ClassConstantPool.DOMAIN_NORMALASCIIZ));
+            stringsToCPClass.put(string, cpString);
+        }
+        return cpString;
+    }
+
+    public CPDouble cpDoubleValue(Double dbl) {
+        CPDouble cpDouble = (CPDouble) doublesToCPDoubles.get(dbl);
+        if(cpDouble == null) {
+            cpDouble = new CPDouble(dbl);
+            doublesToCPDoubles.put(dbl, cpDouble);
+        }
+        return cpDouble;
+    }
+
+    public CPNameAndType cpNameAndTypeValue(String descriptor) {
+        CPNameAndType cpNameAndType = (CPNameAndType) descriptorsToCPNameAndTypes.get(descriptor);
+        if(cpNameAndType == null) {
+            int descriptorDomain = ClassConstantPool.DOMAIN_UNDEFINED;
+            int colon = descriptor.indexOf(':');
+            String nameString = descriptor.substring(0,colon);
+            String descriptorString = descriptor.substring(colon+1);
+            // For some reason, descriptors which have just plain
+            // native types are stored in DOMAIN_NORMALASCIIZ rather
+            // than in DOMAIN_SIGNATUREASCIIZ. This might indicate
+            // that DOMAIN_SIGNATUREASCIIZ is poorly named.
+            boolean nativeDescriptor = true;
+            for(int index=0; index < descriptorString.length(); index++) {
+                char currentChar = descriptorString.charAt(index);
+                if(Character.isLetter(currentChar)) {
+                    if(currentChar == 'L') {
+                        nativeDescriptor = false;
+                    }
+                    break;
+                }
+            }
+            int domain = ClassConstantPool.DOMAIN_NAMEANDTYPE;
+            CPUTF8 name = cpUTF8Value(nameString, ClassConstantPool.DOMAIN_NORMALASCIIZ);
+            if( nativeDescriptor ) {
+                // Native signatures are stored in DOMAIN_NORMALASCIIZ, not
+                // DOMAIN_SIGNATUREASCIIZ for some reason.
+                descriptorDomain = ClassConstantPool.DOMAIN_NORMALASCIIZ;
+            } else {
+                descriptorDomain = ClassConstantPool.DOMAIN_SIGNATUREASCIIZ;
+            }
+            CPUTF8 descriptorU = cpUTF8Value(descriptorString, descriptorDomain);
+            cpNameAndType = new CPNameAndType(name, descriptorU, domain);
+            descriptorsToCPNameAndTypes.put(descriptor, cpNameAndType);
+        }
+        return cpNameAndType;
+    }
+
+}
\ No newline at end of file

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java Fri Feb 29 06:24:57 2008
@@ -29,6 +29,7 @@
 import org.apache.harmony.pack200.bytecode.CPLong;
 import org.apache.harmony.pack200.bytecode.CPNameAndType;
 import org.apache.harmony.pack200.bytecode.CPUTF8;
+import org.apache.harmony.pack200.bytecode.ClassConstantPool;
 import org.apache.harmony.pack200.bytecode.RuntimeVisibleorInvisibleAnnotationsAttribute;
 import org.apache.harmony.pack200.bytecode.RuntimeVisibleorInvisibleParameterAnnotationsAttribute;
 import org.apache.harmony.pack200.bytecode.AnnotationsAttribute.Annotation;
@@ -41,9 +42,11 @@
 public class MetadataBandGroup {
 
     private String type;
+    private CpBands cpBands;
 
-    public MetadataBandGroup(String type) {
+    public MetadataBandGroup(String type, CpBands cpBands) {
         this.type = type;
+        this.cpBands = cpBands;
     }
 
     private List attributes;
@@ -148,9 +151,10 @@
             annotations[i] = getAnnotation(types[i], pairCounts[i], namesIterator);
         }
         return new RuntimeVisibleorInvisibleAnnotationsAttribute(type
-                .equals("RVA") ? "RuntimeVisibleAnnotations"
-                : "RuntimeInvisibleAnnotations",
-                annotations);
+                .equals("RVA") ? cpBands.cpUTF8Value("RuntimeVisibleAnnotations",
+                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ) : cpBands.cpUTF8Value(
+                "RuntimeInvisibleAnnotations",
+                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ), annotations);
     }
 
     private Attribute getParameterAttribute(int numParameters, Iterator namesIterator ) {
@@ -165,8 +169,11 @@
             parameter_annotations[i] = new ParameterAnnotation(annotations);
         }
         return new RuntimeVisibleorInvisibleParameterAnnotationsAttribute(type
-                .equals("RVA") ? "RuntimeVisibleParameterAnnotations"
-                : "RuntimeInvisibleParameterAnnotations",
+                .equals("RVA") ? cpBands.cpUTF8Value(
+                "RuntimeVisibleParameterAnnotations",
+                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ) : cpBands.cpUTF8Value(
+                "RuntimeInvisibleParameterAnnotations",
+                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ),
                 parameter_annotations);
     }
 
@@ -201,7 +208,7 @@
             case 'e':
                 // TODO: check this - it may not work if the first string already has a colon in it
                 String enumString = caseet_Iterator.next() + ":" + caseec_Iterator.next();
-                return new CPNameAndType(enumString);
+                return cpBands.cpNameAndTypeValue(enumString);
             case 's':
                 return cases_Iterator.next();
             case '[':

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java Fri Feb 29 06:24:57 2008
@@ -35,6 +35,7 @@
 import org.apache.harmony.pack200.bytecode.CPNameAndType;
 import org.apache.harmony.pack200.bytecode.CPString;
 import org.apache.harmony.pack200.bytecode.CPUTF8;
+import org.apache.harmony.pack200.bytecode.ClassConstantPool;
 import org.apache.harmony.pack200.bytecode.NewAttribute;
 
 /**
@@ -102,7 +103,9 @@
      * @return
      */
     private Attribute getOneAttribute(int index, List elements) {
-        NewAttribute attribute = new NewAttribute(attributeLayout.getName());
+        NewAttribute attribute = new NewAttribute(segment.getCpBands()
+                .cpUTF8Value(attributeLayout.getName(),
+                        ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ));
         for (Iterator iter = elements.iterator(); iter.hasNext();) {
             AttributeLayoutElement element = (AttributeLayoutElement) iter.next();
             element.addToAttribute(index, attribute);

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java Fri Feb 29 06:24:57 2008
@@ -140,31 +140,40 @@
 		        fileName = fullName.substring(i) + ".java";
 		    }
 			classFile.attributes = new Attribute[] { (Attribute) cp
-					.add(new SourceFileAttribute(fileName)) };
+					.add(new SourceFileAttribute(cpBands.cpUTF8Value(fileName, ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ))) };
 		} else {
 			classFile.attributes = new Attribute[] {};
 		}
 		// this/superclass
-		ClassFileEntry cfThis = cp.add(new CPClass(fullName));
-		ClassFileEntry cfSuper = cp.add(new CPClass(classBands.getClassSuper()[classNum]));
+		ClassFileEntry cfThis = cp.add(cpBands.cpClassValue(fullName));
+		ClassFileEntry cfSuper = cp.add(cpBands.cpClassValue(classBands.getClassSuper()[classNum]));
 		// add interfaces
 		ClassFileEntry cfInterfaces[] = new ClassFileEntry[classBands.getClassInterfaces()[classNum].length];
 		for (i = 0; i < cfInterfaces.length; i++) {
-			cfInterfaces[i] = cp.add(new CPClass(classBands.getClassInterfaces()[classNum][i]));
+			cfInterfaces[i] = cp.add(cpBands.cpClassValue(classBands.getClassInterfaces()[classNum][i]));
 		}
 		// add fields
 		ClassFileEntry cfFields[] = new ClassFileEntry[classBands.getClassFieldCount()[classNum]];
 		// fieldDescr and fieldFlags used to create this
 		for (i = 0; i < cfFields.length; i++) {
-			cfFields[i] = cp.add(new CPField(classBands.getFieldDescr()[classNum][i],
+            String descriptorStr = classBands.getFieldDescr()[classNum][i];
+            int colon = descriptorStr.indexOf(':');
+            CPUTF8 name = cpBands.cpUTF8Value(descriptorStr.substring(0,colon), ClassConstantPool.DOMAIN_NORMALASCIIZ);
+            CPUTF8 descriptor = cpBands.cpUTF8Value(descriptorStr.substring(colon+1), ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
+            cfFields[i] = cp.add(new CPField(name, descriptor,
                     classBands.getFieldFlags()[classNum][i], classBands.getFieldAttributes()[classNum][i]));
 		}
 		// add methods
 		ClassFileEntry cfMethods[] = new ClassFileEntry[classBands.getClassMethodCount()[classNum]];
 		// fieldDescr and fieldFlags used to create this
 		for (i = 0; i < cfMethods.length; i++) {
-			cfMethods[i] = cp.add(new CPMethod(classBands.getMethodDescr()[classNum][i],
-                    classBands.getMethodFlags()[classNum][i], classBands.getMethodAttributes()[classNum][i]));
+            String descriptorStr = classBands.getMethodDescr()[classNum][i];
+            int colon = descriptorStr.indexOf(':');
+            CPUTF8 name = cpBands.cpUTF8Value(descriptorStr.substring(0,colon), ClassConstantPool.DOMAIN_NORMALASCIIZ);
+            CPUTF8 descriptor = cpBands.cpUTF8Value(descriptorStr.substring(colon+1), ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
+			cfMethods[i] = cp.add(new CPMethod(name, descriptor, classBands
+                    .getMethodFlags()[classNum][i], classBands
+                    .getMethodAttributes()[classNum][i]));
 		}
 
 		// add inner class attribute (if required)
@@ -187,14 +196,14 @@
 		    CPClass outerClass = null;
 
 		    if(ic_stored[index].isAnonymous()) {
-		        innerClass = new CPClass(innerClassString);
+		        innerClass = cpBands.cpClassValue(innerClassString);
 		    } else {
-	            innerClass = new CPClass(innerClassString);
-	            innerName = new CPUTF8(simpleClassName, ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+	            innerClass = cpBands.cpClassValue(innerClassString);
+	            innerName = cpBands.cpUTF8Value(simpleClassName, ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
 		    }
 
 		    if(ic_stored[index].isMember()) {
-		        outerClass = new CPClass(outerClassString);
+		        outerClass = cpBands.cpClassValue(outerClassString);
 		    }
 
 	        int flags = ic_stored[index].F;
@@ -429,7 +438,6 @@
 			}
 		}
 		dos.flush();
-		out.finish();
 		out.flush();
 	}
 

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=632326&r1=632325&r2=632326&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 Fri Feb 29 06:24:57 2008
@@ -18,16 +18,9 @@
 
 import java.util.ArrayList;
 
-import org.apache.harmony.pack200.bytecode.CPClass;
-import org.apache.harmony.pack200.bytecode.CPDouble;
 import org.apache.harmony.pack200.bytecode.CPFieldRef;
-import org.apache.harmony.pack200.bytecode.CPFloat;
-import org.apache.harmony.pack200.bytecode.CPInteger;
 import org.apache.harmony.pack200.bytecode.CPInterfaceMethodRef;
-import org.apache.harmony.pack200.bytecode.CPLong;
 import org.apache.harmony.pack200.bytecode.CPMethodRef;
-import org.apache.harmony.pack200.bytecode.CPString;
-import org.apache.harmony.pack200.bytecode.CPUTF8;
 import org.apache.harmony.pack200.bytecode.ClassConstantPool;
 import org.apache.harmony.pack200.bytecode.ConstantPoolEntry;
 
@@ -60,6 +53,7 @@
     public static final int CP_METHOD = 11;
     public static final int CP_IMETHOD = 12;
 
+    // TODO: All CP***??
     public Object getValue(int cp, long value) throws Pack200Exception {
         int index = (int) value;
         if (index == -1) {
@@ -77,7 +71,7 @@
         } else if (cp == CP_DOUBLE) {
             return new Double(bands.getCpDouble()[index]);
         } else if (cp == CP_STRING) {
-            return bands.getCpString()[index];
+            return bands.cpStringValue(bands.getCpString()[index]);
         } else if (cp == CP_CLASS) {
             return bands.getCpClass()[index];
         } else if (cp == SIGNATURE) {
@@ -231,19 +225,19 @@
         } else if (index < 0) {
             throw new Pack200Exception("Cannot have a negative range");
         } else if (cp == UTF_8) {
-            return new CPUTF8(bands.getCpUTF8()[index], ClassConstantPool.DOMAIN_NORMALASCIIZ);
+            return bands.cpUTF8Value(bands.getCpUTF8()[index], ClassConstantPool.DOMAIN_NORMALASCIIZ);
         } else if (cp == CP_INT) {
-            return new CPInteger(new Integer(bands.getCpInt()[index]));
+            return bands.cpIntegerValue(new Integer(bands.getCpInt()[index]));
         } else if (cp == CP_FLOAT) {
-            return new CPFloat(new Float(bands.getCpFloat()[index]));
+            return bands.cpFloatValue(new Float(bands.getCpFloat()[index]));
         } else if (cp == CP_LONG) {
-            return new CPLong(new Long(bands.getCpLong()[index]));
+            return bands.cpLongValue(new Long(bands.getCpLong()[index]));
         } else if (cp == CP_DOUBLE) {
-            return new CPDouble(new Double(bands.getCpDouble()[index]));
+            return bands.cpDoubleValue(new Double(bands.getCpDouble()[index]));
         } else if (cp == CP_STRING) {
-            return new CPString(bands.getCpString()[index]);
+            return bands.cpStringValue(bands.getCpString()[index]);
         } else if (cp == CP_CLASS) {
-            return new CPClass(bands.getCpClass()[index]);
+            return bands.cpClassValue(bands.getCpClass()[index]);
         } else if (cp == SIGNATURE) {
         	throw new Error("I don't know what to do with signatures yet");
 //            return null /* new CPSignature(bands.getCpSignature()[index]) */;
@@ -251,11 +245,17 @@
         	throw new Error("I don't know what to do with descriptors yet");
 //            return null /* new CPDescriptor(bands.getCpDescriptor()[index]) */;
         } else if (cp == CP_FIELD) {
-            return new CPFieldRef(bands.getCpFieldClass()[index], bands.getCpFieldDescriptor()[index]);
+            return new CPFieldRef(bands
+                    .cpClassValue(bands.getCpFieldClass()[index]), bands
+                    .cpNameAndTypeValue(bands.getCpFieldDescriptor()[index]));
         } else if (cp == CP_METHOD) {
-            return new CPMethodRef(bands.getCpMethodClass()[index], bands.getCpMethodDescriptor()[index]);
+            return new CPMethodRef(bands
+                    .cpClassValue(bands.getCpMethodClass()[index]), bands
+                    .cpNameAndTypeValue(bands.getCpMethodDescriptor()[index]));
         } else if (cp == CP_IMETHOD) {
-            return new CPInterfaceMethodRef(bands.getCpIMethodClass()[index], bands.getCpIMethodDescriptor()[index]);
+            return new CPInterfaceMethodRef(bands.cpClassValue(bands
+                    .getCpIMethodClass()[index]), bands.cpNameAndTypeValue(bands
+                    .getCpIMethodDescriptor()[index]));
         } else {
             // etc
             throw new Error("Get value incomplete");

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationDefaultAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationDefaultAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationDefaultAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationDefaultAttribute.java Fri Feb 29 06:24:57 2008
@@ -26,8 +26,10 @@
 
     private ElementValue element_value;
 
+    private static final CPUTF8 attributeName = new CPUTF8("AnnotationDefault", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+
     public AnnotationDefaultAttribute(ElementValue element_value) {
-        super("AnnotationDefault");
+        super(attributeName);
         this.element_value = element_value;
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationsAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationsAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationsAttribute.java Fri Feb 29 06:24:57 2008
@@ -154,7 +154,7 @@
         }
     }
 
-    public AnnotationsAttribute(String attributeName) {
+    public AnnotationsAttribute(CPUTF8 attributeName) {
         super(attributeName);
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java Fri Feb 29 06:24:57 2008
@@ -24,8 +24,8 @@
 
     private int attributeNameIndex;
 
-    public Attribute(String attributeName) {
-        this.attributeName = new CPUTF8(attributeName, ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+    public Attribute(CPUTF8 attributeName) {
+        this.attributeName = attributeName;
     }
 
     protected void doWrite(DataOutputStream dos) throws IOException {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/BCIRenumberedAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/BCIRenumberedAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/BCIRenumberedAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/BCIRenumberedAttribute.java Fri Feb 29 06:24:57 2008
@@ -31,7 +31,7 @@
         return true;
     }
 
-    public BCIRenumberedAttribute(String attributeName) {
+    public BCIRenumberedAttribute(CPUTF8 attributeName) {
         super(attributeName);
     }
 

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=632326&r1=632325&r2=632326&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 Fri Feb 29 06:24:57 2008
@@ -26,16 +26,15 @@
 	public String name;
 
 	private CPUTF8 utf8;
-
-	public   CPClass(String name) {
+    
+    public CPClass(CPUTF8 name) {
 		super(ConstantPoolEntry.CP_Class);
-		this.name = name;
+		this.name = name.underlyingString();
 		this.domain = ClassConstantPool.DOMAIN_CLASSREF;
-		this.utf8 = new CPUTF8(name, ClassConstantPool.DOMAIN_NORMALASCIIZ);
+		this.utf8 = name;
 	}
 
-
-	public boolean equals(Object obj) {
+    public boolean equals(Object obj) {
 		if (this == obj)
 			return true;
 		if (obj == null)

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java Fri Feb 29 06:24:57 2008
@@ -20,16 +20,15 @@
 import java.io.IOException;
 
 public class CPDouble extends CPConstantNumber {
-	public CPDouble(java.lang.Double value) {
+
+    public CPDouble(Double value) {
 		super(ConstantPoolEntry.CP_Double,value);
         this.domain = ClassConstantPool.DOMAIN_DOUBLE;
 	}
 
-
-	protected void writeBody(DataOutputStream dos) throws IOException {
+    protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeDouble(getNumber().doubleValue());
 	}
-
 
 	public String toString() {
 		return "Double: " + getValue();

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPField.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPField.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPField.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPField.java Fri Feb 29 06:24:57 2008
@@ -20,8 +20,8 @@
 
 public class CPField extends CPMember {
 
-	public CPField(String descriptor, long flags, List attributes) {
-		super(descriptor, flags, attributes);
+	public CPField(CPUTF8 name, CPUTF8 descriptor, long flags, List attributes) {
+		super(name, descriptor, flags, attributes);
 	}
 
 }

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=632326&r1=632325&r2=632326&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 Fri Feb 29 06:24:57 2008
@@ -19,30 +19,24 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
-
 public class CPFieldRef extends ConstantPoolEntry {
 
 	CPClass className;
 	transient int classNameIndex;
-
-
 	private CPNameAndType nameAndType;
 	transient int nameAndTypeIndex;
-	public CPFieldRef(String className, String descriptor) {
+
+	public CPFieldRef(CPClass className, CPNameAndType descriptor) {
 		super(ConstantPoolEntry.CP_Fieldref);
 		this.domain = ClassConstantPool.DOMAIN_FIELD;
-		this.className = new CPClass(className);
-		this.nameAndType = new CPNameAndType(descriptor);
+		this.className = className;
+		this.nameAndType = descriptor;
 	}
 
-
-
 	protected ClassFileEntry[] getNestedClassFileEntries() {
 		return new ClassFileEntry[] {className, nameAndType};
 	}
 
-
-
 	protected void resolve(ClassConstantPool pool) {
 		super.resolve(pool);
 		nameAndTypeIndex = pool.indexOf(nameAndType);
@@ -54,7 +48,6 @@
 		dos.writeShort(nameAndTypeIndex);
 	}
 
-
 	public String toString() {
 		return "FieldRef: " + className + "#" + nameAndType;
 	}
@@ -71,8 +64,6 @@
 		return result;
 	}
 
-
-
 	public boolean equals(Object obj) {
 		if (this == obj)
 			return true;
@@ -94,4 +85,4 @@
 		return true;
 	}
 
-}
+}
\ No newline at end of file

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java Fri Feb 29 06:24:57 2008
@@ -21,12 +21,12 @@
 
 public class CPFloat extends CPConstantNumber {
 
-    public CPFloat(java.lang.Float value) {
+    public CPFloat(Float value) {
 		super(ConstantPoolEntry.CP_Float,value);
 	      this.domain = ClassConstantPool.DOMAIN_FLOAT;
 	}
 
-	protected void writeBody(DataOutputStream dos) throws IOException {
+    protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeFloat(getNumber().floatValue());
 	}
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java Fri Feb 29 06:24:57 2008
@@ -21,13 +21,12 @@
 
 public class CPInteger extends CPConstantNumber {
 
-	public CPInteger(java.lang.Integer value) {
+    public CPInteger(Integer value) {
 		super(ConstantPoolEntry.CP_Integer,value);
 		this.domain = ClassConstantPool.DOMAIN_INTEGER;
 	}
 
-
-	protected void writeBody(DataOutputStream dos) throws IOException {
+    protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeInt(getNumber().intValue());
 	}
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInterfaceMethodRef.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInterfaceMethodRef.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInterfaceMethodRef.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInterfaceMethodRef.java Fri Feb 29 06:24:57 2008
@@ -18,7 +18,7 @@
 
 public class CPInterfaceMethodRef extends CPRef {
 
-	public CPInterfaceMethodRef(String className, String descriptor) {
+	public CPInterfaceMethodRef(CPClass className, CPNameAndType descriptor) {
 		super(ConstantPoolEntry.CP_InterfaceMethodref, className, descriptor);
 		this.domain = ClassConstantPool.DOMAIN_METHOD;
 	}

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java Fri Feb 29 06:24:57 2008
@@ -21,13 +21,12 @@
 
 public class CPLong extends CPConstantNumber {
 
-	public CPLong(java.lang.Long value) {
+    public CPLong(Long value) {
 		super(ConstantPoolEntry.CP_Long,value);
         this.domain = ClassConstantPool.DOMAIN_LONG;
 	}
 
-
-	protected void writeBody(DataOutputStream dos) throws IOException {
+    protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeLong(getNumber().longValue());
 	}
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java Fri Feb 29 06:24:57 2008
@@ -22,30 +22,22 @@
 import java.util.Iterator;
 import java.util.List;
 
-
 public class CPMember extends ClassFileEntry {
 
 	List attributes;
-
-
 	short flags;
-
 	CPUTF8 name;
 	transient int nameIndex;
-
-
 	private CPUTF8 descriptor;
 	transient int descriptorIndex;
-	public CPMember(String descriptor, long flags, List attributes) {
-		int colon = descriptor.indexOf(':');
-		this.name = new CPUTF8(descriptor.substring(0,colon), ClassConstantPool.DOMAIN_NORMALASCIIZ);
-		this.descriptor = new CPUTF8(descriptor.substring(colon+1), ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
-		this.flags = (short) flags;
+
+	public CPMember(CPUTF8 name, CPUTF8 descriptor, long flags, List attributes) {
+		this.name = name;
+        this.descriptor = descriptor;
+        this.flags = (short) flags;
 		this.attributes = (attributes == null ? new ArrayList() : attributes);
 	}
 
-
-
 	protected ClassFileEntry[] getNestedClassFileEntries() {
 		int attributeCount = attributes.size();
 		ClassFileEntry[] entries = new ClassFileEntry[attributeCount+2];
@@ -57,8 +49,6 @@
 		return entries;
 	}
 
-
-
 	protected void resolve(ClassConstantPool pool) {
 		super.resolve(pool);
 		nameIndex = pool.indexOf(name);
@@ -69,12 +59,10 @@
 		}
 	}
 
-
 	public String toString() {
 		return "Field: " + name + "(" + descriptor + ")";
 	}
 
-
 	public int hashCode() {
 		final int PRIME = 31;
 		int result = 1;
@@ -85,8 +73,6 @@
 		return result;
 	}
 
-
-
 	public boolean equals(Object obj) {
 		if (this == obj)
 			return true;
@@ -115,8 +101,6 @@
 		return true;
 	}
 
-
-
 	protected void doWrite(DataOutputStream dos) throws IOException {
 		dos.writeShort(flags);
 		dos.writeShort(nameIndex);
@@ -127,7 +111,6 @@
 			Attribute attribute = (Attribute) attributes.get(i);
 			attribute.doWrite(dos);
 		}
-
 	}
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.java Fri Feb 29 06:24:57 2008
@@ -20,9 +20,9 @@
 
 public class CPMethod extends CPMember {
 
-	public CPMethod(String descriptor, long flags, List attributes) {
+	public CPMethod(CPUTF8 name, CPUTF8 descriptor, long flags, List attributes) {
 		// TODO Check that we only pass these on, or remap
-		super(descriptor, 0x7FFF & flags, attributes);
+		super(name, descriptor, 0x7FFF & flags, attributes);
 	}
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethodRef.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethodRef.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethodRef.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethodRef.java Fri Feb 29 06:24:57 2008
@@ -18,10 +18,8 @@
 
 public class CPMethodRef extends CPRef {
 
-	public CPMethodRef(String className, String descriptor) {
+	public CPMethodRef(CPClass className, CPNameAndType descriptor) {
 		super(ConstantPoolEntry.CP_Methodref, className, descriptor);
-		this.className = new CPClass(className);
-		this.nameAndType = new CPNameAndType(descriptor);
         this.domain = ClassConstantPool.DOMAIN_METHOD;
 	}
 

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=632326&r1=632325&r2=632326&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 Fri Feb 29 06:24:57 2008
@@ -21,7 +21,6 @@
 
 import org.apache.harmony.pack200.SegmentUtils;
 
-
 public class CPNameAndType extends ConstantPoolEntry {
 
 	CPUTF8 descriptor;
@@ -32,42 +31,16 @@
 
 	transient int nameIndex;
 
-	public CPNameAndType(String descriptor) {
+	public CPNameAndType(CPUTF8 name, CPUTF8 descriptor, int domain) {
 		super(ConstantPoolEntry.CP_NameAndType);
-		int descriptorDomain = ClassConstantPool.DOMAIN_UNDEFINED;
-		int colon = descriptor.indexOf(':');
-		String nameString = descriptor.substring(0,colon);
-		String descriptorString = descriptor.substring(colon+1);
-		// For some reason, descriptors which have just plain
-		// native types are stored in DOMAIN_NORMALASCIIZ rather
-		// than in DOMAIN_SIGNATUREASCIIZ. This might indicate
-		// that DOMAIN_SIGNATUREASCIIZ is poorly named.
-		boolean nativeDescriptor = true;
-		for(int index=0; index < descriptorString.length(); index++) {
-		    char currentChar = descriptorString.charAt(index);
-		    if(Character.isLetter(currentChar)) {
-		        if(currentChar == 'L') {
-		            nativeDescriptor = false;
-		        }
-		        break;
-		    }
-		}
-		this.domain = ClassConstantPool.DOMAIN_NAMEANDTYPE;
-		this.name = new CPUTF8(nameString, ClassConstantPool.DOMAIN_NORMALASCIIZ);
-		if( nativeDescriptor ) {
-		    // Native signatures are stored in DOMAIN_NORMALASCIIZ, not
-		    // DOMAIN_SIGNATUREASCIIZ for some reason.
-		    descriptorDomain = ClassConstantPool.DOMAIN_NORMALASCIIZ;
-		} else {
-		    descriptorDomain = ClassConstantPool.DOMAIN_SIGNATUREASCIIZ;
-		}
-		this.descriptor = new CPUTF8(descriptorString, descriptorDomain);
+		this.name = name;
+		this.descriptor = descriptor;
+        this.domain = domain;
 	}
 
 	protected ClassFileEntry[] getNestedClassFileEntries() {
 		return new ClassFileEntry[] { name, descriptor };
 	}
-
 
 	protected void resolve(ClassConstantPool pool) {
 		super.resolve(pool);

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=632326&r1=632325&r2=632326&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 Fri Feb 29 06:24:57 2008
@@ -27,10 +27,10 @@
 	protected CPNameAndType nameAndType;
 	transient int nameAndTypeIndex;
 
-	public CPRef(byte type, String className, String descriptor) {
+	public CPRef(byte type, CPClass className, CPNameAndType descriptor) {
 		super(type);
-		this.className = new CPClass(className);
-		this.nameAndType = new CPNameAndType(descriptor);
+		this.className = className;
+		this.nameAndType = descriptor;
 	}
 
 	public boolean equals(Object obj) {

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=632326&r1=632325&r2=632326&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 Fri Feb 29 06:24:57 2008
@@ -20,18 +20,17 @@
 import java.io.IOException;
 
 public class CPString extends CPConstant {
-	private transient int nameIndex;
+
+    private transient int nameIndex;
 	private CPUTF8 name;
 
-	public CPString(java.lang.String value) {
-		super(ConstantPoolEntry.CP_String,value);
+    public CPString(CPUTF8 value) {
+		super(ConstantPoolEntry.CP_String, value);
 		this.domain = ClassConstantPool.DOMAIN_STRING;
-		this.name = new CPUTF8((String) getValue(), ClassConstantPool.DOMAIN_NORMALASCIIZ);
-
+		this.name = value;
 	}
 
-
-	protected void writeBody(DataOutputStream dos) throws IOException {
+    protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeShort(nameIndex);
 	}
 
@@ -55,6 +54,6 @@
  	}
 
 	public String comparisonString() {
-	    return (String)getValue();
+	    return ((CPUTF8)getValue()).underlyingString();
 	}
 }

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=632326&r1=632325&r2=632326&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 Fri Feb 29 06:24:57 2008
@@ -21,12 +21,16 @@
 import java.io.UnsupportedEncodingException;
 
 public class CPUTF8 extends ConstantPoolEntry {
-	private String utf8;
 
-	public CPUTF8(String utf8, int domain) {
+    private String utf8;
+
+    public CPUTF8(String utf8, int domain) {
 		super(ConstantPoolEntry.CP_UTF8);
 		this.utf8 = utf8;
 		this.domain = domain;
+        if(domain == ClassConstantPool.DOMAIN_UNDEFINED) {
+            throw new RuntimeException();
+        }
 	}
 
 	public boolean equals(Object obj) {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java Fri Feb 29 06:24:57 2008
@@ -33,10 +33,11 @@
     public List exceptionTable; // of ExceptionTableEntry
     public int maxLocals;
     public int maxStack;
+    private static final CPUTF8 attributeName = new CPUTF8("Code", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
 
     public CodeAttribute(int maxStack, int maxLocals, byte codePacked[],
             Segment segment, OperandManager operandManager, List exceptionTable) {
-        super("Code"); //$NON-NLS-1$
+        super(attributeName); //$NON-NLS-1$
         this.maxLocals = maxLocals;
         this.maxStack = maxStack;
         this.codeLength = 0;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantValueAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantValueAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantValueAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantValueAttribute.java Fri Feb 29 06:24:57 2008
@@ -24,23 +24,16 @@
 
 	private ClassFileEntry entry;
 
-	public ConstantValueAttribute(Object value) {
-		super("ConstantValue"); //$NON-NLS-1$
-		if (value instanceof java.lang.Integer) {
-			this.entry = new CPInteger((Integer) value);
-		} else if (value instanceof java.lang.Long) {
-			this.entry = new CPLong((Long) value);
-		} else if (value instanceof java.lang.Float) {
-			this.entry = new CPFloat((Float) value);
-		} else if (value instanceof java.lang.Double) {
-			this.entry = new CPDouble((Double) value);
-		} else if (value instanceof java.lang.String) {
-			this.entry = new CPString((String) value);
-		} else {
-			throw new Error("Oops, I've not done it again");
-		}
-	}
+    private static final CPUTF8 attributeName = new CPUTF8(
+            "ConstantValue", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
 
+	public ConstantValueAttribute(ClassFileEntry entry) {
+		super(attributeName);
+        if(entry == null) {
+            throw new NullPointerException();
+        }
+		this.entry = entry;
+	}
 
 	public boolean equals(Object obj) {
 		if (this == obj)

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/EnclosingMethodAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/EnclosingMethodAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/EnclosingMethodAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/EnclosingMethodAttribute.java Fri Feb 29 06:24:57 2008
@@ -25,9 +25,11 @@
     private int method_index;
     private CPClass cpClass;
     private CPNameAndType method;
+    private static final CPUTF8 attributeName = new CPUTF8(
+            "EnclosingMethod", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
 
     public EnclosingMethodAttribute(CPClass cpClass, CPNameAndType method) {
-        super("EnclosingMethod");
+        super(attributeName);
         this.cpClass = cpClass;
         this.method = method;
     }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java Fri Feb 29 06:24:57 2008
@@ -21,6 +21,9 @@
 import java.util.Arrays;
 
 public class ExceptionsAttribute extends Attribute {
+    
+    private static final CPUTF8 attributeName = new CPUTF8(
+            "Exceptions", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
 
 	private static int hashCode(Object[] array) {
 		final int prime = 31;
@@ -34,17 +37,15 @@
 		return result;
 	}
 
-
 	private transient int[] exceptionIndexes;
 
 	private CPClass[] exceptions;
 
 	public ExceptionsAttribute(CPClass[] exceptions) {
-		super("Exceptions"); //$NON-NLS-1$
+		super(attributeName);
 		this.exceptions = exceptions;
 	}
 
-
 	public boolean equals(Object obj) {
 		if (this == obj)
 			return true;
@@ -58,7 +59,6 @@
 		return true;
 	}
 
-
 	protected int getLength() {
 		return 2 + 2 * exceptions.length;
 	}
@@ -72,7 +72,6 @@
 		return result;
 	}
 
-
 	public int hashCode() {
 		final int prime = 31;
 		int result = super.hashCode();
@@ -92,7 +91,6 @@
 	public String toString() {
 		return "Exceptions:" + exceptions;
 	}
-
 
 	protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeShort(exceptionIndexes.length);

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/InnerClassesAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/InnerClassesAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/InnerClassesAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/InnerClassesAttribute.java Fri Feb 29 06:24:57 2008
@@ -26,6 +26,10 @@
 
 
 public class InnerClassesAttribute extends Attribute {
+    
+    private static final CPUTF8 attributeName = new CPUTF8(
+            "InnerClasses", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
+
 
     class InnerClassesEntry {
         CPClass inner_class_info;
@@ -93,7 +97,7 @@
     private List nestedClassFileEntries = new ArrayList();
 
     public InnerClassesAttribute(String name) {
-        super("InnerClasses"); //$NON-NLS-1$
+        super(attributeName);
         nestedClassFileEntries.add(getAttributeName());
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LineNumberTableAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LineNumberTableAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LineNumberTableAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LineNumberTableAttribute.java Fri Feb 29 06:24:57 2008
@@ -24,9 +24,12 @@
     private int line_number_table_length;
     private int[] start_pcs;
     private int[] line_numbers;
+    private static final CPUTF8 attributeName = new CPUTF8(
+            "LineNumberTable", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
+
 
     public LineNumberTableAttribute(int line_number_table_length, int[] start_pcs, int[] line_numbers) {
-        super("LineNumberTable");
+        super(attributeName);
         this.line_number_table_length = line_number_table_length;
         this.start_pcs = start_pcs;
         this.line_numbers = line_numbers;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTableAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTableAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTableAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTableAttribute.java Fri Feb 29 06:24:57 2008
@@ -31,11 +31,14 @@
     private int[] indexes;
     private CPUTF8[] names;
     private CPUTF8[] descriptors;
+    private static final CPUTF8 attributeName = new CPUTF8(
+            "LocalVariableTable", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
+
 
     public LocalVariableTableAttribute(int local_variable_table_length,
             int[] start_pcs, int[] lengths, CPUTF8[] names,
             CPUTF8[] descriptors, int[] indexes) {
-        super("LocalVariableTable");
+        super(attributeName);
         this.local_variable_table_length = local_variable_table_length;
         this.start_pcs = start_pcs;
         this.lengths = lengths;
@@ -59,7 +62,6 @@
         }
     }
 
-
     protected ClassFileEntry[] getNestedClassFileEntries() {
         ArrayList nestedEntries = new ArrayList();
         nestedEntries.add(getAttributeName());
@@ -128,7 +130,9 @@
             // Given the index of the start_pc, we can now add
             // the encodedLength to it to get the stop index.
             int stopIndex = indexOfStartPC + encodedLength;
-
+            if(stopIndex < 0) {
+                System.out.println(stopIndex);
+            }
             // Length can either be an index into the byte code offsets, or one beyond the
             // end of the byte code offsets. Need to determine which this is.
             if(stopIndex == byteCodeOffsets.size()) {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTypeTableAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTypeTableAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTypeTableAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTypeTableAttribute.java Fri Feb 29 06:24:57 2008
@@ -30,11 +30,14 @@
     private int[] indexes;
     private CPUTF8[] names;
     private CPUTF8[] signatures;
+    private static final CPUTF8 attributeName = new CPUTF8(
+            "LocalVariableTypeTable", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
+
 
     public LocalVariableTypeTableAttribute(int local_variable_type_table_length,
             int[] start_pcs, int[] lengths, CPUTF8[] names,
             CPUTF8[] signatures, int[] indexes) {
-        super("LocalVariableTypeTable");
+        super(attributeName);
         this.local_variable_type_table_length = local_variable_type_table_length;
         this.start_pcs = start_pcs;
         this.lengths = lengths;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/NewAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/NewAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/NewAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/NewAttribute.java Fri Feb 29 06:24:57 2008
@@ -31,7 +31,7 @@
     private List body = new ArrayList();
     private ClassConstantPool pool;
 
-    public NewAttribute(String attributeName) {
+    public NewAttribute(CPUTF8 attributeName) {
         super(attributeName);
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java Fri Feb 29 06:24:57 2008
@@ -23,11 +23,9 @@
 
     private int num_annotations;
     private Annotation[] annotations;
-    private String name;
 
-    public RuntimeVisibleorInvisibleAnnotationsAttribute(String name, Annotation[] annotations) {
+    public RuntimeVisibleorInvisibleAnnotationsAttribute(CPUTF8 name, Annotation[] annotations) {
         super(name);
-        this.name = name;
         this.num_annotations = annotations.length;
         this.annotations = annotations;
     }
@@ -55,7 +53,7 @@
     }
 
     public String toString() {
-        return name + ": " + num_annotations + " annotations";
+        return attributeName.underlyingString() + ": " + num_annotations + " annotations";
     }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java Fri Feb 29 06:24:57 2008
@@ -23,11 +23,9 @@
 
     private int num_parameters;
     private ParameterAnnotation[] parameter_annotations;
-    private String name;
 
-    public RuntimeVisibleorInvisibleParameterAnnotationsAttribute(String name, ParameterAnnotation[] parameter_annotations) {
+    public RuntimeVisibleorInvisibleParameterAnnotationsAttribute(CPUTF8 name, ParameterAnnotation[] parameter_annotations) {
         super(name);
-        this.name = name;
         this.num_parameters = parameter_annotations.length;
         this.parameter_annotations = parameter_annotations;
     }
@@ -55,7 +53,7 @@
     }
 
     public String toString() {
-        return name + ": " + num_parameters + " parameter annotations";
+        return attributeName.underlyingString() + ": " + num_parameters + " parameter annotations";
     }
 
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SignatureAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SignatureAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SignatureAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SignatureAttribute.java Fri Feb 29 06:24:57 2008
@@ -24,8 +24,10 @@
     private int signature_index;
     private CPUTF8 signature;
 
+    private static final CPUTF8 attributeName = new CPUTF8("Signature", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+
     public SignatureAttribute(CPUTF8 value) {
-        super("Signature");
+        super(attributeName);
         this.signature = value;
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java?rev=632326&r1=632325&r2=632326&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java Fri Feb 29 06:24:57 2008
@@ -19,15 +19,17 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
-
 public class SourceFileAttribute extends Attribute {
-	private CPUTF8 name;
 
+	private CPUTF8 name;
 	private int nameIndex;
+    private static final CPUTF8 attributeName = new CPUTF8(
+            "SourceFile", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
+
 
-	public SourceFileAttribute(String name) {
-		super("SourceFile"); //$NON-NLS-1$
-		this.name = new CPUTF8(name, ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+	public SourceFileAttribute(CPUTF8 name) {
+		super(attributeName);
+		this.name = name;
 	}
 
 	public boolean equals(Object obj) {



Mime
View raw message