harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r663883 - in /harmony/enhanced/classlib/trunk/modules/pack200/src: main/java/org/apache/harmony/pack200/ test/java/org/apache/harmony/pack200/tests/
Date Fri, 06 Jun 2008 10:25:30 GMT
Author: sjanuary
Date: Fri Jun  6 03:25:30 2008
New Revision: 663883

URL: http://svn.apache.org/viewvc?rev=663883&view=rev
Log:
Pack200 - code to pack constant pool bands

Added:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java   (contents, props changed)
      - copied, changed from r662730, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MethodOrField.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java   (contents, props changed)
      - copied, changed from r662730, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java   (with props)
Removed:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MethodOrField.java
Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
    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/CPNameAndType.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/Codec.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/Segment.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java?rev=663883&r1=663882&r2=663883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java Fri Jun  6 03:25:30 2008
@@ -28,7 +28,7 @@
 public class AttributeDefinitionBands extends BandSet {
 
     private final SegmentHeader segmentHeader;
-    
+
     private final Map namesToAttributes = new HashMap();
 
     public AttributeDefinitionBands(SegmentHeader segmentHeader) {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java?rev=663883&r1=663882&r2=663883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java Fri Jun  6 03:25:30 2008
@@ -283,6 +283,11 @@
                     z += (z - z % 3) / 3;
                 }
             }
+        } else {
+            if (z < 0) {
+                // need to use integer overflow here to represent negatives.
+                z += 4294967296L; // this value is eq
+            }
         }
         List byteList = new ArrayList();
         for (int n = 0; n < b; n++) {

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=663883&r1=663882&r2=663883&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 Jun  6 03:25:30 2008
@@ -32,4 +32,9 @@
         return codec.encode(value);
     }
 
