harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r650483 [1/2] - in /harmony/enhanced/classlib/trunk/modules/pack200/src: main/java/org/apache/harmony/unpack200/ main/java/org/apache/harmony/unpack200/bytecode/ test/java/org/apache/harmony/unpack200/tests/ test/java/org/apache/harmony/unp...
Date Tue, 22 Apr 2008 12:40:24 GMT
Author: sjanuary
Date: Tue Apr 22 05:39:29 2008
New Revision: 650483

URL: http://svn.apache.org/viewvc?rev=650483&view=rev
Log:
Pack200 - new code for sorting the class constant pool

Added:
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/HelloWorldJavap.out
Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/AttributeLayout.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcTuple.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentConstantPool.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPClass.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPConstant.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPConstantNumber.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPDouble.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPField.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPFieldRef.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPFloat.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPInteger.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPInterfaceMethodRef.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPLong.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPMember.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPMethod.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPMethodRef.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPNameAndType.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPString.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPUTF8.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ClassFile.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ConstantPoolEntry.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/DeprecatedAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LineNumberTableAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/AttributeLayoutTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/BcBandsTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/CPUTF8Test.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ClassBandsTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/CodeAttributeTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ICTupleTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/SegmentTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/bytecode/ClassFileEntryTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/bytecode/ConstantPoolTest.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/AttributeLayout.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/AttributeLayout.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/AttributeLayout.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/AttributeLayout.java Tue Apr 22 05:39:29 2008
@@ -17,6 +17,7 @@
 package org.apache.harmony.unpack200;
 
 import org.apache.harmony.pack200.Codec;