+    public byte[] encodeBandInt(int[] ints, Codec defaultCodec) throws Pack200Exception {
+        // TODO non-default codecs
+        return defaultCodec.encode(ints);
+    }
+
 }

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=663883&r1=663882&r2=663883&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 Jun  6 03:25:30 2008
@@ -24,7 +24,7 @@
 public class BcBands extends BandSet {
 
     public void finaliseBands() {
-        
+
     }
 
     public void pack(OutputStream out) {

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java?rev=663883&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java Fri Jun  6 03:25:30 2008
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.pack200;
+
+
+public class CPClass extends ConstantPoolEntry implements Comparable {
+
+    private final String className;
+    private final CPUTF8 utf8;
+
+    public CPClass(CPUTF8 utf8) {
+        this.utf8 = utf8;
+        this.className = utf8.getUnderlyingString();
+    }
+
+    public int compareTo(Object arg0) {
+        return className.compareTo(((CPClass)arg0).className);
+    }
+
+    public String toString() {
+        return className;
+    }
+
+    public int getIndexInCpUtf8() {
+        return utf8.getIndex();
+    }
+
+}

Copied: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java (from r662730, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MethodOrField.java)
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java?p2=harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java&p1=harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MethodOrField.java&r1=662730&r2=663883&rev=663883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MethodOrField.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java Fri Jun  6 03:25:30 2008
@@ -16,22 +16,22 @@
  */
 package org.apache.harmony.pack200;
 
-public class MethodOrField implements Comparable {
+public class CPMethodOrField implements Comparable {
 
-    private final String className;
+    private final CPClass className;
     private final CPNameAndType nameAndType;
 
-    public MethodOrField(String className, CPNameAndType nameAndType) {
+    public CPMethodOrField(CPClass className, CPNameAndType nameAndType) {
         this.className = className;
         this.nameAndType = nameAndType;
     }
 
     public boolean equals(Object obj) {
-        if (obj == null || !(obj instanceof MethodOrField)) {
+        if (obj == null || !(obj instanceof CPMethodOrField)) {
             return false;
         }
-        return ((MethodOrField) obj).className.equals(className)
-                && ((MethodOrField) obj).nameAndType.equals(nameAndType);
+        return ((CPMethodOrField) obj).className.equals(className)
+                && ((CPMethodOrField) obj).nameAndType.equals(nameAndType);
     }
 
     public int hashCode() {
@@ -43,8 +43,8 @@
     }
 
     public int compareTo(Object obj) {
-        if (obj instanceof MethodOrField) {
-            MethodOrField mof = (MethodOrField) obj;
+        if (obj instanceof CPMethodOrField) {
+            CPMethodOrField mof = (CPMethodOrField) obj;
             int compareName = className.compareTo(mof.className);
             if (compareName == 0) {
                 return nameAndType.compareTo(mof.nameAndType);
@@ -54,4 +54,12 @@
         }
         return 0;
     }
+    
+    public int getClassIndex() {
+        return className.getIndex();
+    }
+    
+    public int getDescIndex() {
+        return nameAndType.getIndex();
+    }
 }
\ No newline at end of file

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java?rev=663883&r1=663882&r2=663883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java Fri Jun  6 03:25:30 2008
@@ -16,12 +16,12 @@
  */
 package org.apache.harmony.pack200;
 
-public class CPNameAndType implements Comparable {
+public class CPNameAndType extends ConstantPoolEntry implements Comparable {
 
-    private final String name;
-    private final String signature;
+    private final CPUTF8 name;
+    private final CPSignature signature;
 
-    public CPNameAndType(String name, String signature) {
+    public CPNameAndType(CPUTF8 name, CPSignature signature) {
         this.name = name;
         this.signature = signature;
     }
@@ -55,4 +55,12 @@
         return 0;
     }
 
+    public int getNameIndex() {
+        return name.getIndex();
+    }
+
+    public int getTypeIndex() {
+        return signature.getIndex();
+    }
+
 }
\ No newline at end of file

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java?rev=663883&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java Fri Jun  6 03:25:30 2008
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.pack200;
+
+import java.util.List;
+
+public class CPSignature extends ConstantPoolEntry implements Comparable {
+    
+    private final CPUTF8 signatureForm;
+    private final List classes;
+    private final String signature;
+
+    public CPSignature(String signature, CPUTF8 signatureForm, List classes) {
+        this.signature = signature;
+        this.signatureForm = signatureForm;
+        this.classes = classes;
+    }
+
+    public int compareTo(Object arg0) {
+        return signature.compareTo(((CPSignature)arg0).signature);
+    }
+
+    public int getIndexInCpUtf8() {
+        return signatureForm.getIndex();
+    }
+    
+    public List getClasses() {
+        return classes;
+    }
+    
+    public String toString() {
+        return signature;
+    }
+
+    public String getUnderlyingString() {
+        return signature;
+    }
+
+    public CPUTF8 getSignatureForm() {
+        return signatureForm;
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java?rev=663883&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java Fri Jun  6 03:25:30 2008
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.pack200;
+
+
+public class CPString extends ConstantPoolEntry implements Comparable {
+
+    private final String string;
+    private final CPUTF8 utf8;
+
+    public CPString(CPUTF8 utf8) {
+        this.utf8 = utf8;
+        this.string = utf8.getUnderlyingString();
+    }
+
+    public int compareTo(Object arg0) {
+        return string.compareTo(((CPString)arg0).string);
+    }
+
+    public String toString() {
+        return string;
+    }
+
+    public int getIndexInCpUtf8() {
+        return utf8.getIndex();
+    }
+
+}

Copied: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java (from r662730, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java)
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java?p2=harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java&p1=harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java&r1=662730&r2=663883&rev=663883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java Fri Jun  6 03:25:30 2008
@@ -17,13 +17,24 @@
 package org.apache.harmony.pack200;
 
 
-public class CPString {
-
+public class CPUTF8 extends ConstantPoolEntry implements Comparable {
 
     private final String string;
 
-    public CPString(String string) {
+    public CPUTF8(String string) {
         this.string = string;
     }
 
+    public int compareTo(Object arg0) {
+        return string.compareTo(((CPUTF8)arg0).string);
+    }
+
+    public String toString() {
+        return string;
+    }
+
+    public String getUnderlyingString() {
+        return string;
+    }
+
 }

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=663883&r1=663882&r2=663883&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 Jun  6 03:25:30 2008
@@ -51,7 +51,7 @@
     private final CPNameAndType[][] method_descr;
 
     public void finaliseBands() {
-        
+
     }
 
     public void pack(OutputStream out) {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java?rev=663883&r1=663882&r2=663883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java Fri Jun  6 03:25:30 2008
@@ -104,7 +104,7 @@
 
     /**
      * Encode a single value into a sequence of bytes.
-     * 
+     *
      * @param value
      *            the value to encode
      * @param last
@@ -118,7 +118,7 @@
     /**
      * Encode a single value into a sequence of bytes. Note that this method can
      * only be used for non-delta encodings.
-     * 
+     *
      * @param value
      *            the value to encode
      * @return the encoded bytes
@@ -277,7 +277,7 @@
 
     /**
      * Encode a sequence of integers into a byte array
-     * 
+     *
      * @param ints
      *            the values to encode
      * @return byte[] encoded bytes
@@ -288,7 +288,7 @@
         int total = 0;
         byte[][] bytes = new byte[ints.length][];
         for (int i = 0; i < ints.length; i++) {
-            bytes[i] = encode(ints[i]);
+            bytes[i] = encode(ints[i], i > 0 ? ints[i-1] : 0);
             total += bytes[i].length;
         }
         byte[] encoded = new byte[total];

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java?rev=663883&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java Fri Jun  6 03:25:30 2008
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.pack200;
+
+
+public abstract class ConstantPoolEntry {
+
+    private int index = -1;
+
+    public int getIndex() {
+        return index;
+    }
+
+    public void setIndex(int index) {
+        this.index = index;
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=663883&r1=663882&r2=663883&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 Jun  6 03:25:30 2008
@@ -16,8 +16,13 @@
  */
 package org.apache.harmony.pack200;
 
+import java.io.IOException;
 import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
@@ -34,11 +39,18 @@
 import org.apache.bcel.classfile.ConstantPool;
 import org.apache.bcel.classfile.ConstantString;
 import org.apache.bcel.classfile.ConstantUtf8;
+import org.apache.bcel.classfile.JavaClass;
 
+/**
+ * Pack200 Constant Pool Bands
+ */
 public class CpBands extends BandSet {
 
     private final SegmentHeader segmentHeader;
 
+    // Don't need to include default attribute names in the constant pool bands
+    private final Set defaultAttributeNames = new HashSet();
+
     private final Set cp_Utf8 = new TreeSet();
     private final Set cp_Int = new TreeSet();
     private final Set cp_Float = new TreeSet();
@@ -52,30 +64,250 @@
     private final Set cp_Method = new TreeSet();
     private final Set cp_Imethod = new TreeSet();
 
-    private ConstantPool currentConstantPool;
-    private final Map stringsToCpClass = new HashMap();
+    private final Map stringsToCpUtf8 = new HashMap();
     private final Map stringsToCpNameAndType = new HashMap();
-    private final Map stringsToCpString = new HashMap();
+    // private final Map stringsToCpString = new HashMap();
+    private final Map stringsToCpClass = new HashMap();
     private final Map stringsToCpSignature = new HashMap();
-    
-    
+
+    private ConstantPool currentConstantPool;
+    private JavaClass currentClass;
+
     public CpBands(SegmentHeader segmentHeader) {
         this.segmentHeader = segmentHeader;
+        defaultAttributeNames.add("AnnotationDefault");
+        defaultAttributeNames.add("RuntimeVisibleAnnotations");
+        defaultAttributeNames.add("RuntimeInvisibleAnnotations");
+        defaultAttributeNames.add("RuntimeVisibleParameterAnnotations");
+        defaultAttributeNames.add("RuntimeInvisibleParameterAnnotations");
+        defaultAttributeNames.add("Code");
+        defaultAttributeNames.add("LineNumberTable");
+        defaultAttributeNames.add("LocalVariableTable");
+        defaultAttributeNames.add("LocalVariableTypeTable");
+        defaultAttributeNames.add("ConstantValue");
+        defaultAttributeNames.add("Deprecated");
+        defaultAttributeNames.add("EnclosingMethod");
+        defaultAttributeNames.add("Exceptions");
+        defaultAttributeNames.add("InnerClasses");
+        defaultAttributeNames.add("Signature");
+        defaultAttributeNames.add("SourceFile");
+    }
+
+    public void pack(OutputStream out) throws IOException, Pack200Exception {
+        writeCpUtf8(out);
+        writeCpInt(out);
+        writeCpFloat(out);
+        writeCpLong(out);
+        writeCpDouble(out);
+        writeCpString(out);
+        writeCpClass(out);
+        writeCpSignature(out);
+        writeCpDescr(out);
+        writeCpMethodOrField(cp_Field, out);
+        writeCpMethodOrField(cp_Method, out);
+        writeCpMethodOrField(cp_Imethod, out);
+    }
+
+    private void writeCpUtf8(OutputStream out) throws IOException,
+            Pack200Exception {
+        int[] cpUtf8Prefix = new int[cp_Utf8.size() - 2];
+        int[] cpUtf8Suffix = new int[cp_Utf8.size() - 1];
+        List chars = new ArrayList();
+        List bigSuffix = new ArrayList();
+        List bigChars = new ArrayList();
+        Object[] cpUtf8Array = cp_Utf8.toArray();
+        String first = ((CPUTF8) cpUtf8Array[1]).getUnderlyingString();
+        cpUtf8Suffix[0] = first.length();
+        addCharacters(chars, first.toCharArray());
+        for (int i = 2; i < cpUtf8Array.length; i++) {
+            char[] previous = ((CPUTF8) cpUtf8Array[i - 1])
+                    .getUnderlyingString().toCharArray();
+            String currentStr = ((CPUTF8) cpUtf8Array[i]).getUnderlyingString();
+            char[] current = currentStr.toCharArray();
+            int prefix = 0;
+            for (int j = 0; j < previous.length; j++) {
+                if (previous[j] == current[j]) {
+                    prefix++;
+                } else {
+                    break;
+                }
+            }
+            cpUtf8Prefix[i - 2] = prefix;
+            currentStr = currentStr.substring(prefix);
+            char[] suffix = currentStr.toCharArray();
+            if (suffix.length > 100) { // big suffix (100 is arbitrary - can we
+                                        // do better?)
+                cpUtf8Suffix[i - 1] = 0;
+                bigSuffix.add(new Integer(suffix.length));
+                addCharacters(bigChars, suffix);
+            } else {
+                cpUtf8Suffix[i - 1] = suffix.length;
+                addCharacters(chars, suffix);
+            }
+        }
+        int[] cpUtf8Chars = new int[chars.size()];
+        int[] cpUtf8BigSuffix = new int[bigSuffix.size()];
+        int[] cpUtf8BigChars = new int[bigChars.size()];
+        for (int i = 0; i < cpUtf8Chars.length; i++) {
+            cpUtf8Chars[i] = ((Character) chars.get(i)).charValue();
+        }
+        for (int i = 0; i < cpUtf8BigSuffix.length; i++) {
+            cpUtf8BigSuffix[i] = ((Integer) bigSuffix.get(i)).intValue();
+        }
+        for (int i = 0; i < cpUtf8BigChars.length; i++) {
+            cpUtf8BigChars[i] = ((Character) bigChars.get(i)).charValue();
+        }
+        out.write(encodeBandInt(cpUtf8Prefix, Codec.DELTA5));
+        out.write(encodeBandInt(cpUtf8Suffix, Codec.UNSIGNED5));
+        out.write(encodeBandInt(cpUtf8Chars, Codec.CHAR3));
+        out.write(encodeBandInt(cpUtf8BigSuffix, Codec.DELTA5));
+        out.write(encodeBandInt(cpUtf8BigChars, Codec.DELTA5));
     }
 
-    public void pack(OutputStream out) {
-        // TODO Auto-generated method stub
+    private void addCharacters(List chars, char[] charArray) {
+        for (int i = 0; i < charArray.length; i++) {
+            chars.add(new Character(charArray[i]));
+        }
+    }
 
+    private void writeCpInt(OutputStream out) throws IOException,
+            Pack200Exception {
+        int[] cpInt = new int[cp_Int.size()];
+        int i = 0;
+        for (Iterator iterator = cp_Int.iterator(); iterator.hasNext();) {
+            Integer integer = (Integer) iterator.next();
+            cpInt[i] = integer.intValue();
+            i++;
+        }
+        out.write(encodeBandInt(cpInt, Codec.UDELTA5));
     }
 
-    public void setCurrentConstantPool(ConstantPool cp) {
-        this.currentConstantPool = cp;
+    private void writeCpFloat(OutputStream out) throws IOException,
+            Pack200Exception {
+        int[] cpFloat = new int[cp_Float.size()];
+        int i = 0;
+        for (Iterator iterator = cp_Float.iterator(); iterator.hasNext();) {
+            Float fl = (Float) iterator.next();
+            cpFloat[i] = Float.floatToIntBits(fl.floatValue());
+            i++;
+        }
+        out.write(encodeBandInt(cpFloat, Codec.UDELTA5));
     }
 
-    public void finaliseBands() {
+    private void writeCpLong(OutputStream out) throws IOException,
+            Pack200Exception {
+        int[] highBits = new int[cp_Long.size()];
+        int[] loBits = new int[cp_Long.size()];
+        int i = 0;
+        for (Iterator iterator = cp_Long.iterator(); iterator.hasNext();) {
+            Long lng = (Long) iterator.next();
+            long l = lng.longValue();
+            highBits[i] = (int) (l >> 32);
+            loBits[i] = (int) l;
+            i++;
+        }
+        out.write(encodeBandInt(highBits, Codec.UDELTA5));
+        out.write(encodeBandInt(loBits, Codec.DELTA5));
+    }
+
+    private void writeCpDouble(OutputStream out) throws IOException,
+            Pack200Exception {
+        int[] highBits = new int[cp_Double.size()];
+        int[] loBits = new int[cp_Double.size()];
+        int i = 0;
+        for (Iterator iterator = cp_Double.iterator(); iterator.hasNext();) {
+            Double dbl = (Double) iterator.next();
+            long l = Double.doubleToLongBits(dbl.doubleValue());
+            highBits[i] = (int) (l >> 32);
+            loBits[i] = (int) l;
+            i++;
+        }
+        out.write(encodeBandInt(highBits, Codec.UDELTA5));
+        out.write(encodeBandInt(loBits, Codec.DELTA5));
+    }
+
+    private void writeCpString(OutputStream out) throws IOException,
+            Pack200Exception {
+        int[] cpString = new int[cp_String.size()];
+        int i = 0;
+        for (Iterator iterator = cp_String.iterator(); iterator.hasNext();) {
+            CPString cpStr = (CPString) iterator.next();
+            cpString[i] = cpStr.getIndexInCpUtf8();
+            i++;
+        }
+        out.write(encodeBandInt(cpString, Codec.UDELTA5));
+    }
+
+    private void writeCpClass(OutputStream out) throws IOException,
+            Pack200Exception {
+        int[] cpClass = new int[cp_Class.size()];
+        int i = 0;
+        for (Iterator iterator = cp_Class.iterator(); iterator.hasNext();) {
+            CPClass cpCl = (CPClass) iterator.next();
+            cpClass[i] = cpCl.getIndexInCpUtf8();
+            i++;
+        }
+        out.write(encodeBandInt(cpClass, Codec.UDELTA5));
+    }
+
+    private void writeCpSignature(OutputStream out) throws IOException,
+            Pack200Exception {
+        int[] cpSignatureForm = new int[cp_Signature.size()];
+        List classes = new ArrayList();
+        int i = 0;
+        for (Iterator iterator = cp_Signature.iterator(); iterator.hasNext();) {
+            CPSignature cpS = (CPSignature) iterator.next();
+            classes.addAll(cpS.getClasses());
+            cpSignatureForm[i] = cpS.getIndexInCpUtf8();
+            i++;
+        }
+        int[] cpSignatureClasses = new int[classes.size()];
+        for (int j = 0; j < cpSignatureClasses.length; j++) {
+            cpSignatureClasses[j] = ((CPClass) classes.get(j)).getIndex();
+        }
+        out.write(encodeBandInt(cpSignatureForm, Codec.DELTA5));
+        out.write(encodeBandInt(cpSignatureClasses, Codec.UDELTA5));
+    }
+
+    private void writeCpDescr(OutputStream out) throws IOException,
+            Pack200Exception {
+        int[] cpDescrName = new int[cp_Descr.size()];
+        int[] cpDescrType = new int[cp_Descr.size()];
+        int i = 0;
+        for (Iterator iterator = cp_Descr.iterator(); iterator.hasNext();) {
+            CPNameAndType nameAndType = (CPNameAndType) iterator.next();
+            cpDescrName[i] = nameAndType.getNameIndex();
+            cpDescrType[i] = nameAndType.getTypeIndex();
+            i++;
+        }
+        out.write(encodeBandInt(cpDescrName, Codec.DELTA5));
+        out.write(encodeBandInt(cpDescrType, Codec.UDELTA5));
+    }
+
+    private void writeCpMethodOrField(Set cp, OutputStream out)
+            throws IOException, Pack200Exception {
+        int[] cp_methodOrField_class = new int[cp.size()];
+        int[] cp_methodOrField_desc = new int[cp.size()];
+        int i = 0;
+        for (Iterator iterator = cp.iterator(); iterator.hasNext();) {
+            CPMethodOrField mOrF = (CPMethodOrField) iterator.next();
+            cp_methodOrField_class[i] = mOrF.getClassIndex();
+            cp_methodOrField_desc[i] = mOrF.getDescIndex();
+            i++;
+        }
+        out.write(encodeBandInt(cp_methodOrField_class, Codec.DELTA5));
+        out.write(encodeBandInt(cp_methodOrField_desc, Codec.UDELTA5));
+    }
+
+    public void setCurrentClass(JavaClass javaClass) {
+        this.currentClass = javaClass;
+        this.currentConstantPool = javaClass.getConstantPool();
+    }
 
-        System.out.println("pool");
-        
+    public void finaliseBands() {
+        addCpUtf8("");
+        removeSignaturesFromCpUTF8();
+        addIndices();
         segmentHeader.setCp_Utf8_count(cp_Utf8.size());
         segmentHeader.setCp_Int_count(cp_Int.size());
         segmentHeader.setCp_Float_count(cp_Float.size());
@@ -90,13 +322,42 @@
         segmentHeader.setCp_Imethod_count(cp_Imethod.size());
     }
 
+    private void removeSignaturesFromCpUTF8() {
+        for (Iterator iterator = cp_Signature.iterator(); iterator.hasNext();) {
+            CPSignature signature = (CPSignature) iterator.next();
+            String sigStr = signature.getUnderlyingString();
+            CPUTF8 utf8 = signature.getSignatureForm();
+            String form = utf8.getUnderlyingString();
+            if (!sigStr.equals(form)) {
+                removeCpUtf8(sigStr);
+            }
+        }
+    }
+
+    private void addIndices() {
+        Set[] sets = new Set[] { cp_Utf8, cp_String, cp_Class, cp_Signature,
+                cp_Descr };
+        for (int i = 0; i < sets.length; i++) {
+            int j = 0;
+            for (Iterator iterator = sets[i].iterator(); iterator.hasNext();) {
+                ConstantPoolEntry entry = (ConstantPoolEntry) iterator.next();
+                entry.setIndex(j);
+                j++;
+            }
+        }
+    }
+
+    private void removeCpUtf8(String string) {
+        CPUTF8 utf8 = (CPUTF8) stringsToCpUtf8.get(string);
+        if (utf8 != null) {
+            stringsToCpUtf8.remove(string);
+            cp_Utf8.remove(utf8);
+        }
+    }
+
     public void addConstantClass(ConstantClass constant) {
         String className = constant.getBytes(currentConstantPool);
-        if(stringsToCpClass.get(className) == null) {
-            CPClass cpClass = new CPClass(className);
-            cp_Class.add(cpClass);
-            stringsToCpClass.put(className, cpClass);
-        }
+        addCPClass(className);
     }
 
     public void addConstantDouble(ConstantDouble constant) {
@@ -107,10 +368,10 @@
         ConstantFieldref cf = constant;
         ConstantNameAndType cnat = (ConstantNameAndType) currentConstantPool
                 .getConstant(cf.getNameAndTypeIndex());
-        CPNameAndType nat = new CPNameAndType(cnat.getName(currentConstantPool),
+        CPNameAndType nat = getCPNameAndType(cnat.getName(currentConstantPool),
                 cnat.getSignature(currentConstantPool));
-        cp_Signature.add(cnat.getSignature(currentConstantPool));
-        cp_Field.add(new MethodOrField(cf.getClass(currentConstantPool), nat));
+        cp_Field.add(new CPMethodOrField(getCPClass(cf
+                .getClass(currentConstantPool)), nat));
     }
 
     public void addConstantFloat(ConstantFloat constant) {
@@ -126,9 +387,10 @@
         ConstantNameAndType cnat = (ConstantNameAndType) currentConstantPool
                 .getConstant(constant.getNameAndTypeIndex());
         String signature = cnat.getSignature(currentConstantPool);
-        cp_Signature.add(signature);
-        CPNameAndType nat = new CPNameAndType(cnat.getName(currentConstantPool), signature);
-        cp_Imethod.add(new MethodOrField(constant.getClass(currentConstantPool), nat));
+        CPNameAndType nat = getCPNameAndType(cnat.getName(currentConstantPool),
+                signature);
+        cp_Imethod.add(new CPMethodOrField(getCPClass(constant
+                .getClass(currentConstantPool)), nat));
     }
 
     public void addConstantLong(ConstantLong constant) {
@@ -139,69 +401,145 @@
         ConstantNameAndType cnat = (ConstantNameAndType) currentConstantPool
                 .getConstant(constant.getNameAndTypeIndex());
         String signature = cnat.getSignature(currentConstantPool);
-        cp_Signature.add(signature);
-        CPNameAndType nat = new CPNameAndType(cnat.getName(currentConstantPool),
+        CPNameAndType nat = getCPNameAndType(cnat.getName(currentConstantPool),
                 signature);
-        cp_Method.add(new MethodOrField(constant.getClass(currentConstantPool),
-                nat));
+        cp_Method.add(new CPMethodOrField(getCPClass(constant
+                .getClass(currentConstantPool)), nat));
     }
 
     public void addConstantNameAndType(ConstantNameAndType constant) {
         String name = constant.getName(currentConstantPool);
         String signature = constant.getSignature(currentConstantPool);
-        String descr = name + ":" + signature;
-        if(stringsToCpNameAndType.get(descr) != null) {
-            cp_Signature.add(signature);
-            CPNameAndType nameAndType = new CPNameAndType(name,
-                    signature);
-            stringsToCpNameAndType.put(descr, nameAndType);
-            cp_Descr.add(nameAndType);
-        }
+        addCPNameAndType(name, signature);
     }
 
     public void addConstantString(ConstantString constant) {
         String string = constant.getBytes(currentConstantPool);
-        CPString cpString = (CPString) stringsToCpString.get(string);
-        if(cpString == null) {
-            cpString = new CPString(string);
-            cp_String.add(cpString);
-            stringsToCpString.put(string, cpString);
-        }
+        // CPString cpString = (CPString) stringsToCpString.get(string);
+        // if(cpString == null) {
+        CPString cpString = new CPString(getCpUtf8(string));
+        cp_String.add(cpString);
+        // stringsToCpString.put(string, cpString);
+        // }
     }
 
     public void addConstantUtf8(ConstantUtf8 constant) {
-        cp_Utf8.add((constant).getBytes());
+        String utf8 = constant.getBytes();
+        if (!defaultAttributeNames.contains(utf8)) {
+            if (utf8.endsWith(".java")) {
+                if (!isPredictableSourceFileName(utf8)) {
+                    addCpUtf8(utf8);
+                }
+            } else {
+                addCpUtf8(utf8);
+            }
+        }
+    }
+
+    private void addCpUtf8(String utf8) {
+        getCpUtf8(utf8);
+    }
+
+    private CPUTF8 getCpUtf8(String utf8) {
+        CPUTF8 cpUtf8 = (CPUTF8) stringsToCpUtf8.get(utf8);
+        if (cpUtf8 == null) {
+            cpUtf8 = new CPUTF8(utf8);
+            cp_Utf8.add(cpUtf8);
+            stringsToCpUtf8.put(utf8, cpUtf8);
+        }
+        return cpUtf8;
     }
 
-    public void addDesc(String name, String signature) {
-        cp_Signature.add(signature);
-        cp_Descr.add(new CPNameAndType(name, signature));
+    public void addCPNameAndType(String name, String signature) {
+        getCPNameAndType(name, signature);
     }
 
     public void addSignature(String signature) {
-        cp_Signature.add(signature);
+        getSignature(signature);
+    }
+
+    private CPSignature getSignature(String signature) {
+        CPSignature cpS = (CPSignature) stringsToCpSignature.get(signature);
+        if (cpS == null) {
+            List cpClasses = new ArrayList();
+            CPUTF8 signatureUTF8;
+            if (signature.length() > 1 && signature.indexOf("L") != -1) {
+                List classes = new ArrayList();
+                char[] chars = signature.toCharArray();
+                StringBuffer signatureString = new StringBuffer();
+                for (int i = 0; i < chars.length; i++) {
+                    signatureString.append(chars[i]);
+                    if (chars[i] == 'L') {
+                        StringBuffer className = new StringBuffer();
+                        for (int j = i + 1; j < chars.length; j++) {
+                            char c = chars[j];
+                            if (Character.isLetter(c) || Character.isDigit(c)
+                                    || c == '/') {
+                                className.append(c);
+                            } else {
+                                classes.add(className.toString());
+                                i = j - 1;
+                                break;
+                            }
+                        }
+                    }
+                }
+                removeCpUtf8(signature);
+                for (Iterator iterator2 = classes.iterator(); iterator2
+                        .hasNext();) {
+                    cpClasses.add(getCPClass((String) iterator2.next()));
+                }
+
+                signatureUTF8 = getCpUtf8(signatureString.toString());
+            } else {
+                signatureUTF8 = getCpUtf8(signature);
+            }
+            cpS = new CPSignature(signature, signatureUTF8, cpClasses);
+            cp_Signature.add(cpS);
+            stringsToCpSignature.put(signature, cpS);
+        }
+        return cpS;
     }
 
     public CPClass getCPClass(String className) {
+        className = className.replace('.', '/');
         CPClass cpClass = (CPClass) stringsToCpClass.get(className);
-        if(cpClass == null) {
-            cpClass = new CPClass(className);
+        if (cpClass == null) {
+            CPUTF8 cpUtf8 = getCpUtf8(className);
+            cpClass = new CPClass(cpUtf8);
             cp_Class.add(cpClass);
             stringsToCpClass.put(className, cpClass);
         }
         return cpClass;
     }
 
+    public void addCPClass(String className) {
+        getCPClass(className);
+    }
+
     public CPNameAndType getCPNameAndType(String name, String signature) {
         String descr = name + ":" + signature;
-        CPNameAndType nameAndType = (CPNameAndType) stringsToCpNameAndType.get(descr);
+        CPNameAndType nameAndType = (CPNameAndType) stringsToCpNameAndType
+                .get(descr);
         if (nameAndType == null) {
-            cp_Signature.add(signature);
-            nameAndType = new CPNameAndType(name, signature);
+            nameAndType = new CPNameAndType(getCpUtf8(name),
+                    getSignature(signature));
             stringsToCpNameAndType.put(descr, nameAndType);
             cp_Descr.add(nameAndType);
         }
         return nameAndType;
     }
 
+    public boolean isPredictableSourceFileName(String name) {
+        String className = currentClass.getClassName();
+        if (className.indexOf(".") != -1) {
+            className = className.substring(className.lastIndexOf(".") + 1);
+        }
+        if (className.indexOf("$") != -1) {
+            className = className.substring(0, className.indexOf("$"));
+        }
+        className += ".java";
+        return className.equals(name);
+    }
+
 }

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=663883&r1=663882&r2=663883&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 Jun  6 03:25:30 2008
@@ -5,9 +5,9 @@
  * licenses this file to You under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -77,7 +77,7 @@
         fileBands = new FileBands(segmentHeader, files);
 
         processClasses(classes);
-        
+
         cpBands.finaliseBands();
         attributeDefinitionBands.finaliseBands();
         icBands.finaliseBands();
@@ -147,7 +147,6 @@
     }
 
     public void visitConstantPool(ConstantPool obj) {
-        cpBands.setCurrentConstantPool(obj);
     }
 
     public void visitConstantString(ConstantString obj) {
@@ -171,7 +170,7 @@
     }
 
     public void visitField(Field obj) {
-        cpBands.addDesc(obj.getName(), obj.getSignature());
+        cpBands.addCPNameAndType(obj.getName(), obj.getSignature());
     }
 
     public void visitInnerClass(InnerClass obj) {
@@ -184,6 +183,7 @@
     }
 
     public void visitJavaClass(JavaClass obj) {
+        cpBands.setCurrentClass(obj);
         classBands.addClass(obj);
         segmentHeader.addMinorVersion(obj.getMinor());
         segmentHeader.addMajorVersion(obj.getMajor());
@@ -209,7 +209,7 @@
     }
 
     public void visitMethod(Method obj) {
-        cpBands.addDesc(obj.getName(), obj.getSignature());
+        cpBands.addCPNameAndType(obj.getName(), obj.getSignature());
     }
 
     public void visitSignature(Signature obj) {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java?rev=663883&r1=663882&r2=663883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java Fri Jun  6 03:25:30 2008
@@ -306,16 +306,16 @@
     public void addMajorVersion(int major) {
         majverCounter.add(major);
     }
-    
+
     /**
      * Counter for major/minor class file numbers so we can work out the default
      */
     private class Counter {
-        
+
         private final int[] objs = new int[8];
         private final int[] counts = new int[8];
         private int length;
-        
+
         public void add(int obj) {
             boolean found = false;
             for (int i = 0; i < length; i++) {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java?rev=663883&r1=663882&r2=663883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java Fri Jun  6 03:25:30 2008
@@ -23,6 +23,7 @@
 import junit.framework.TestCase;
 
 import org.apache.harmony.pack200.BHSDCodec;
+import org.apache.harmony.pack200.Codec;
 import org.apache.harmony.pack200.CodecEncoding;
 import org.apache.harmony.pack200.Pack200Exception;
 
@@ -64,4 +65,14 @@
         }
     }
 
+    public void testDeltaEncodings() throws IOException, Pack200Exception {
+        Codec c = Codec.UDELTA5;
+        int[] sequence = new int[] {0, 2, 4, 2, 2, 4};
+        byte[] encoded = c.encode(sequence);
+        int[] decoded = c.decodeInts(6, new ByteArrayInputStream(encoded));
+        for (int i = 0; i < decoded.length; i++) {
+            assertEquals(sequence[i], decoded[i]);
+        }
+    }
+
 }
\ No newline at end of file



Mime
View raw message