+import org.apache.harmony.unpack200.bytecode.ClassFileEntry;
 
 /**
  * AttributeLayout defines a layout that describes how an attribute will be
@@ -63,7 +64,7 @@
     public static final String[] contextNames = { "Class", "Field", "Method", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
             "Code", }; //$NON-NLS-1$
 
-    private static Object getValue(String layout, long value,
+    private static ClassFileEntry getValue(String layout, long value,
             SegmentConstantPool pool) throws Pack200Exception {
         if (layout.startsWith("R")) { //$NON-NLS-1$
             // references
@@ -187,19 +188,19 @@
         return layout;
     }
 
-    public Object getValue(long value, SegmentConstantPool pool)
+    public ClassFileEntry getValue(long value, SegmentConstantPool pool)
             throws Pack200Exception {
         return getValue(layout, value, pool);
     }
 
-    public Object getValue(long value, String type, SegmentConstantPool pool)
+    public ClassFileEntry getValue(long value, String type, SegmentConstantPool pool)
             throws Pack200Exception {
         // TODO This really needs to be better tested, esp. the different types
         // TODO This should have the ability to deal with RUN stuff too, and
         // unions
         if (layout.startsWith("KQ")) { //$NON-NLS-1$
             if (type.equals("Ljava/lang/String;")) { //$NON-NLS-1$
-                Object value2 = getValue("KS", value, pool); //$NON-NLS-1$
+                ClassFileEntry value2 = getValue("KS", value, pool); //$NON-NLS-1$
                 return value2;
             } else {
                 return getValue("K" + type + layout.substring(2), value, //$NON-NLS-1$

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java Tue Apr 22 05:39:29 2008
@@ -428,42 +428,29 @@
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = "
                                 + index + ", array size = " + reference.length);
-            result[i1] = segment.getCpBands().cpIntegerValue(
-                    new Integer(reference[index]));
+            result[i1] = segment.getCpBands().cpIntegerValue(index);
         }
         return result;
     }
 
     public CPDouble[] parseCPDoubleReferences(String name, InputStream in,
             BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        double[] reference = segment.getCpBands().getCpDouble();
         int[] indices = decodeBandInt(name, in, codec, count);
         CPDouble[] result = new CPDouble[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] = segment.getCpBands().cpDoubleValue(
-                    new Double(reference[index]));
+            result[i1] = segment.getCpBands().cpDoubleValue(index);
         }
         return result;
     }
 
     public CPFloat[] parseCPFloatReferences(String name, InputStream in,
             BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        float[] reference = segment.getCpBands().getCpFloat();
         int[] indices = decodeBandInt(name, in, codec, count);
         CPFloat[] result = new CPFloat[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] = segment.getCpBands().cpFloatValue(
-                    new Float(reference[index]));
+            result[i1] = segment.getCpBands().cpFloatValue(index);
         }
         return result;
     }
@@ -479,24 +466,18 @@
                 throw new Pack200Exception(
                         "Something has gone wrong during parsing references, index = "
                                 + index + ", array size = " + reference.length);
-            result[i1] = segment.getCpBands().cpLongValue(
-                    new Long(reference[index]));
+            result[i1] = segment.getCpBands().cpLongValue(index);
         }
         return result;
     }
 
     public CPUTF8[] parseCPUTF8References(String name, InputStream in,
             BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        String[] reference = segment.getCpBands().getCpUTF8();
         int[] indices = decodeBandInt(name, in, codec, count);
         CPUTF8[] result = new CPUTF8[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] = segment.getCpBands().cpUTF8Value(reference[index],
+            result[i1] = segment.getCpBands().cpUTF8Value(index,
                     ClassConstantPool.DOMAIN_NORMALASCIIZ);
         }
         return result;
@@ -504,7 +485,6 @@
 
     public CPUTF8[][] parseCPUTF8References(String name, InputStream in,
             BHSDCodec codec, int[] counts) throws IOException, Pack200Exception {
-        String[] reference = segment.getCpBands().getCpUTF8();
         CPUTF8[][] result = new CPUTF8[counts.length][];
         int sum = 0;
         for (int i = 0; i < counts.length; i++) {
@@ -515,11 +495,7 @@
         int[] indices = decodeBandInt(name, in, codec, sum);
         for (int i1 = 0; i1 < sum; 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);
-            result1[i1] = segment.getCpBands().cpUTF8Value(reference[index],
+            result1[i1] = segment.getCpBands().cpUTF8Value(index,
                     ClassConstantPool.DOMAIN_NORMALASCIIZ);
         }
         CPUTF8[] refs = result1;
@@ -535,16 +511,11 @@
 
     public CPString[] parseCPStringReferences(String name, InputStream in,
             BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        String[] reference = segment.getCpBands().getCpString();
         int[] indices = decodeBandInt(name, in, codec, count);
         CPString[] result = new CPString[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] = segment.getCpBands().cpStringValue(reference[index]);
+            result[i1] = segment.getCpBands().cpStringValue(index);
         }
         return result;
     }
@@ -553,19 +524,11 @@
             String name, InputStream in, BHSDCodec codec, int count)
             throws IOException, Pack200Exception {
         CpBands cpBands = segment.getCpBands();
-        String[] reference = cpBands.getCpIMethodClass();
-        String[] descriptors = cpBands.getCpIMethodDescriptor();
         int[] indices = decodeBandInt(name, in, codec, count);
         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(cpBands
-                    .cpClassValue(reference[index]), cpBands
-                    .cpNameAndTypeValue(descriptors[index]));
+            result[i1] = cpBands.cpIMethodValue(index);
         }
         return result;
     }
@@ -574,19 +537,11 @@
             InputStream in, BHSDCodec codec, int count) throws IOException,
             Pack200Exception {
         CpBands cpBands = segment.getCpBands();
-        String[] reference = cpBands.getCpMethodClass();
-        String[] descriptors = cpBands.getCpMethodDescriptor();
         int[] indices = decodeBandInt(name, in, codec, count);
         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(
-                    cpBands.cpClassValue(reference[index]), cpBands
-                            .cpNameAndTypeValue(descriptors[index]));
+            result[i1] = cpBands.cpMethodValue(index);
         }
         return result;
     }
@@ -594,18 +549,11 @@
     public CPFieldRef[] parseCPFieldRefReferences(String name, InputStream in,
             BHSDCodec codec, int count) throws IOException, Pack200Exception {
         CpBands cpBands = segment.getCpBands();
-        String[] reference = cpBands.getCpFieldClass();
-        String[] descriptors = cpBands.getCpFieldDescriptor();
         int[] indices = decodeBandInt(name, in, codec, count);
         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(cpBands.cpClassValue(reference[index]),
-                    cpBands.cpNameAndTypeValue(descriptors[index]));
+            result[i1] = cpBands.cpFieldValue(index);
         }
         return result;
     }
@@ -614,49 +562,78 @@
             InputStream in, BHSDCodec codec, int count) throws IOException,
             Pack200Exception {
         CpBands cpBands = segment.getCpBands();
-        String[] reference = cpBands.getCpDescriptor();
         int[] indices = decodeBandInt(name, in, codec, count);
         CPNameAndType[] result = new CPNameAndType[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] = cpBands.cpNameAndTypeValue(reference[index]);
+            result[i1] = cpBands.cpNameAndTypeValue(index);
         }
         return result;
     }
 
     public CPUTF8[] parseCPSignatureReferences(String name, InputStream in,
             BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        String[] reference = segment.getCpBands().getCpSignature();
         int[] indices = decodeBandInt(name, in, codec, count);
         CPUTF8[] result = new CPUTF8[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] = segment.getCpBands().cpUTF8Value(reference[index],
-                    ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
+            result[i1] = segment.getCpBands().cpSignatureValue(index);
+        }
+        return result;
+    }
+
+    protected CPUTF8[][] parseCPSignatureReferences(String name, InputStream in,
+            BHSDCodec codec, int[] counts) throws IOException, Pack200Exception {
+        CPUTF8[][] result = new CPUTF8[counts.length][];
+        int sum = 0;
+        for (int i = 0; i < counts.length; i++) {
+            result[i] = new CPUTF8[counts[i]];
+            sum += counts[i];
+        }
+        CPUTF8[] result1 = new CPUTF8[sum];
+        int[] indices = decodeBandInt(name, in, codec, sum);
+        for (int i1 = 0; i1 < sum; i1++) {
+            int index = indices[i1];
+            result1[i1] = segment.getCpBands().cpSignatureValue(index);
+        }
+        CPUTF8[] refs = result1;
+        int pos = 0;
+        for (int i = 0; i < counts.length; i++) {
+            int num = counts[i];
+            result[i] = new CPUTF8[num];
+            System.arraycopy(refs, pos, result[i], 0, num);
+            pos += num;
         }
         return result;
     }
 
     public CPClass[] parseCPClassReferences(String name, InputStream in,
             BHSDCodec codec, int count) throws IOException, Pack200Exception {
-        String[] reference = segment.getCpBands().getCpClass();
         int[] indices = decodeBandInt(name, in, codec, count);
         CPClass[] result = new CPClass[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] = segment.getCpBands().cpClassValue(reference[index]);
+            result[i1] = segment.getCpBands().cpClassValue(index);
+        }
+        return result;
+    }
+
+    protected String[] getReferences(int[] ints, String[] reference) {
+        String[] result = new String[ints.length];
+        for (int i = 0; i < result.length; i++) {
+            result[i] = reference[ints[i]];
+        }
+        return result;
+    }
+
+    protected String[][] getReferences(int[][] ints, String[] reference) {
+        String[][] result = new String[ints.length][];
+        for (int i = 0; i < result.length; i++) {
+            result[i] = new String[ints[i].length];
+            for (int j = 0; j < result[i].length; j++) {
+                result[i][j] = reference[ints[i][j]];
+                
+            }
         }
         return result;
     }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java Tue Apr 22 05:39:29 2008
@@ -382,7 +382,7 @@
         int[][] handlerEndPCs = segment.getClassBands().getCodeHandlerEndPO();
         int[][] handlerCatchPCs = segment.getClassBands()
                 .getCodeHandlerCatchPO();
-        String[][] handlerClassTypes = segment.getClassBands()
+        int[][] handlerClassTypes = segment.getClassBands()
                 .getCodeHandlerClassRCN();
 
         for (int c = 0; c < classCount; c++) {
@@ -398,16 +398,17 @@
                     // I believe this has to take wide arguments into account
                     maxLocal += SegmentUtils
                             .countInvokeInterfaceArgs(methodDescr[c][m]);
-                    operandManager.setCurrentClass(segment.getClassBands()
-                            .getClassThis()[c]);
-                    operandManager.setSuperClass(segment.getClassBands()
-                            .getClassSuper()[c]);
+                    String[] cpClass = segment.getCpBands().getCpClass();
+                    operandManager.setCurrentClass(cpClass[segment.getClassBands()
+                            .getClassThisInts()[c]]);
+                    operandManager.setSuperClass(cpClass[segment.getClassBands()
+                            .getClassSuperInts()[c]]);
                     List exceptionTable = new ArrayList();
                     if (handlerCount != null) {
                         for (int j = 0; j < handlerCount[i]; j++) {
-                            String handlerClass = handlerClassTypes[i][j];
+                            int handlerClass = handlerClassTypes[i][j] - 1;
                             CPClass cpHandlerClass = null;
-                            if (handlerClass != null) {
+                            if (handlerClass != -1) {
                                 // The handlerClass will be null if the
                                 // catch is a finally (that is, the
                                 // exception table catch_type should be 0

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java Tue Apr 22 05:39:29 2008
@@ -51,14 +51,16 @@
     private long[] classAccessFlags; // Access flags for writing to the class
     // file
 
-    private String[][] classInterfaces;
+    private int[][] classInterfacesInts;
 
     private int[] classMethodCount;
 
-    private String[] classSuper;
+    private int[] classSuperInts;
 
     private String[] classThis;
 
+    private int[] classThisInts;
+
     private ArrayList[] classAttributes;
 
     private int[] classVersionMajor;
@@ -79,6 +81,8 @@
 
     private String[][] fieldDescr;
 
+    private int[][] fieldDescrInts;
+
     private long[][] fieldFlags;
 
     private long[][] fieldAccessFlags;
@@ -86,6 +90,8 @@
     private ArrayList[][] methodAttributes;
 
     private String[][] methodDescr;
+    
+    private int[][] methodDescrInts;
 
     private long[][] methodFlags;
 
@@ -107,7 +113,7 @@
 
     private int[][] codeHandlerCatchPO;
 
-    private String[][] codeHandlerClassRCN;
+    private int[][] codeHandlerClassRCN;
 
     /**
      * @param segment
@@ -124,19 +130,19 @@
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.apache.harmony.unpack200.BandSet#unpack(java.io.InputStream)
      */
     public void unpack(InputStream in) throws IOException, Pack200Exception {
         int classCount = header.getClassCount();
-        classThis = parseReferences("class_this", in, Codec.DELTA5, classCount,
-                cpBands.getCpClass());
-        classSuper = parseReferences("class_super", in, Codec.DELTA5,
-                classCount, cpBands.getCpClass());
+        classThisInts = decodeBandInt("class_this", in, Codec.DELTA5, classCount);
+        classThis = getReferences(classThisInts, cpBands.getCpClass());
+        classSuperInts = decodeBandInt("class_super", in, Codec.DELTA5,
+                classCount);
         int[] classInterfaceLengths = decodeBandInt("class_interface_count",
                 in, Codec.DELTA5, classCount);
-        classInterfaces = parseReferences("class_interface", in, Codec.DELTA5,
-                classInterfaceLengths, cpBands.getCpClass());
+        classInterfacesInts = decodeBandInt("class_interface", in, Codec.DELTA5,
+                classInterfaceLengths);
         classFieldCount = decodeBandInt("class_field_count", in, Codec.DELTA5,
                 classCount);
         classMethodCount = decodeBandInt("class_method_count", in,
@@ -150,8 +156,9 @@
 
     private void parseFieldBands(InputStream in) throws IOException,
             Pack200Exception {
-        fieldDescr = parseReferences("field_descr", in, Codec.DELTA5,
-                classFieldCount, cpBands.getCpDescriptor());
+        fieldDescrInts = decodeBandInt("field_descr", in, Codec.DELTA5,
+                classFieldCount);
+        fieldDescr = getReferences(fieldDescrInts, cpBands.getCpDescriptor());
         parseFieldAttrBands(in);
     }
 
@@ -247,10 +254,10 @@
                     if (type.equals("B") || type.equals("S")
                             || type.equals("C") || type.equals("Z"))
                         type = "I";
-                    Object value = constantValueLayout.getValue(result, type,
-                            cpBands.getConstantPool());
-                    fieldAttributes[i][j].add(new ConstantValueAttribute(
-                            getClassFileEntry(value)));
+                    ClassFileEntry value = constantValueLayout.getValue(result,
+                            type, cpBands.getConstantPool());
+                    fieldAttributes[i][j]
+                            .add(new ConstantValueAttribute(value));
                     constantValueIndex++;
                 }
                 if (signatureLayout.matches(flag)) {
@@ -259,9 +266,8 @@
                     String desc = fieldDescr[i][j];
                     int colon = desc.indexOf(':');
                     String type = desc.substring(colon + 1);
-                    CPUTF8 value = cpBands.cpUTF8Value((String) signatureLayout
-                            .getValue(result, type, cpBands.getConstantPool()),
-                            ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
+                    CPUTF8 value = (CPUTF8) signatureLayout.getValue(result,
+                            type, cpBands.getConstantPool());
                     fieldAttributes[i][j].add(new SignatureAttribute(value));
                     signatureIndex++;
                 }
@@ -278,28 +284,11 @@
         }
     }
 
-    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,
-                classMethodCount, cpBands.getCpDescriptor());
+        methodDescrInts = decodeBandInt("method_descr", in, Codec.MDELTA5,
+                classMethodCount);
+        methodDescr = getReferences(methodDescrInts, cpBands.getCpDescriptor());
         parseMethodAttrBands(in);
     }
 
@@ -334,8 +323,8 @@
                 methodExceptionsLayout);
         int[] numExceptions = decodeBandInt("method_Exceptions_n", in,
                 Codec.UNSIGNED5, count);
-        String[][] methodExceptionsRS = parseReferences("method_Exceptions_RC",
-                in, Codec.UNSIGNED5, numExceptions, cpBands.getCpClass());
+        int[][] methodExceptionsRS = decodeBandInt("method_Exceptions_RC",
+                in, Codec.UNSIGNED5, numExceptions);
 
         // Parse method signature attributes
         AttributeLayout methodSignatureLayout = attrMap.getAttributeLayout(
@@ -395,7 +384,7 @@
                 }
                 if (methodExceptionsLayout.matches(flag)) {
                     int n = numExceptions[methodExceptionsIndex];
-                    String[] exceptions = methodExceptionsRS[methodExceptionsIndex];
+                    int[] exceptions = methodExceptionsRS[methodExceptionsIndex];
                     CPClass[] exceptionClasses = new CPClass[n];
                     for (int k = 0; k < n; k++) {
                         exceptionClasses[k] = cpBands
@@ -415,10 +404,10 @@
                     // be e.g. KIB or KIH
                     if (type.equals("B") || type.equals("H"))
                         type = "I";
-                    Object value = methodSignatureLayout.getValue(result, type,
-                            cpBands.getConstantPool());
-                    methodAttributes[i][j].add(new ConstantValueAttribute(
-                            getClassFileEntry(value)));
+                    ClassFileEntry value = methodSignatureLayout.getValue(
+                            result, type, cpBands.getConstantPool());
+                    methodAttributes[i][j]
+                            .add(new ConstantValueAttribute(value));
                     methodSignatureIndex++;
                 }
                 // Non-predefined attributes
@@ -500,12 +489,12 @@
                 AttributeLayout.CONTEXT_CLASS);
         int enclosingMethodCount = SegmentUtils.countMatches(classFlags,
                 enclosingMethodLayout);
-        String[] enclosingMethodRC = parseReferences(
+        int[] enclosingMethodRC = decodeBandInt(
                 "class_EnclosingMethod_RC", in, Codec.UNSIGNED5,
-                enclosingMethodCount, cpClass);
-        String[] enclosingMethodRDN = parseReferences(
+                enclosingMethodCount);
+        int[] enclosingMethodRDN = decodeBandInt(
                 "class_EnclosingMethod_RDN", in, Codec.UNSIGNED5,
-                enclosingMethodCount, cpBands.getCpDescriptor());
+                enclosingMethodCount);
 
         AttributeLayout signatureLayout = attrMap.getAttributeLayout(
                 AttributeLayout.ATTRIBUTE_SIGNATURE,
@@ -602,7 +591,7 @@
             }
             if (sourceFileLayout.matches(flag)) {
                 long result = classSourceFile[sourceFileIndex];
-                String value = (String) sourceFileLayout.getValue(result,
+                ClassFileEntry value = sourceFileLayout.getValue(result,
                         cpBands.getConstantPool());
                 if (value == null) {
                     // Remove package prefix
@@ -624,11 +613,9 @@
                         className = className.substring(0, index);
                     }
                     // Add .java to the end
-                    value = className + ".java";
+                    value = cpBands.cpUTF8Value(className + ".java", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ, false);
                 }
-                classAttributes[i].add(new SourceFileAttribute(cpBands
-                        .cpUTF8Value(value,
-                                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ)));
+                classAttributes[i].add(new SourceFileAttribute((CPUTF8)value));
                 sourceFileIndex++;
             }
             if (enclosingMethodLayout.matches(flag)) {
@@ -642,10 +629,9 @@
             }
             if (signatureLayout.matches(flag)) {
                 long result = classSignature[signatureIndex];
-                Object value = signatureLayout.getValue(result, cpBands
+                ClassFileEntry value = signatureLayout.getValue(result, cpBands
                         .getConstantPool());
-                classAttributes[i].add(new ConstantValueAttribute(
-                        getClassFileEntry(value)));
+                classAttributes[i].add(new ConstantValueAttribute(value));
                 signatureIndex++;
             }
             if (innerClassLayout.matches(flag)) {
@@ -653,16 +639,20 @@
                 // decided at the end when creating class constant pools
                 icLocal[i] = new IcTuple[classInnerClassesN[innerClassIndex]];
                 for (int j = 0; j < icLocal[i].length; j++) {
-                    String icTupleC = null;
-                    int icTupleF = -1;
+                    int icTupleCIndex = classInnerClassesRC[innerClassIndex][j];
+                    int icTupleC2Index = -1;
+                    int icTupleNIndex = -1;
+
+                    String icTupleC = cpClass[icTupleCIndex];
+                    int icTupleF = classInnerClassesF[innerClassIndex][j];
                     String icTupleC2 = null;
                     String icTupleN = null;
-
-                    icTupleC = cpClass[classInnerClassesRC[innerClassIndex][j]];
-                    icTupleF = classInnerClassesF[innerClassIndex][j];
+                    
                     if (icTupleF != 0) {
-                        icTupleC2 = cpClass[classInnerClassesOuterRCN[innerClassC2NIndex]];
-                        icTupleN = cpUTF8[classInnerClassesNameRUN[innerClassC2NIndex]];
+                        icTupleC2Index = classInnerClassesOuterRCN[innerClassC2NIndex];
+                        icTupleNIndex = classInnerClassesNameRUN[innerClassC2NIndex];
+                        icTupleC2 = cpClass[icTupleC2Index];
+                        icTupleN = cpUTF8[icTupleNIndex];
                         innerClassC2NIndex++;
                     } else {
                         // Get from icBands
@@ -678,7 +668,7 @@
                     }
 
                     IcTuple icTuple = new IcTuple(icTupleC, icTupleF,
-                            icTupleC2, icTupleN);
+                            icTupleC2, icTupleN, icTupleCIndex, icTupleC2Index, icTupleNIndex);
                     icLocal[i][j] = icTuple;
                 }
                 innerClassIndex++;
@@ -758,23 +748,11 @@
                 Codec.BRANCH5, codeHandlerCount);
         codeHandlerCatchPO = decodeBandInt("code_handler_catch_PO", in,
                 Codec.BRANCH5, codeHandlerCount);
-        int[][] codeHandlerClassRCNints = decodeBandInt(
+        codeHandlerClassRCN = decodeBandInt(
                 "code_handler_class_RCN", in, Codec.UNSIGNED5, codeHandlerCount);
         // The codeHandlerClassRCN band contains incremented references to
         // cp_Class so we can't use parseReferences(..) here.
         String[] cpClass = cpBands.getCpClass();
-        codeHandlerClassRCN = new String[codeHandlerClassRCNints.length][];
-        for (int i = 0; i < codeHandlerClassRCNints.length; i++) {
-            codeHandlerClassRCN[i] = new String[codeHandlerClassRCNints[i].length];
-            for (int j = 0; j < codeHandlerClassRCNints[i].length; j++) {
-                int handlerClassReference = codeHandlerClassRCNints[i][j];
-                if (handlerClassReference == 0) {
-                    codeHandlerClassRCN[i][j] = null;
-                } else {
-                    codeHandlerClassRCN[i][j] = cpClass[handlerClassReference - 1];
-                }
-            }
-        }
 
         int codeFlagsCount = segment.getSegmentHeader().getOptions()
                 .hasAllCodeFlags() ? codeCount : codeSpecialHeader;
@@ -839,12 +817,12 @@
         int[][] localVariableTableSpanO = decodeBandInt(
                 "code_LocalVariableTable_span_O", in, Codec.BRANCH5,
                 localVariableTableN);
-        CPUTF8[][] localVariableTableNameRU = stringsToCPUTF8(parseReferences(
+        CPUTF8[][] localVariableTableNameRU = parseCPUTF8References(
                 "code_LocalVariableTable_name_RU", in, Codec.UNSIGNED5,
-                localVariableTableN, cpBands.getCpUTF8()));
-        CPUTF8[][] localVariableTableTypeRS = stringsToCPUTF8(parseReferences(
+                localVariableTableN);
+        CPUTF8[][] localVariableTableTypeRS = parseCPSignatureReferences(
                 "code_LocalVariableTable_type_RS", in, Codec.UNSIGNED5,
-                localVariableTableN, cpBands.getCpSignature()));
+                localVariableTableN);
         int[][] localVariableTableSlot = decodeBandInt(
                 "code_LocalVariableTable_slot", in, Codec.UNSIGNED5,
                 localVariableTableN);
@@ -877,12 +855,12 @@
         int[][] localVariableTypeTableSpanO = decodeBandInt(
                 "code_LocalVariableTypeTable_span_O", in, Codec.BRANCH5,
                 localVariableTypeTableN);
-        CPUTF8[][] localVariableTypeTableNameRU = stringsToCPUTF8(parseReferences(
+        CPUTF8[][] localVariableTypeTableNameRU = parseCPUTF8References(
                 "code_LocalVariableTypeTable_name_RU", in, Codec.UNSIGNED5,
-                localVariableTypeTableN, cpBands.getCpUTF8()));
-        CPUTF8[][] localVariableTypeTableTypeRS = stringsToCPUTF8(parseReferences(
+                localVariableTypeTableN);
+        CPUTF8[][] localVariableTypeTableTypeRS = parseCPSignatureReferences(
                 "code_LocalVariableTypeTable_type_RS", in, Codec.UNSIGNED5,
-                localVariableTypeTableN, cpBands.getCpSignature()));
+                localVariableTypeTableN);
         int[][] localVariableTypeTableSlot = decodeBandInt(
                 "code_LocalVariableTypeTable_slot", in, Codec.UNSIGNED5,
                 localVariableTypeTableN);
@@ -965,27 +943,6 @@
 
     }
 
-    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].length];
-            for (int j = 0; j < strings[i].length; j++) {
-                cpUTF8s[i][j] = cpBands.cpUTF8Value(strings[i][j],
-                        ClassConstantPool.DOMAIN_NORMALASCIIZ);
-            }
-        }
-        return cpUTF8s;
-    }
-
-    private CPUTF8[] stringsToCPUTF8(String[] strings) {
-        CPUTF8[] cpUTF8s = new CPUTF8[strings.length];
-        for (int i = 0; i < strings.length; i++) {
-            cpUTF8s[i] = cpBands.cpUTF8Value(strings[i],
-                    ClassConstantPool.DOMAIN_NORMALASCIIZ);
-        }
-        return cpUTF8s;
-    }
-
     private int parseFieldMetadataBands(InputStream in, int[] fieldAttrCalls)
             throws Pack200Exception, IOException {
         int backwardsCallsUsed = 0;
@@ -1045,9 +1002,9 @@
             if (!rxa.equals("AD")) {
                 mbg[i].anno_N = decodeBandInt(contextName + "_" + rxa
                         + "_anno_N", in, Codec.UNSIGNED5, RxACount[i]);
-                mbg[i].type_RS = stringsToCPUTF8(parseReferences(contextName
+                mbg[i].type_RS = parseCPSignatureReferences(contextName
                         + "_" + rxa + "_type_RS", in, Codec.UNSIGNED5,
-                        mbg[i].anno_N, cpBands.getCpSignature()));
+                        mbg[i].anno_N);
                 mbg[i].pair_N = decodeBandInt(contextName + "_" + rxa
                         + "_pair_N", in, Codec.UNSIGNED5, mbg[i].anno_N);
                 for (int j = 0; j < mbg[i].pair_N.length; j++) {
@@ -1056,9 +1013,9 @@
                     }
                 }
 
-                mbg[i].name_RU = stringsToCPUTF8(parseReferences(contextName
+                mbg[i].name_RU = parseCPUTF8References(contextName
                         + "_" + rxa + "_name_RU", in, Codec.UNSIGNED5,
-                        pairCount, cpBands.getCpUTF8()));
+                        pairCount);
             }
             mbg[i].T = decodeBandInt(contextName + "_" + rxa + "_T", in,
                     Codec.BYTE1, pairCount + backwardsCallCounts[i]);
@@ -1273,20 +1230,20 @@
         return classAccessFlags;
     }
 
-    public String[][] getClassInterfaces() {
-        return classInterfaces;
+    public int[][] getClassInterfacesInts() {
+        return classInterfacesInts;
     }
 
     public int[] getClassMethodCount() {
         return classMethodCount;
     }
 
-    public String[] getClassSuper() {
-        return classSuper;
+    public int[] getClassSuperInts() {
+        return classSuperInts;
     }
 
-    public String[] getClassThis() {
-        return classThis;
+    public int[] getClassThisInts() {
+        return classThisInts;
     }
 
     public int[] getCodeMaxNALocals() {
@@ -1301,8 +1258,12 @@
         return fieldAttributes;
     }
 
-    public String[][] getFieldDescr() {
-        return fieldDescr;
+    public int[][] getFieldDescrInts() {
+        return fieldDescrInts;
+    }
+
+    public int[][] getMethodDescrInts() {
+        return methodDescrInts;
     }
 
     public long[][] getFieldFlags() throws Pack200Exception {
@@ -1409,7 +1370,7 @@
         return codeHandlerCatchPO;
     }
 
-    public String[][] getCodeHandlerClassRCN() {
+    public int[][] getCodeHandlerClassRCN() {
         return codeHandlerClassRCN;
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java Tue Apr 22 05:39:29 2008
@@ -24,9 +24,12 @@
 import org.apache.harmony.pack200.Codec;
 import org.apache.harmony.unpack200.bytecode.CPClass;
 import org.apache.harmony.unpack200.bytecode.CPDouble;
+import org.apache.harmony.unpack200.bytecode.CPFieldRef;
 import org.apache.harmony.unpack200.bytecode.CPFloat;
 import org.apache.harmony.unpack200.bytecode.CPInteger;
+import org.apache.harmony.unpack200.bytecode.CPInterfaceMethodRef;
 import org.apache.harmony.unpack200.bytecode.CPLong;
+import org.apache.harmony.unpack200.bytecode.CPMethodRef;
 import org.apache.harmony.unpack200.bytecode.CPNameAndType;
 import org.apache.harmony.unpack200.bytecode.CPString;
 import org.apache.harmony.unpack200.bytecode.CPUTF8;
@@ -44,19 +47,30 @@
     private final SegmentConstantPool pool = new SegmentConstantPool(this);
 
     private String[] cpClass;
+    private int[] cpClassInts;
+    private int[] cpDescriptorNameInts;
+    private int[] cpDescriptorTypeInts;
     private String[] cpDescriptor;
     private double[] cpDouble;
     private String[] cpFieldClass;
     private String[] cpFieldDescriptor;
+    private int[] cpFieldClassInts;
+    private int[] cpFieldDescriptorInts;
     private float[] cpFloat;
     private String[] cpIMethodClass;
     private String[] cpIMethodDescriptor;
+    private int[] cpIMethodClassInts;
+    private int[] cpIMethodDescriptorInts;
     private int[] cpInt;
     private long[] cpLong;
     private String[] cpMethodClass;
     private String[] cpMethodDescriptor;
+    private int[] cpMethodClassInts;
+    private int[] cpMethodDescriptorInts;
     private String[] cpSignature;
+    private int[] cpSignatureInts;
     private String[] cpString;
+    private int[] cpStringInts;
     private String[] cpUTF8;
 
     private final HashMap[] stringsToCPUTF8 = new HashMap[ClassConstantPool.NUM_DOMAINS];
@@ -68,6 +82,18 @@
     private final HashMap doublesToCPDoubles = new HashMap();
     private final HashMap descriptorsToCPNameAndTypes = new HashMap();
 
+    private int intOffset;
+    private int floatOffset;
+    private int longOffset;
+    private int doubleOffset;
+    private int stringOffset;
+    private int classOffset;
+    private int signatureOffset;
+    private int descrOffset;
+    private int fieldOffset;
+    private int methodOffset;
+    private int imethodOffset;
+
     public CpBands(Segment segment) {
         super(segment);
     }
@@ -85,6 +111,18 @@
         parseCpField(in);
         parseCpMethod(in);
         parseCpIMethod(in);
+
+        intOffset = cpUTF8.length;
+        floatOffset = intOffset + cpInt.length;
+        longOffset = floatOffset + cpFloat.length;
+        doubleOffset = longOffset + cpLong.length;
+        stringOffset = doubleOffset + cpDouble.length;
+        classOffset = stringOffset + cpString.length;
+        signatureOffset = classOffset + cpClass.length;
+        descrOffset = signatureOffset + cpSignature.length;
+        fieldOffset = descrOffset + cpDescriptor.length;
+        methodOffset = fieldOffset + cpFieldClass.length;
+        imethodOffset = methodOffset + cpMethodClass.length;
     }
 
     /**
@@ -102,8 +140,11 @@
     private void parseCpClass(InputStream in) throws IOException,
             Pack200Exception {
         int cpClassCount = header.getCpClassCount();
-        cpClass = parseReferences("cp_Class", in, Codec.UDELTA5, cpClassCount,
-                cpUTF8);
+        cpClassInts = decodeBandInt("cp_Class", in, Codec.UDELTA5, cpClassCount);
+        cpClass = new String[cpClassCount];
+        for (int i = 0; i < cpClassCount; i++) {
+            cpClass[i] = cpUTF8[cpClassInts[i]];
+        }
     }
 
     /**
@@ -125,10 +166,13 @@
     private void parseCpDescriptor(InputStream in) throws IOException,
             Pack200Exception {
         int cpDescriptorCount = header.getCpDescriptorCount();
-        String[] cpDescriptorNames = parseReferences("cp_Descr_name", in,
-                Codec.DELTA5, cpDescriptorCount, cpUTF8);
-        String[] cpDescriptorTypes = parseReferences("cp_Descr_type", in,
-                Codec.UDELTA5, cpDescriptorCount, cpSignature);
+        cpDescriptorNameInts = decodeBandInt("cp_Descr_name", in, Codec.DELTA5,
+                cpDescriptorCount);
+        cpDescriptorTypeInts = decodeBandInt("cp_Descr_type", in,
+                Codec.UDELTA5, cpDescriptorCount);
+        String[] cpDescriptorNames = getReferences(cpDescriptorNameInts, cpUTF8);
+        String[] cpDescriptorTypes = getReferences(cpDescriptorTypeInts,
+                cpSignature);
         cpDescriptor = new String[cpDescriptorCount];
         for (int i = 0; i < cpDescriptorCount; i++) {
             cpDescriptor[i] = cpDescriptorNames[i] + ":" + cpDescriptorTypes[i]; //$NON-NLS-1$
@@ -161,10 +205,16 @@
     private void parseCpField(InputStream in) throws IOException,
             Pack200Exception {
         int cpFieldCount = header.getCpFieldCount();
-        cpFieldClass = parseReferences("cp_Field_class", in, Codec.DELTA5,
-                cpFieldCount, cpClass);
-        cpFieldDescriptor = parseReferences("cp_Field_desc", in, Codec.UDELTA5,
-                cpFieldCount, cpDescriptor);
+        cpFieldClassInts = decodeBandInt("cp_Field_class", in, Codec.DELTA5,
+                cpFieldCount);
+        cpFieldDescriptorInts = decodeBandInt("cp_Field_desc", in, Codec.UDELTA5,
+                cpFieldCount);
+        cpFieldClass = new String[cpFieldCount];
+        cpFieldDescriptor = new String[cpFieldCount];
+        for (int i = 0; i < cpFieldCount; i++) {
+            cpFieldClass[i] = cpClass[cpFieldClassInts[i]];
+            cpFieldDescriptor[i] = cpDescriptor[cpFieldDescriptorInts[i]];
+        }
     }
 
     private void parseCpFloat(InputStream in) throws IOException,
@@ -194,10 +244,16 @@
     private void parseCpIMethod(InputStream in) throws IOException,
             Pack200Exception {
         int cpIMethodCount = header.getCpIMethodCount();
-        cpIMethodClass = parseReferences("cp_Imethod_class", in, Codec.DELTA5,
-                cpIMethodCount, cpClass);
-        cpIMethodDescriptor = parseReferences("cp_Imethod_desc", in,
-                Codec.UDELTA5, cpIMethodCount, cpDescriptor);
+        cpIMethodClassInts = decodeBandInt("cp_Imethod_class", in, Codec.DELTA5,
+                cpIMethodCount);
+        cpIMethodDescriptorInts = decodeBandInt("cp_Imethod_desc", in,
+                Codec.UDELTA5, cpIMethodCount);
+        cpIMethodClass = new String[cpIMethodCount];
+        cpIMethodDescriptor = new String[cpIMethodCount];
+        for (int i = 0; i < cpIMethodCount; i++) {
+            cpIMethodClass[i] = cpClass[cpIMethodClassInts[i]];
+            cpIMethodDescriptor[i] = cpDescriptor[cpIMethodDescriptorInts[i]];
+        }
     }
 
     private void parseCpInt(InputStream in) throws IOException,
@@ -228,10 +284,16 @@
     private void parseCpMethod(InputStream in) throws IOException,
             Pack200Exception {
         int cpMethodCount = header.getCpMethodCount();
-        cpMethodClass = parseReferences("cp_Method_class", in, Codec.DELTA5,
-                cpMethodCount, cpClass);
-        cpMethodDescriptor = parseReferences("cp_Method_desc", in,
-                Codec.UDELTA5, cpMethodCount, cpDescriptor);
+        cpMethodClassInts = decodeBandInt("cp_Method_class", in, Codec.DELTA5,
+                cpMethodCount);
+        cpMethodDescriptorInts = decodeBandInt("cp_Method_desc", in,
+                Codec.UDELTA5, cpMethodCount);
+        cpMethodClass = new String[cpMethodCount];
+        cpMethodDescriptor = new String[cpMethodCount];
+        for (int i = 0; i < cpMethodCount; i++) {
+            cpMethodClass[i] = cpClass[cpMethodClassInts[i]];
+            cpMethodDescriptor[i] = cpDescriptor[cpMethodDescriptorInts[i]];
+        }
     }
 
     /**
@@ -259,8 +321,9 @@
     private void parseCpSignature(InputStream in) throws IOException,
             Pack200Exception {
         int cpSignatureCount = header.getCpSignatureCount();
-        String[] cpSignatureForm = parseReferences("cp_Signature_form", in,
-                Codec.DELTA5, cpSignatureCount, cpUTF8);
+        cpSignatureInts = decodeBandInt("cp_Signature_form", in,
+                Codec.DELTA5, cpSignatureCount);
+        String[] cpSignatureForm = getReferences(cpSignatureInts, cpUTF8);
         cpSignature = new String[cpSignatureCount];
         int lCount = 0;
         for (int i = 0; i < cpSignatureCount; i++) {
@@ -268,6 +331,7 @@
             char[] chars = form.toCharArray();
             for (int j = 0; j < chars.length; j++) {
                 if (chars[j] == 'L') {
+                    cpSignatureInts[i] = -1;
                     lCount++;
                 }
             }
@@ -309,8 +373,12 @@
     private void parseCpString(InputStream in) throws IOException,
             Pack200Exception {
         int cpStringCount = header.getCpStringCount();
-        cpString = parseReferences("cp_String", in, Codec.UDELTA5,
-                cpStringCount, cpUTF8);
+        cpStringInts = decodeBandInt("cp_String", in, Codec.UDELTA5,
+                cpStringCount);
+        cpString = new String[cpStringCount];
+        for (int i = 0; i < cpStringCount; i++) {
+            cpString[i] = cpUTF8[cpStringInts[i]];
+        }
     }
 
     private void parseCpUtf8(InputStream in) throws IOException,
@@ -434,79 +502,226 @@
         return cpUTF8;
     }
 
+    public CPUTF8 cpUTF8Value(int index, int domain) {
+        String string = cpUTF8[index];
+        if (stringsToCPUTF8[domain] == null) {
+            stringsToCPUTF8[domain] = new HashMap();
+        }
+        CPUTF8 cputf8 = (CPUTF8) stringsToCPUTF8[domain].get(string);
+        if (cputf8 == null) {
+            cputf8 = new CPUTF8(string, domain, index);
+            stringsToCPUTF8[domain].put(string, cputf8);
+        }
+        return cputf8;
+    }
+    
     public CPUTF8 cpUTF8Value(String string, int domain) {
+        return cpUTF8Value(string, domain, true);
+    }
+
+    public CPUTF8 cpUTF8Value(String string, int domain, boolean searchForIndex) {
         if (stringsToCPUTF8[domain] == null) {
             stringsToCPUTF8[domain] = new HashMap();
         }
         CPUTF8 cputf8 = (CPUTF8) stringsToCPUTF8[domain].get(string);
         if (cputf8 == null) {
-            cputf8 = new CPUTF8(string, domain);
+            int index = -1;
+            if(searchForIndex) {
+                index = search(cpUTF8, string);
+            }
+            if(index != -1) {
+                return cpUTF8Value(index, domain);
+            }
+            if(searchForIndex) {
+                index = search(cpSignature, string);
+            }
+            if(index != -1) {
+                return cpSignatureValue(index);
+            }
+            cputf8 = new CPUTF8(string, domain, -1);
             stringsToCPUTF8[domain].put(string, cputf8);
         }
         return cputf8;
     }
 
-    public CPString cpStringValue(String string) {
+    public CPString cpStringValue(int index) {
+        String string = cpString[index];
+        int utf8Index = cpStringInts[index];
+        int globalIndex = stringOffset + index;
         CPString cpString = (CPString) stringsToCPStrings.get(string);
         if (cpString == null) {
-            cpString = new CPString(cpUTF8Value(string,
-                    ClassConstantPool.DOMAIN_NORMALASCIIZ));
+            cpString = new CPString(cpUTF8Value(utf8Index,
+                    ClassConstantPool.DOMAIN_NORMALASCIIZ), globalIndex);
             stringsToCPStrings.put(string, cpString);
         }
         return cpString;
     }
 
-    public CPLong cpLongValue(Long l) {
+    public CPLong cpLongValue(int index) {
+        Long l = new Long(cpLong[index]);
         CPLong cpLong = (CPLong) longsToCPLongs.get(l);
         if (cpLong == null) {
-            cpLong = new CPLong(l);
+            cpLong = new CPLong(l, index + longOffset);
             longsToCPLongs.put(l, cpLong);
         }
         return cpLong;
     }
 
-    public CPInteger cpIntegerValue(Integer i) {
+    public CPInteger cpIntegerValue(int index) {
+        Integer i = new Integer(cpInt[index]);
         CPInteger cpInteger = (CPInteger) integersToCPIntegers.get(i);
         if (cpInteger == null) {
-            cpInteger = new CPInteger(i);
+            cpInteger = new CPInteger(i, index + intOffset);
             integersToCPIntegers.put(i, cpInteger);
         }
         return cpInteger;
     }
 
-    public CPFloat cpFloatValue(Float f) {
+    public CPFloat cpFloatValue(int index) {
+        Float f = new Float(cpFloat[index]);
         CPFloat cpFloat = (CPFloat) floatsToCPFloats.get(f);
         if (cpFloat == null) {
-            cpFloat = new CPFloat(f);
+            cpFloat = new CPFloat(f, index + floatOffset);
             floatsToCPFloats.put(f, cpFloat);
         }
         return cpFloat;
     }
 
+    public CPClass cpClassValue(int index) {
+        String string = cpClass[index];
+        int utf8Index = cpClassInts[index];
+        int globalIndex = classOffset + index;
+        CPClass cpString = (CPClass) stringsToCPClass.get(string);
+        if (cpString == null) {
+            cpString = new CPClass(cpUTF8Value(utf8Index,
+                    ClassConstantPool.DOMAIN_NORMALASCIIZ), globalIndex);
+            stringsToCPClass.put(string, cpString);
+        }
+        return cpString;
+    }
+
     public CPClass cpClassValue(String string) {
         CPClass cpString = (CPClass) stringsToCPClass.get(string);
         if (cpString == null) {
+            int index = search(cpClass, string);
+            if(index != -1) {
+                return cpClassValue(index);
+            }
             cpString = new CPClass(cpUTF8Value(string,
-                    ClassConstantPool.DOMAIN_NORMALASCIIZ));
+                    ClassConstantPool.DOMAIN_NORMALASCIIZ, false), -1);
             stringsToCPClass.put(string, cpString);
         }
         return cpString;
     }
 
-    public CPDouble cpDoubleValue(Double dbl) {
+    private int search(String[] array, String string) {
+        for (int i = 0; i < array.length; i++) {
+            if(array[i].equals(string)) {
+                return i;
+            }
+        }
+        return -1;
+    }
+
+    public CPDouble cpDoubleValue(int index) {
+        Double dbl = new Double(cpDouble[index]);
         CPDouble cpDouble = (CPDouble) doublesToCPDoubles.get(dbl);
         if (cpDouble == null) {
-            cpDouble = new CPDouble(dbl);
+            cpDouble = new CPDouble(dbl, index + doubleOffset);
             doublesToCPDoubles.put(dbl, cpDouble);
         }
         return cpDouble;
     }
 
-    public CPNameAndType cpNameAndTypeValue(String descriptor) {
+    public CPNameAndType cpNameAndTypeValue(int index) {
+        String descriptor = cpDescriptor[index];
         CPNameAndType cpNameAndType = (CPNameAndType) descriptorsToCPNameAndTypes
                 .get(descriptor);
         if (cpNameAndType == null) {
             int descriptorDomain = ClassConstantPool.DOMAIN_UNDEFINED;
+            int nameIndex = cpDescriptorNameInts[index];
+            int descriptorIndex = cpDescriptorTypeInts[index];
+            String descriptorString = cpSignature[descriptorIndex];
+                
+            // 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 i = 0; i < descriptorString.length(); i++) {
+                char currentChar = descriptorString.charAt(i);
+                if (Character.isLetter(currentChar)) {
+                    if (currentChar == 'L') {
+                        nativeDescriptor = false;
+                    }
+                    break;
+                }
+            }
+            int domain = ClassConstantPool.DOMAIN_NAMEANDTYPE;
+            CPUTF8 name = cpUTF8Value(nameIndex,
+                    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 = cpSignatureValue(descriptorIndex, descriptorDomain);
+            cpNameAndType = new CPNameAndType(name, descriptorU, domain, index + descrOffset);
+            descriptorsToCPNameAndTypes.put(descriptor, cpNameAndType);
+        }
+        return cpNameAndType;
+    }
+
+    public CPInterfaceMethodRef cpIMethodValue(int index) {
+        return new CPInterfaceMethodRef(cpClassValue(cpIMethodClassInts[index]),
+                cpNameAndTypeValue(cpIMethodDescriptorInts[index]), index
+                        + imethodOffset);
+    }
+
+    public CPMethodRef cpMethodValue(int index) {
+        return new CPMethodRef(cpClassValue(cpMethodClassInts[index]),
+                cpNameAndTypeValue(cpMethodDescriptorInts[index]), index
+                        + methodOffset);
+    }
+
+    public CPFieldRef cpFieldValue(int index) {
+        return new CPFieldRef(cpClassValue(cpFieldClassInts[index]),
+                cpNameAndTypeValue(cpFieldDescriptorInts[index]), index
+                        + fieldOffset);
+    }
+
+    public CPUTF8 cpSignatureValue(int index) {
+        return cpSignatureValue(index, ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
+    }
+
+    public CPUTF8 cpSignatureValue(int index, int domain) {
+        int globalIndex = index + signatureOffset;
+        if(cpSignatureInts[index] != -1) {
+            globalIndex = cpSignatureInts[index];
+        }
+        if (stringsToCPUTF8[domain] == null) {
+            stringsToCPUTF8[domain] = new HashMap();
+        }
+        String string = cpSignature[index];
+        CPUTF8 cpUTF8 = (CPUTF8) stringsToCPUTF8[domain].get(string);
+        if(cpUTF8 == null) {
+            cpUTF8 = new CPUTF8(string, domain, globalIndex);
+            stringsToCPUTF8[domain].put(string, cpUTF8);
+        }
+        return cpUTF8;
+    }
+
+    public CPNameAndType cpNameAndTypeValue(String descriptor) {
+        CPNameAndType cpNameAndType = (CPNameAndType) descriptorsToCPNameAndTypes
+            .get(descriptor);
+        if (cpNameAndType == null) {
+            int index = search(cpDescriptor, descriptor);
+            if(index != -1) {
+                return cpNameAndTypeValue(index);
+            }
+            int descriptorDomain = ClassConstantPool.DOMAIN_UNDEFINED;
             int colon = descriptor.indexOf(':');
             String nameString = descriptor.substring(0, colon);
             String descriptorString = descriptor.substring(colon + 1);
@@ -515,8 +730,8 @@
             // 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);
+            for (int i = 0; i < descriptorString.length(); i++) {
+                char currentChar = descriptorString.charAt(i);
                 if (Character.isLetter(currentChar)) {
                     if (currentChar == 'L') {
                         nativeDescriptor = false;
@@ -526,7 +741,7 @@
             }
             int domain = ClassConstantPool.DOMAIN_NAMEANDTYPE;
             CPUTF8 name = cpUTF8Value(nameString,
-                    ClassConstantPool.DOMAIN_NORMALASCIIZ);
+                    ClassConstantPool.DOMAIN_NORMALASCIIZ, true);
             if (nativeDescriptor) {
                 // Native signatures are stored in DOMAIN_NORMALASCIIZ, not
                 // DOMAIN_SIGNATUREASCIIZ for some reason.
@@ -534,11 +749,19 @@
             } else {
                 descriptorDomain = ClassConstantPool.DOMAIN_SIGNATUREASCIIZ;
             }
-            CPUTF8 descriptorU = cpUTF8Value(descriptorString, descriptorDomain);
-            cpNameAndType = new CPNameAndType(name, descriptorU, domain);
+            CPUTF8 descriptorU = cpUTF8Value(descriptorString, descriptorDomain, true);
+            cpNameAndType = new CPNameAndType(name, descriptorU, domain, index + descrOffset);
             descriptorsToCPNameAndTypes.put(descriptor, cpNameAndType);
         }
         return cpNameAndType;
+    }
+
+    public int[] getCpDescriptorNameInts() {
+        return cpDescriptorNameInts;
+    }
+
+    public int[] getCpDescriptorTypeInts() {
+        return cpDescriptorTypeInts;
     }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcBands.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcBands.java Tue Apr 22 05:39:29 2008
@@ -54,8 +54,9 @@
     public void unpack(InputStream in) throws IOException, Pack200Exception {
         // Read IC bands
         int innerClassCount = header.getInnerClassCount();
-        String[] icThisClass = parseReferences("ic_this_class", in,
-                Codec.UDELTA5, innerClassCount, cpClass);
+        int[] icThisClassInts = decodeBandInt("ic_this_class", in,
+                Codec.UDELTA5, innerClassCount);
+        String[] icThisClass = getReferences(icThisClassInts, cpClass);
         int[] icFlags = decodeBandInt("ic_flags", in, Codec.UNSIGNED5,
                 innerClassCount);
         int outerClasses = SegmentUtils.countBit16(icFlags);
@@ -84,19 +85,21 @@
         icAll = new IcTuple[icThisClass.length];
         int index = 0;
         for (int i = 0; i < icThisClass.length; i++) {
-            String icTupleC = null;
-            int icTupleF = -1;
+            String icTupleC = icThisClass[i];
+            int icTupleF = icFlags[i];
             String icTupleC2 = null;
             String icTupleN = null;
-
-            icTupleC = icThisClass[i];
-            icTupleF = icFlags[i];
+            int cIndex = icThisClassInts[i];
+            int c2Index = -1;
+            int nIndex = -1;
             if ((icFlags[i] & 1 << 16) != 0) {
                 icTupleC2 = icOuterClass[index];
                 icTupleN = icName[index];
+                c2Index = icOuterClassInts[index] - 1;
+                nIndex = icNameInts[index] - 1;
                 index++;
             }
-            icAll[i] = new IcTuple(icTupleC, icTupleF, icTupleC2, icTupleN);
+            icAll[i] = new IcTuple(icTupleC, icTupleF, icTupleC2, icTupleN, cIndex, c2Index, nIndex);
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcTuple.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcTuple.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcTuple.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcTuple.java Tue Apr 22 05:39:29 2008
@@ -28,11 +28,28 @@
  */
 public class IcTuple {
 
-    public IcTuple(String C, int F, String C2, String N) {
+    private final int cIndex;
+    private final int c2Index;
+    private final int nIndex;
+
+    /**
+     * 
+     * @param C
+     * @param F
+     * @param C2
+     * @param N
+     * @param cIndex the index of C in cpClass
+     * @param c2Index the index of C2 in cpClass, or -1 if C2 is null
+     * @param nIndex the index of N in cpUTF8, or -1 if N is null
+     */
+    public IcTuple(String C, int F, String C2, String N, int cIndex, int c2Index, int nIndex) {
         this.C = C;
         this.F = F;
         this.C2 = C2;
         this.N = N;
+        this.cIndex = cIndex;
+        this.c2Index = c2Index;
+        this.nIndex = nIndex;
         if (null == N) {
             predictSimple = true;
         }
@@ -42,8 +59,8 @@
         initializeClassStrings();
     }
 
-    public IcTuple(String C, int F) {
-        this(C, F, null, null);
+    public IcTuple(String C, int F, int cIndex) {
+        this(C, F, null, null, cIndex, -1, -1);
     }
 
     public static final int NESTED_CLASS_FLAG = 0x00010000;
@@ -59,6 +76,8 @@
     private boolean initialized = false;
     private boolean anonymous = false;
     private boolean member = true;
+    private int cachedOuterClassIndex;
+    private int cachedSimpleClassNameIndex;
 
     /**
      * Answer true if the receiver is predicted; answer false if the receiver is
@@ -217,9 +236,11 @@
         // above. Can we eliminate some by reworking the logic?
         if (!predictSimple) {
             cachedSimpleClassName = N;
+            cachedSimpleClassNameIndex = nIndex;
         }
         if (!predictOuter) {
             cachedOuterClassString = C2;
+            cachedOuterClassIndex = c2Index;
         }
         if (isAllDigits(cachedSimpleClassName)) {
             anonymous = true;
@@ -308,5 +329,21 @@
             return cachedOuterClassString;
         }
         return cachedOuterClassString.substring(0, firstDollarPosition);
+    }
+
+    public int thisClassIndex() {
+        if(predicted()) {
+            return cIndex;
+        } else {
+            return -1;
+        }
+    }
+
+    public int outerClassIndex() {
+        return cachedOuterClassIndex;
+    }
+
+    public int simpleClassNameIndex() {
+        return cachedSimpleClassNameIndex;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/MetadataBandGroup.java Tue Apr 22 05:39:29 2008
@@ -42,6 +42,17 @@
 
     private final String type;
     private final CpBands cpBands;
+    
+    private final CPUTF8 rvaUTF8 = new CPUTF8("RuntimeVisibleAnnotations",
+            ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+    private final CPUTF8 riaUTF8 = new CPUTF8("RuntimeInvisibleAnnotations",
+            ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+    private final CPUTF8 rvpaUTF8 = new CPUTF8(
+            "RuntimeVisibleParameterAnnotations",
+            ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+    private final CPUTF8 ripaUTF8 = new CPUTF8(
+            "RuntimeInvisibleParameterAnnotations",
+            ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
 
     public MetadataBandGroup(String type, CpBands cpBands) {
         this.type = type;
@@ -156,11 +167,7 @@
                     namesIterator);
         }
         return new RuntimeVisibleorInvisibleAnnotationsAttribute(type
-                .equals("RVA") ? cpBands.cpUTF8Value(
-                "RuntimeVisibleAnnotations",
-                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ) : cpBands
-                .cpUTF8Value("RuntimeInvisibleAnnotations",
-                        ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ), annotations);
+                .equals("RVA") ? rvaUTF8 : riaUTF8, annotations);
     }
 
     private Attribute getParameterAttribute(int numParameters,
@@ -178,11 +185,7 @@
             parameter_annotations[i] = new ParameterAnnotation(annotations);
         }
         return new RuntimeVisibleorInvisibleParameterAnnotationsAttribute(type
-                .equals("RVA") ? cpBands.cpUTF8Value(
-                "RuntimeVisibleParameterAnnotations",
-                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ) : cpBands
-                .cpUTF8Value("RuntimeInvisibleParameterAnnotations",
-                        ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ),
+                .equals("RVPA") ? rvpaUTF8 : ripaUTF8,
                 parameter_annotations);
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java Tue Apr 22 05:39:29 2008
@@ -105,7 +105,8 @@
         // that instead
         // build constant pool
         ClassConstantPool cp = classFile.pool;
-        String fullName = classBands.getClassThis()[classNum];
+        int fullNameIndexInCpClass = classBands.getClassThisInts()[classNum];
+        String fullName = cpBands.getCpClass()[fullNameIndexInCpClass];
         // SourceFile attribute
         int i = fullName.lastIndexOf("/") + 1; // if lastIndexOf==-1, then
         // -1+1=0, so str.substring(0)
@@ -140,7 +141,7 @@
                 }
                 sourceFileAttribute = new SourceFileAttribute(cpBands
                         .cpUTF8Value(fileName,
-                                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ));
+                                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ, false));
                 classFile.attributes = new Attribute[] { (Attribute) cp
                         .add(sourceFileAttribute) };
             } else {
@@ -176,28 +177,27 @@
         }
 
         // this/superclass
-        ClassFileEntry cfThis = cp.add(cpBands.cpClassValue(fullName));
+        ClassFileEntry cfThis = cp.add(cpBands.cpClassValue(fullNameIndexInCpClass));
         ClassFileEntry cfSuper = cp.add(cpBands.cpClassValue(classBands
-                .getClassSuper()[classNum]));
+                .getClassSuperInts()[classNum]));
         // add interfaces
         ClassFileEntry cfInterfaces[] = new ClassFileEntry[classBands
-                .getClassInterfaces()[classNum].length];
+                .getClassInterfacesInts()[classNum].length];
         for (i = 0; i < cfInterfaces.length; i++) {
             cfInterfaces[i] = cp.add(cpBands.cpClassValue(classBands
-                    .getClassInterfaces()[classNum][i]));
+                    .getClassInterfacesInts()[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++) {
-            String descriptorStr = classBands.getFieldDescr()[classNum][i];
-            int colon = descriptorStr.indexOf(':');
-            CPUTF8 name = cpBands.cpUTF8Value(
-                    descriptorStr.substring(0, colon),
+            int descriptorIndex = classBands.getFieldDescrInts()[classNum][i];
+            int nameIndex = cpBands.getCpDescriptorNameInts()[descriptorIndex];
+            int typeIndex = cpBands.getCpDescriptorTypeInts()[descriptorIndex];
+            CPUTF8 name = cpBands.cpUTF8Value(nameIndex,
                     ClassConstantPool.DOMAIN_NORMALASCIIZ);
-            CPUTF8 descriptor = cpBands.cpUTF8Value(descriptorStr
-                    .substring(colon + 1),
+            CPUTF8 descriptor = cpBands.cpSignatureValue(typeIndex,
                     ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
             cfFields[i] = cp.add(new CPField(name, descriptor, classBands
                     .getFieldFlags()[classNum][i], classBands
@@ -208,19 +208,21 @@
                 .getClassMethodCount()[classNum]];
         // methodDescr and methodFlags used to create this
         for (i = 0; i < cfMethods.length; i++) {
-            String descriptorStr = classBands.getMethodDescr()[classNum][i];
-            int colon = descriptorStr.indexOf(':');
-            CPUTF8 name = cpBands.cpUTF8Value(
-                    descriptorStr.substring(0, colon),
+            int descriptorIndex = classBands.getMethodDescrInts()[classNum][i];
+//            int colon = descriptorStr.indexOf(':');
+            int nameIndex = cpBands.getCpDescriptorNameInts()[descriptorIndex];
+            int typeIndex = cpBands.getCpDescriptorTypeInts()[descriptorIndex];
+            CPUTF8 name = cpBands.cpUTF8Value(nameIndex,
                     ClassConstantPool.DOMAIN_NORMALASCIIZ);
-            CPUTF8 descriptor = cpBands.cpUTF8Value(descriptorStr
-                    .substring(colon + 1),
+            CPUTF8 descriptor = cpBands.cpSignatureValue(typeIndex,
                     ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
             cfMethods[i] = cp.add(new CPMethod(name, descriptor, classBands
                     .getMethodFlags()[classNum][i], classBands
                     .getMethodAttributes()[classNum][i]));
         }
 
+        cp.addNestedEntries();
+
         // add inner class attribute (if required)
         boolean addInnerClassesAttr = false;
         IcTuple[] ic_local = getClassBands().getIcLocal()[classNum];
@@ -233,6 +235,10 @@
         IcTuple[] ic_relevant = getIcBands().getRelevantIcTuples(fullName, cp);
         IcTuple[] ic_stored = computeIcStored(ic_local, ic_relevant);
         for (int index = 0; index < ic_stored.length; index++) {
+            int innerClassIndex = ic_stored[index].thisClassIndex();
+            int outerClassIndex = ic_stored[index].outerClassIndex();
+            int simpleClassNameIndex = ic_stored[index].simpleClassNameIndex();
+            
             String innerClassString = ic_stored[index].thisClassString();
             String outerClassString = ic_stored[index].outerClassString();
             String simpleClassName = ic_stored[index].simpleClassName();
@@ -241,18 +247,22 @@
             CPUTF8 innerName = null;
             CPClass outerClass = null;
 
-            if (ic_stored[index].isAnonymous()) {
-                innerClass = cpBands.cpClassValue(innerClassString);
-            } else {
-                innerClass = cpBands.cpClassValue(innerClassString);
-                innerName = cpBands.cpUTF8Value(simpleClassName,
-                        ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+            innerClass = innerClassIndex != -1 ? cpBands
+                    .cpClassValue(innerClassIndex) : cpBands
+                    .cpClassValue(innerClassString);
+            if (!ic_stored[index].isAnonymous()) {
+                innerName = simpleClassNameIndex != -1 ? cpBands.cpUTF8Value(
+                        simpleClassNameIndex,
+                        ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ) : cpBands
+                        .cpUTF8Value(simpleClassName,
+                                ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
             }
 
             if (ic_stored[index].isMember()) {
-                outerClass = cpBands.cpClassValue(outerClassString);
+                outerClass = outerClassIndex != -1 ? cpBands
+                        .cpClassValue(outerClassIndex) : cpBands
+                        .cpClassValue(outerClassString);
             }
-
             int flags = ic_stored[index].F;
             innerClassesAttribute.addInnerClassesEntry(innerClass, outerClass,
                     innerName, flags);
@@ -442,7 +452,7 @@
             if (isClass) {
                 // pull from headers
                 if (name == null || name.equals(""))
-                    name = classBands.getClassThis()[classNum] + ".class";
+                    name = cpBands.getCpClass()[classBands.getClassThisInts()[classNum]] + ".class";
             }
             JarEntry entry = new JarEntry(name);
             if (deflate)

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentConstantPool.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentConstantPool.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentConstantPool.java Tue Apr 22 05:39:29 2008
@@ -16,10 +16,8 @@
  */
 package org.apache.harmony.unpack200;
 
-import org.apache.harmony.unpack200.bytecode.CPFieldRef;
-import org.apache.harmony.unpack200.bytecode.CPInterfaceMethodRef;
-import org.apache.harmony.unpack200.bytecode.CPMethodRef;
 import org.apache.harmony.unpack200.bytecode.ClassConstantPool;
+import org.apache.harmony.unpack200.bytecode.ClassFileEntry;
 import org.apache.harmony.unpack200.bytecode.ConstantPoolEntry;
 
 /**
@@ -57,30 +55,30 @@
     protected static final String INITSTRING = "<init>";
     protected static final String REGEX_MATCH_INIT = "^" + INITSTRING + ".*";
 
-    public Object getValue(int cp, long value) throws Pack200Exception {
+    public ClassFileEntry getValue(int cp, long value) throws Pack200Exception {
         int index = (int) value;
         if (index == -1) {
             return null;
         } else if (index < 0) {
             throw new Pack200Exception("Cannot have a negative range");
         } else if (cp == UTF_8) {
-            return bands.getCpUTF8()[index];
+            return bands.cpUTF8Value(index, ClassConstantPool.DOMAIN_NORMALASCIIZ);
         } else if (cp == CP_INT) {
-            return new Integer(bands.getCpInt()[index]);
+            return bands.cpIntegerValue(index);
         } else if (cp == CP_FLOAT) {
-            return new Float(bands.getCpFloat()[index]);
+            return bands.cpFloatValue(index);
         } else if (cp == CP_LONG) {
-            return new Long(bands.getCpLong()[index]);
+            return bands.cpLongValue(index);
         } else if (cp == CP_DOUBLE) {
-            return new Double(bands.getCpDouble()[index]);
+            return bands.cpDoubleValue(index);
         } else if (cp == CP_STRING) {
-            return bands.cpStringValue(bands.getCpString()[index]);
+            return bands.cpStringValue(index);
         } else if (cp == CP_CLASS) {
-            return bands.getCpClass()[index];
+            return bands.cpClassValue(index);
         } else if (cp == SIGNATURE) {
-            return bands.getCpSignature()[index];
+            return bands.cpSignatureValue(index);
         } else if (cp == CP_DESCR) {
-            return bands.getCpDescriptor()[index];
+            return bands.cpNameAndTypeValue(index);
         } else {
             throw new Error("Tried to get a value I don't know about: " + cp);
         }
@@ -278,20 +276,20 @@
         } else if (index < 0) {
             throw new Pack200Exception("Cannot have a negative range");
         } else if (cp == UTF_8) {
-            return bands.cpUTF8Value(bands.getCpUTF8()[index],
+            return bands.cpUTF8Value(index,
                     ClassConstantPool.DOMAIN_NORMALASCIIZ);
         } else if (cp == CP_INT) {
-            return bands.cpIntegerValue(new Integer(bands.getCpInt()[index]));
+            return bands.cpIntegerValue(index);
         } else if (cp == CP_FLOAT) {
-            return bands.cpFloatValue(new Float(bands.getCpFloat()[index]));
+            return bands.cpFloatValue(index);
         } else if (cp == CP_LONG) {
-            return bands.cpLongValue(new Long(bands.getCpLong()[index]));
+            return bands.cpLongValue(index);
         } else if (cp == CP_DOUBLE) {
-            return bands.cpDoubleValue(new Double(bands.getCpDouble()[index]));
+            return bands.cpDoubleValue(index);
         } else if (cp == CP_STRING) {
-            return bands.cpStringValue(bands.getCpString()[index]);
+            return bands.cpStringValue(index);
         } else if (cp == CP_CLASS) {
-            return bands.cpClassValue(bands.getCpClass()[index]);
+            return bands.cpClassValue(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]) */;
@@ -300,17 +298,11 @@
             // return null /* new CPDescriptor(bands.getCpDescriptor()[index])
             // */;
         } else if (cp == CP_FIELD) {
-            return new CPFieldRef(bands
-                    .cpClassValue(bands.getCpFieldClass()[index]), bands
-                    .cpNameAndTypeValue(bands.getCpFieldDescriptor()[index]));
+            return bands.cpFieldValue(index);
         } else if (cp == CP_METHOD) {
-            return new CPMethodRef(bands
-                    .cpClassValue(bands.getCpMethodClass()[index]), bands
-                    .cpNameAndTypeValue(bands.getCpMethodDescriptor()[index]));
+            return bands.cpMethodValue(index);
         } else if (cp == CP_IMETHOD) {
-            return new CPInterfaceMethodRef(bands.cpClassValue(bands
-                    .getCpIMethodClass()[index]), bands
-                    .cpNameAndTypeValue(bands.getCpIMethodDescriptor()[index]));
+            return bands.cpIMethodValue(index);
         } else {
             // etc
             throw new Error("Get value incomplete");

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java?rev=650483&r1=650482&r2=650483&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java Tue Apr 22 05:39:29 2008
@@ -51,4 +51,8 @@
         return "AnnotationDefault: " + element_value;
     }
 
+    public boolean equals(Object obj) {
+        return this == obj;
+    }
+
 }



Mime
View raw message