harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r587111 [1/2] - in /harmony/enhanced/classlib/trunk/modules/pack200/src: main/java/org/apache/harmony/pack200/ main/java/org/apache/harmony/pack200/bytecode/ test/java/org/apache/harmony/pack200/tests/ test/resources/org/apache/harmony/pack...
Date Mon, 22 Oct 2007 14:31:35 GMT
Author: hindessm
Date: Mon Oct 22 07:31:32 2007
New Revision: 587111

URL: http://svn.apache.org/viewvc?rev=587111&view=rev
Log:
Applying patches from "[#HARMONY-4994] [classlib] [pack200] Pack200 -
Ongoing progress in band parsing and some tests".

Added:
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AbstractBandsTestCase.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ClassBandsTest.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/pack200-e1.pack.gz   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/sql-e1.pack.gz   (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayoutMap.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/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/CodecEncoding.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/FileBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.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/SegmentOptions.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFile.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutMapTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BcBandsTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecEncodingTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/HelloWorld.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentOptionsTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java Mon Oct 22 07:31:32 2007
@@ -248,5 +248,18 @@
     public String getName() {
         return name;
     }
+    
+    public int numBackwardsCallables() {
+        int num = 0;
+        String[] split = layout.split("\\(");
+        if(split.length > 0) {
+            for (int i = 1; i < split.length; i++) {
+                if(split[i].startsWith("-") || split[i].startsWith("0")) {
+                    num++;
+                }
+            }
+        }
+        return num;
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayoutMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayoutMap.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayoutMap.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayoutMap.java Mon Oct 22 07:31:32 2007
@@ -16,10 +16,6 @@
  */
 package org.apache.harmony.pack200;
 
-// NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-// NOTE: Do not extract strings as messages; this code is still a
-// work-in-progress
-// NOTE: Also, don't get rid of 'else' statements for the hell of it ...
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -223,6 +219,12 @@
         }
         return null;
 	}
+    
+    public AttributeLayout getAttributeLayout(int index, int context)
+            throws Pack200Exception {
+        Map map = layouts[context];
+        return (AttributeLayout) map.get(new Integer(index));
+    }
     
     /**
      * The map should not contain the same layout and name combination more than

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=587111&r1=587110&r2=587111&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 Mon Oct 22 07:31:32 2007
@@ -15,19 +15,17 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * TODO Comment -- quite a lot can be nicked from Codec, since this was created
  * from it
- * 
- * @author Alex Blewitt
- * 
+ *  
  */
 public final class BHSDCodec extends Codec {
 
@@ -155,13 +153,23 @@
 			x = in.read();
 			if (x == -1)
 				throw new EOFException("End of stream reached whilst decoding");
-			z += x * Math.pow(h, n); 
+			z += x * Math.pow(h, n);
             n++;
 		} while (n < b & isHigh(x));
-        long u = z;
-        long twoPowS = (long)Math.pow(2, s);
-        double twoPowSMinusOne = twoPowS-1;
+
+// TODO: Decide whether to use this algorithm instead (neater, possibly quicker but less easy to understand)
+//        if (isSigned()) {
+//            int u = ((1 << s) - 1);
+//            if ((z & u) == u) {
+//                z = z >>> s ^ -1L;
+//            } else {
+//                z = z - (z >>> s);
+//            }
+//        }
         if(isSigned()) {
+            long u = z;
+            long twoPowS = (long)Math.pow(2, s);
+            double twoPowSMinusOne = twoPowS-1;
             if(u % twoPowS < twoPowSMinusOne) {
                 if(cardinality < Math.pow(2, 32)) {
                     z = (long) (u - (Math.floor(u/ twoPowS)));                    
@@ -172,8 +180,8 @@
                 z = (long) (-Math.floor(u/ twoPowS) - 1);
             }
         }
-		if (isDelta())
-			z += last;
+	    if (isDelta())
+	        z += last;
 		return z;
 	}
 
@@ -196,6 +204,50 @@
 	public boolean encodes(long value) {
 		return (value >= smallest() && value <= largest());
 	}
+    
+    public byte[] encode(long value, long last) throws Pack200Exception {
+        if (isDelta()) {
+            value -= last;
+        }
+        if (!encodes(value)) {
+            throw new Pack200Exception("The codec " + toString()
+                    + " does not encode the value " + value);
+        }
+        long z = value;
+        if (isSigned()) {
+            if (z < 0) {
+                z = (-z << s) - 1;
+            } else {
+                if (s == 1) {
+                    z = z << s;
+                } else {
+                    z += (z - z % 3) / 3;
+                }
+            }
+        }
+        List byteList = new ArrayList();
+        for (int n = 0; n < b; n++) {
+            long byteN;
+            if (z < l) {
+                byteN = z;
+            } else {
+                byteN = z % h;
+                while (byteN < l)
+                    byteN += h;
+            }
+            byteList.add(new Byte((byte) byteN));
+            if (byteN < l) {
+                break;
+            }
+            z -= byteN;
+            z /= h;
+        }
+        byte[] bytes = new byte[byteList.size()];
+        for (int i = 0; i < bytes.length; i++) {
+            bytes[i] = ((Byte) byteList.get(i)).byteValue();
+        }
+        return bytes;
+    }
 
 	/**
 	 * Returns true if this codec is a delta codec
@@ -220,19 +272,15 @@
 	 */
 	public long largest() {
 		long result;
-		if (isDelta()) {
-			result = Long.MAX_VALUE;
+		// TODO This can probably be optimized into a better mathematical statement
+		if (s == 0) {
+			result = cardinality() - 1;
+		} else if (s == 1) {
+			result = cardinality() / 2 - 1;
+		} else if (s == 2) {
+			result = (3L * cardinality()) / 4 - 1;
 		} else {
-			// TODO This can probably be optimized into a better mathematical statement
-			if (s == 0) {
-				result = cardinality() - 1;
-			} else if (s == 1) {
-				result = cardinality() / 2 - 1;
-			} else if (s == 2) {
-				result = (3L * cardinality()) / 4 - 1;
-			} else {
-				throw new Error("Unknown s value");
-			}
+			throw new Error("Unknown s value");
 		}
 		return Math.min((s == 0 ? ((long) Integer.MAX_VALUE) << 1
 				: Integer.MAX_VALUE) - 1, result);
@@ -244,14 +292,10 @@
 	 */
 	public long smallest() {
 		long result;
-		if (isDelta()) {
-			result = Integer.MIN_VALUE;
+		if (isSigned()) {
+			result = -cardinality() / (1 << s);
 		} else {
-			if (isSigned()) {
-				result = -cardinality() / (1 << s);
-			} else {
-				result = 0;
-			}
+			result = 0;
 		}
 		return Math.max(Integer.MIN_VALUE, result);
 	}

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=587111&r1=587110&r2=587111&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 Mon Oct 22 07:31:32 2007
@@ -16,6 +16,7 @@
  */
 package org.apache.harmony.pack200;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -36,7 +37,7 @@
     }
 
     /**
-     * Decode a band and return an array of <code>int[]</code> values
+     * Decode a band and return an array of <code>int</code> values
      * 
      * @param name
      *            the name of the band (primarily for logging/debugging
@@ -47,7 +48,7 @@
      *            the default codec for this band
      * @param count
      *            the number of elements to read
-     * @return an array of decoded <code>int[]</code> values
+     * @return an array of decoded <code>int</code> values
      * @throws IOException
      *             if there is a problem reading from the underlying input
      *             stream
@@ -60,17 +61,34 @@
             Pack200Exception {
         // TODO Might be able to improve this directly.
         int[] result = new int[count];
-
-        // TODO We need to muck around in the scenario where the first value
-        // read indicates
-        // an uber-codec
         long[] longResult = decodeBandLong(name, in, defaultCodec, count);
         for (int i = 0; i < count; i++) {
             result[i] = (int) longResult[i];
         }
         return result;
     }
-    
+
+    /**
+     * Decode a band and return an array of <code>int[]</code> values
+     * 
+     * @param name
+     *            the name of the band (primarily for logging/debugging
+     *            purposes)
+     * @param in
+     *            the InputStream to decode from
+     * @param defaultCodec
+     *            the default codec for this band
+     * @param counts
+     *            the numbers of elements to read for each int array within the
+     *            array to be returned
+     * @return an array of decoded <code>int[]</code> values
+     * @throws IOException
+     *             if there is a problem reading from the underlying input
+     *             stream
+     * @throws Pack200Exception
+     *             if there is a problem decoding the value or that the value is
+     *             invalid
+     */
     public int[][] decodeBandInt(String name, InputStream in, BHSDCodec defaultCodec, int[] counts) throws IOException, Pack200Exception {
         int[][] result = new int[counts.length][];
         int totalCount = 0;
@@ -90,7 +108,7 @@
     }
     
     /**
-     * Decode a band and return an array of <code>long[]</code> values
+     * Decode a band and return an array of <code>long</code> values
      * 
      * @param name
      *            the name of the band (primarily for logging/debugging
@@ -101,7 +119,7 @@
      *            the default codec for this band
      * @param count
      *            the number of elements to read
-     * @return an array of decoded <code>long[]</code> values
+     * @return an array of decoded <code>long</code> values
      * @throws IOException
      *             if there is a problem reading from the underlying input
      *             stream
@@ -135,24 +153,39 @@
             return codec.decode(count - 1, in, first);
         }
     }
+
+    public byte[] encodeBandLong(long[] data, BHSDCodec codec) throws IOException, Pack200Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        for (int i = 0; i < data.length; i++) {
+            baos.write(codec.encode(data[i], i == 0 ? 0 : data[i-1]));
+        }
+        return baos.toByteArray();
+    }
     
     public long[] parseFlags(String name, InputStream in, int count,
-            BHSDCodec codec, boolean hasHi) throws IOException, Pack200Exception {
-        return parseFlags(name, in, 1, new int[] { count }, (hasHi ? codec
-                : null), codec)[0];
+            BHSDCodec codec, boolean hasHi) throws IOException,
+            Pack200Exception {
+        return parseFlags(name, in, new int[] { count },
+                (hasHi ? codec : null), codec)[0];
+    }
+
+    public long[][] parseFlags(String name, InputStream in, int counts[],
+            BHSDCodec codec, boolean hasHi) throws IOException,
+            Pack200Exception {
+        return parseFlags(name, in, counts, (hasHi ? codec : null), codec);
     }
 
-    public long[][] parseFlags(String name, InputStream in, int count,
-            int counts[], BHSDCodec codec, boolean hasHi) throws IOException,
+    public long[] parseFlags(String name, InputStream in, int count,
+            BHSDCodec hiCodec, BHSDCodec loCodec) throws IOException,
             Pack200Exception {
-        return parseFlags(name, in, count, counts, (hasHi ? codec : null),
-                codec);
+        return parseFlags(name, in, new int[] { count }, hiCodec, loCodec)[0];
     }
 
-    public long[][] parseFlags(String name, InputStream in, int count,
-            int counts[], BHSDCodec hiCodec, BHSDCodec loCodec) throws IOException,
+    public long[][] parseFlags(String name, InputStream in, int counts[],
+            BHSDCodec hiCodec, BHSDCodec loCodec) throws IOException,
             Pack200Exception {
         // TODO Move away from decoding into a parseBand type structure
+        int count = counts.length;
         if (count == 0) {
             return new long[][] { {} };
         }
@@ -182,7 +215,7 @@
      * [0..reference.length-1].
      * 
      * @param name
-     *            TODO
+     *            the band name
      * @param in
      *            the input stream to read from
      * @param codec
@@ -247,12 +280,12 @@
         }
         // TODO Merge the decode and parsing of a multiple structure into one
         String[] result1 = new String[sum];
-        int[] decode = decodeBandInt(name, in, codec, sum);
+        int[] indices = decodeBandInt(name, in, codec, sum);
         for (int i1 = 0; i1 < sum; i1++) {
-            int index = decode[i1];
+            int index = indices[i1];
             if (index < 0 || index >= reference.length)
                 throw new Pack200Exception(
-                        "Something has gone wrong during parsing references");
+                        "Something has gone wrong during parsing references, index = " + index + ", array size = " + reference.length);
             result1[i1] = reference[index];
         }
         String[] refs = result1;

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=587111&r1=587110&r2=587111&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 Mon Oct 22 07:31:32 2007
@@ -21,7 +21,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.Arrays;
 
 import org.apache.harmony.pack200.bytecode.ByteCode;
 import org.apache.harmony.pack200.bytecode.CodeAttribute;
@@ -31,8 +30,11 @@
  */
 public class BcBands extends BandSet {
     
-    // the bytecodes for each method in each class as they come (i.e. in their packed format)
+    // The bytecodes for each method in each class as they come (i.e. in their packed format)
     private byte[][][] methodByteCodePacked;
+    
+    // The bands
+    // TODO:  Haven't resolved references yet.  Do we want to?
     private int[] bcCaseCount;
     private int[][] bcCaseValue;
     private int[] bcByte;
@@ -137,7 +139,6 @@
                    for (int i = 0; i < codes.length; i++) {
                        codes[i] = methodByteCodePacked[c][m][i] & 0xff;
                    }
-                   debug(Arrays.toString(codes));
                    for (int i = 0; i < methodByteCodePacked[c][m].length; i++) {
                        int codePacked = 0xff & methodByteCodePacked[c][m][i];
                        // TODO a lot of this needs to be encapsulated in the
@@ -467,6 +468,5 @@
 
     public int[][] getBcEscByte() {
         return bcEscByte;
-    }    
-
+    }
 }

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=587111&r1=587110&r2=587111&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 Mon Oct 22 07:31:32 2007
@@ -20,8 +20,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
 
 import org.apache.harmony.pack200.bytecode.CPClass;
 import org.apache.harmony.pack200.bytecode.ConstantValueAttribute;
@@ -32,8 +30,6 @@
  */
 public class ClassBands extends BandSet {
 
-    private int classAttrCount;
-
     private int[] classFieldCount;
 
     private long[] classFlags;
@@ -45,6 +41,8 @@
     private String[] classSuper;
 
     private String[] classThis;
+    
+    private ArrayList[] classAttributes;
 
     private int[] codeHandlerCount;
 
@@ -67,23 +65,30 @@
     private String[][] methodDescr;
 
     private ExceptionsAttribute[][] methodExceptions;
-
+    
     private long[][] methodFlags;
 
     private AttributeLayoutMap attrMap;
 
     private CpBands cpBands;
 
-    private int codeAttrCount;
+    private SegmentOptions options;
 
+    private int classCount;
+
+    private int[] methodAttrCalls;
+    
     /**
-     * @param header
+     * @param segment
      */
     public ClassBands(Segment segment) {
         super(segment);
         this.attrMap = segment.getAttrDefinitionBands()
                 .getAttributeDefinitionMap();
         this.cpBands = segment.getCpBands();
+        this.classCount = header.getClassCount();
+        this.options = header.getOptions();
+        
     }
 
     /*
@@ -107,13 +112,10 @@
                 cpBands.getCpClass());
         classSuper = parseReferences("class_super", in, Codec.DELTA5,
                 classCount, cpBands.getCpClass());
-        classInterfaces = new String[classCount][];
         int[] classInterfaceLengths = decodeBandInt("class_interface_count",
                 in, Codec.DELTA5, classCount);
-        // for (int i = 0; i < classCount; i++) {
         classInterfaces = parseReferences("class_interface", in, Codec.DELTA5,
                 classInterfaceLengths, cpBands.getCpClass());
-        // }
         classFieldCount = decodeBandInt("class_field_count", in, Codec.DELTA5,
                 classCount);
         classMethodCount = decodeBandInt("class_method_count", in,
@@ -127,106 +129,122 @@
 
     private void parseFieldBands(InputStream in) throws IOException,
             Pack200Exception {
-        int classCount = header.getClassCount();
-        SegmentOptions options = header.getOptions();
         fieldDescr = parseReferences("field_descr", in, Codec.DELTA5,
                 classFieldCount, cpBands.getCpDescriptor());
-        fieldFlags = parseFlags("field_flags", in, classCount, classFieldCount,
+        fieldFlags = parseFlags("field_flags", in, classFieldCount,
                 Codec.UNSIGNED5, options.hasFieldFlagsHi());
-        for (int i = 0; i < classCount; i++) {
+        for (int i = 0; i < fieldFlags.length; i++) {
             for (int j = 0; j < fieldFlags[i].length; j++) {
                 long flag = fieldFlags[i][j];
                 if ((flag & (1 << 16)) != 0)
                     fieldAttrCount++;
             }
         }
-        if (fieldAttrCount > 0)
-            throw new Error(
-                    "There are attribute flags, and I don't know what to do with them");
-        debug("unimplemented field_attr_indexes");
-        debug("unimplemented field_attr_calls");
+        int[] fieldAttrCounts = decodeBandInt("field_attr_count", in, Codec.UNSIGNED5, fieldAttrCount);
+        int[][] fieldAttrIndexes = decodeBandInt("field_attr_indexes", in, Codec.UNSIGNED5, fieldAttrCounts);
+        int callCount = 0;
+        for (int i = 0; i < fieldAttrIndexes.length; i++) {
+            for (int j = 0; j < fieldAttrIndexes[i].length; j++) {
+                int index = fieldAttrIndexes[i][j];
+                AttributeLayout layout = attrMap.getAttributeLayout(index, AttributeLayout.CONTEXT_FIELD);
+                callCount += layout.numBackwardsCallables();
+            }
+        }
+        int[] fieldAttrCalls = decodeBandInt("field_attr_calls", in, Codec.UNSIGNED5, callCount);
         AttributeLayout layout = attrMap.getAttributeLayout("ConstantValue",
                 AttributeLayout.CONTEXT_FIELD);
-        Codec codec = layout.getCodec();
-        fieldAttributes = new ArrayList[classCount][];
-        for (int i = 0; i < classCount; i++) {
-            fieldAttributes[i] = new ArrayList[fieldFlags[i].length];
-            for (int j = 0; j < fieldFlags[i].length; j++) {
-                fieldAttributes[i][j] = new ArrayList();
-                long flag = fieldFlags[i][j];
-                if (layout.matches(flag)) {
-                    // we've got a value to read
-                    long result = codec.decode(in);
-                    String desc = fieldDescr[i][j];
-                    int colon = desc.indexOf(':');
-                    // String name = desc.substring(0, colon);
-                    String type = desc.substring(colon + 1);
-                    // TODO Got to get better at this ... in any case, it should
-                    // be e.g. KIB or KIH
-                    if (type.equals("B") || type.equals("H"))
-                        type = "I";
-                    Object value = layout.getValue(result, type, cpBands
-                            .getConstantPool());
-                    fieldAttributes[i][j]
-                            .add(new ConstantValueAttribute(value));
-                    debug("Processed value " + value + " for ConstantValue");
+        int constantCount = SegmentUtils.countMatches(fieldFlags, layout);        
+        if(constantCount > 0) {
+            int[] field_constantValue_KQ = decodeBandInt("field_ConstantValue_KQ", in, Codec.UNSIGNED5, constantCount);
+            int index = 0;
+            fieldAttributes = new ArrayList[classCount][];
+            for (int i = 0; i < classCount; i++) {
+                fieldAttributes[i] = new ArrayList[fieldFlags[i].length];
+                for (int j = 0; j < fieldFlags[i].length; j++) {
+                    fieldAttributes[i][j] = new ArrayList();
+                    long flag = fieldFlags[i][j];
+                    if (layout.matches(flag)) {
+                        // we've got a value to read
+                        long result = field_constantValue_KQ[index];
+                        String desc = fieldDescr[i][j];
+                        int colon = desc.indexOf(':');
+                        // String name = desc.substring(0, colon);
+                        String type = desc.substring(colon + 1);
+                        // TODO Got to get better at this ... in any case, it should
+                        // be e.g. KIB or KIH
+                        if (type.equals("B") || type.equals("H"))
+                            type = "I";
+                        Object value = layout.getValue(result, type, cpBands
+                                    .getConstantPool());
+                        fieldAttributes[i][j]
+                                .add(new ConstantValueAttribute(value));
+                        debug("Processed value " + value + " for ConstantValue");
+                        index++;
+                    }
                 }
             }
         }
 
         layout = attrMap.getAttributeLayout(AttributeLayout.ATTRIBUTE_SIGNATURE,
                 AttributeLayout.CONTEXT_FIELD);
-        codec = layout.getCodec();
-//        fieldAttributes = new ArrayList[classCount][];
-        for (int i = 0; i < classCount; i++) {
-//            fieldAttributes[i] = new ArrayList[fieldFlags[i].length];
-            for (int j = 0; j < fieldFlags[i].length; j++) {
-//                fieldAttributes[i][j] = new ArrayList();
-                long flag = fieldFlags[i][j];
-                if (layout.matches(flag)) {
-                    // we've got a value to read
-                    long result = codec.decode(in);
-//                    String desc = fieldDescr[i][j];
-//                    int colon = desc.indexOf(':');
-//                    // String name = desc.substring(0, colon);
-//                    String type = desc.substring(colon + 1);
-//                    // TODO Got to get better at this ... in any case, it should
-//                    // be e.g. KIB or KIH
-//                    if (type.equals("B") || type.equals("H"))
-//                        type = "I";
-//                    Object value = layout.getValue(result, type, cpBands
-//                            .getConstantPool());
-//                    fieldAttributes[i][j]
-//                            .add(new ConstantValueAttribute(value));
-                    debug("Found a signature attribute: " + result);
+        int signatureCount = SegmentUtils.countMatches(fieldFlags, layout);
+        if (signatureCount > 0) {
+            int[] fieldSignatureRS = decodeBandInt("field_Signature_RS", in, Codec.UNSIGNED5, signatureCount);
+            int index = 0;
+            fieldAttributes = new ArrayList[classCount][];
+            for (int i = 0; i < classCount; i++) {
+                fieldAttributes[i] = new ArrayList[fieldFlags[i].length];
+                for (int j = 0; j < fieldFlags[i].length; j++) {
+                    fieldAttributes[i][j] = new ArrayList();
+                    long flag = fieldFlags[i][j];
+                    if (layout.matches(flag)) {
+                        // we've got a signature attribute
+                        long result = fieldSignatureRS[index];
+                        String desc = fieldDescr[i][j];
+                        int colon = desc.indexOf(':');
+                        // String name = desc.substring(0, colon);
+                        String type = desc.substring(colon + 1);
+                        // TODO Got to get better at this ... in any case, it should
+                        // be e.g. KIB or KIH
+                        if (type.equals("B") || type.equals("H"))
+                            type = "I";
+                        Object value = layout.getValue(result, type, cpBands
+                                .getConstantPool());
+                        fieldAttributes[i][j]
+                                .add(new ConstantValueAttribute(value));
+                        index++;
+                        debug("Found a signature attribute: " + result);
+                    }
                 }
             }
         }
-//        debug("unimplemented field_Signature_RS");
         parseFieldMetadataBands();
     }
 
     private void parseMethodBands(InputStream in) throws IOException,
             Pack200Exception {
-        int classCount = header.getClassCount();
-        SegmentOptions options = header.getOptions();
         methodDescr = parseReferences("method_descr", in, Codec.MDELTA5,
                 classMethodCount, cpBands.getCpDescriptor());
-        methodFlags = parseFlags("method_flags", in, classCount,
-                classMethodCount, Codec.UNSIGNED5, options.hasMethodFlagsHi());
+        methodFlags = parseFlags("method_flags", in, classMethodCount,
+                Codec.UNSIGNED5, options.hasMethodFlagsHi());
         for (int i = 0; i < classCount; i++) {
             for (int j = 0; j < methodFlags[i].length; j++) {
                 long flag = methodFlags[i][j];
                 if ((flag & (1 << 16)) != 0)
                     methodAttrCount++;
             }
+        }        
+        int[] methodAttrCounts = decodeBandInt("method_attr_count", in, Codec.UNSIGNED5, methodAttrCount);
+        int[][] methodAttrIndexes = decodeBandInt("method_attr_indexes", in, Codec.UNSIGNED5, methodAttrCounts);
+        int callCount = 0;
+        for (int i = 0; i < methodAttrIndexes.length; i++) {
+            for (int j = 0; j < methodAttrIndexes[i].length; j++) {
+                int index = methodAttrIndexes[i][j];
+                AttributeLayout layout = attrMap.getAttributeLayout(index, AttributeLayout.CONTEXT_METHOD);
+                callCount += layout.numBackwardsCallables();
+            }
         }
-        if (methodAttrCount > 0)
-            throw new Error(
-                    "There are method attribute flags, and I don't know what to do with them");
-        debug("unimplemented method_attr_count");
-        debug("unimplemented method_attr_indexes");
-        debug("unimplemented method_attr_calls");
+        methodAttrCalls = decodeBandInt("code_attr_calls", in, Codec.UNSIGNED5, callCount);
         // assign empty method attributes
         methodAttributes = new ArrayList[classCount][];
         for (int i = 0; i < classCount; i++) {
@@ -236,10 +254,41 @@
             }
         }
         parseAttributeMethodExceptions(in);
-        parseAttributeMethodSignature(in);
+        parseAttributeMethodSigntaure(in);
         parseMethodMetadataBands();
     }
 
+    private void parseAttributeMethodSigntaure(InputStream in) throws IOException, Pack200Exception {
+        AttributeLayout layout = attrMap.getAttributeLayout(AttributeLayout.ATTRIBUTE_SIGNATURE,
+                AttributeLayout.CONTEXT_METHOD);
+        int count = SegmentUtils.countMatches(methodFlags, layout);
+        long[] methodSignatureRS = decodeBandLong("method_signature_RS", in, Codec.UNSIGNED5, count);
+        int index = 0;
+        for (int i = 0; i < methodAttributes.length; i++) {
+            for (int j = 0; j < methodAttributes[i].length; j++) {
+                long flag = methodFlags[i][j];
+                if (layout.matches(flag)) {
+                    // we've got a signature attribute
+                    long result = methodSignatureRS[index];
+                    String desc = methodDescr[i][j];
+                    int colon = desc.indexOf(':');
+                    // String name = desc.substring(0, colon);
+                    String type = desc.substring(colon + 1);
+                    // TODO Got to get better at this ... in any case, it should
+                    // be e.g. KIB or KIH
+                    if (type.equals("B") || type.equals("H"))
+                        type = "I";
+                    Object value = layout.getValue(result, type, cpBands
+                            .getConstantPool());
+                    methodAttributes[i][j]
+                            .add(new ConstantValueAttribute(value));
+                    index++;
+                    debug("Found a signature attribute: " + result);
+                }
+            }        
+        }
+    }
+
     /**
      * @param in
      * @throws Pack200Exception
@@ -247,123 +296,159 @@
      */
     private void parseAttributeMethodExceptions(InputStream in)
             throws Pack200Exception, IOException {
-        // TODO Should refactor this stuff into the layout somehow
-        int classCount = header.getClassCount();
         AttributeLayout layout = attrMap.getAttributeLayout("Exceptions",
                 AttributeLayout.CONTEXT_METHOD);
-        Codec codec = layout.getCodec();
         methodExceptions = new ExceptionsAttribute[classCount][];
-        int[][] numExceptions = new int[classCount][];
-        for (int i = 0; i < classCount; i++) {
-            numExceptions[i] = new int[methodFlags[i].length];
-            for (int j = 0; j < methodFlags[i].length; j++) {
-                long flag = methodFlags[i][j];
-                if (layout.matches(flag)) {
-                    numExceptions[i][j] = (int) codec.decode(in);
-                }
-            }
-        }
+        int count = SegmentUtils.countMatches(methodFlags, layout);
+        int[] numExceptions = decodeBandInt("method_Exceptions_n", in, Codec.UNSIGNED5, count);
+        String[][] methodExceptionsRS = parseReferences("method_Exceptions_RC", in, Codec.UNSIGNED5, numExceptions, cpBands.getCpClass());
+        int index = 0;
         for (int i = 0; i < classCount; i++) {
             methodExceptions[i] = new ExceptionsAttribute[methodFlags[i].length];
             for (int j = 0; j < methodFlags[i].length; j++) {
                 long flag = methodFlags[i][j];
-                int n = numExceptions[i][j];
-                if (n > 0) {
-                    CPClass[] exceptions = new CPClass[n];
-                    if (layout.matches(flag)) {
-                        for (int k = 0; k < n; k++) {
-                            long result = codec.decode(in);
-                            exceptions[k] = new CPClass(
-                                    cpBands.getCpClass()[(int) result]);
-                        }
+                if(layout.matches(flag)) {
+                    int n = numExceptions[index];
+                    String[] exceptions = methodExceptionsRS[index];
+                    CPClass[] exceptionClasses = new CPClass[n];
+                    for (int k = 0; k < n; k++) {
+                        exceptionClasses[k] = new CPClass(exceptions[k]);
                     }
-                    methodExceptions[i][j] = new ExceptionsAttribute(exceptions);
+                    methodExceptions[i][j] = new ExceptionsAttribute(exceptionClasses);
                     methodAttributes[i][j].add(methodExceptions[i][j]);
+                    index ++;
                 }
             }
         }
     }
 
-    /**
-     * @param name
-     * @param flags
-     * @throws Pack200Exception
-     */
-    private void parseAttributeUnknown(String name, int context, long[][] flags)
-            throws Pack200Exception {
-        debug("Parsing unknown attributes for " + name);
-        AttributeLayout layout = attrMap.getAttributeLayout(name, context);
-        int count = SegmentUtils.countMatches(flags, layout);
-        if (count > 0)
-            throw new Error("We've got data for " + name
-                    + " and we don't know what to do with it (yet)");
-    }
-
-    /**
-     * @param in
-     * 
-     */
-    private void parseAttributeMethodSignature(InputStream in)
-            throws Pack200Exception, IOException {
-        parseAttributeUnknown(AttributeLayout.ATTRIBUTE_SIGNATURE,
-                AttributeLayout.CONTEXT_METHOD, methodFlags);
-    }
-
     private void parseClassAttrBands(InputStream in) throws IOException,
             Pack200Exception {
-        int classCount = header.getClassCount();
-        SegmentOptions options = header.getOptions();
         classFlags = parseFlags("class_flags", in, classCount, Codec.UNSIGNED5,
                 options.hasClassFlagsHi());
-        for (int i = 0; i < classCount; i++) {
+        int classAttrCount = 0;
+        for (int i = 0; i < classFlags.length; i++) {
             long flag = classFlags[i];
             if ((flag & (1 << 16)) != 0)
                 classAttrCount++;
         }
-        if (classAttrCount > 0)
-            throw new Error(
-                    "There are attribute flags, and I don't know what to do with them");
-        debug("unimplemented class_attr_count");
-        debug("unimplemented class_attr_indexes");
-        debug("unimplemented class_attr_calls");
-        AttributeLayout layout = attrMap.getAttributeLayout(
+        int[] classAttrCounts = decodeBandInt("class_attr_count", in, Codec.UNSIGNED5, classAttrCount);
+        int[][] classAttrIndexes = decodeBandInt("class_attr_indexes", in, Codec.UNSIGNED5, classAttrCounts);
+        int callCount = 0;
+        for (int i = 0; i < classAttrIndexes.length; i++) {
+            for (int j = 0; j < classAttrIndexes[i].length; j++) {
+                int index = classAttrIndexes[i][j];
+                AttributeLayout layout = attrMap.getAttributeLayout(index, AttributeLayout.CONTEXT_CLASS);
+                callCount += layout.numBackwardsCallables();
+            }
+        }
+        int[] classAttrCalls = decodeBandInt("class_attr_calls", in, Codec.UNSIGNED5, callCount);
+        
+        AttributeLayout sourceFileLayout = attrMap.getAttributeLayout(
                 AttributeLayout.ATTRIBUTE_SOURCE_FILE,
                 AttributeLayout.CONTEXT_CLASS);
+        int sourceFileCount = SegmentUtils.countMatches(classFlags,
+                sourceFileLayout);
+        int[] classSourceFile = decodeBandInt("class_SourceFile_RUN", in,
+                Codec.UNSIGNED5, sourceFileCount);
+
+        AttributeLayout enclosingMethodLayout = attrMap.getAttributeLayout(
+                AttributeLayout.ATTRIBUTE_ENCLOSING_METHOD,
+                AttributeLayout.CONTEXT_CLASS);
+        int enclosingMethodCount = SegmentUtils.countMatches(classFlags,
+                enclosingMethodLayout);
+        int[] enclosingMethodRC = decodeBandInt("class_EnclosingMethod_RC", in,
+                Codec.UNSIGNED5, enclosingMethodCount);        
+        int[] enclosingMethodRDN = decodeBandInt("class_EnclosingMethod_RDN", in,
+                Codec.UNSIGNED5, enclosingMethodCount);
+        
+        AttributeLayout signatureLayout = attrMap.getAttributeLayout(
+                AttributeLayout.ATTRIBUTE_SIGNATURE,
+                AttributeLayout.CONTEXT_CLASS);
+        int signatureCount = SegmentUtils.countMatches(classFlags,
+                signatureLayout);
+        int[] classSignature = decodeBandInt("class_Signature_RS", in,
+                Codec.UNSIGNED5, signatureCount);        
+
+        parseClassMetadataBands();
+        
+        AttributeLayout innerClassLayout = attrMap.getAttributeLayout(
+                AttributeLayout.ATTRIBUTE_INNER_CLASSES,
+                AttributeLayout.CONTEXT_CLASS);
+        int innerClassCount = SegmentUtils.countMatches(classFlags,
+                innerClassLayout);
+        int[] classInnerClassesN = decodeBandInt("class_InnerClasses_N", in,
+                Codec.UNSIGNED5, innerClassCount);
+        int[][] classInnerClassesRC = decodeBandInt("class_InnerClasses_RC", in, Codec.UNSIGNED5, classInnerClassesN);
+        int[][] classInnerClassesF = decodeBandInt("class_InnerClasses_F", in, Codec.UNSIGNED5, classInnerClassesN);
+        int flagsCount = 0;
+        for (int i = 0; i < classInnerClassesF.length; i++) {
+            for (int j = 0; j < classInnerClassesF[i].length; j++) {
+                if(classInnerClassesF[i][j] != 0) {
+                    flagsCount++;
+                }
+            }
+        }
+        int[] classInnerClassesOuterRCN = decodeBandInt("class_InnerClasses_outer_RCN", in, Codec.UNSIGNED5, flagsCount);
+        int[] classInnerClassesNameRUN = decodeBandInt("class_InnerClasses_name_RUN", in, Codec.UNSIGNED5, flagsCount);
+        
+        
+        AttributeLayout versionLayout = attrMap.getAttributeLayout(
+                AttributeLayout.ATTRIBUTE_CLASS_FILE_VERSION,
+                AttributeLayout.CONTEXT_CLASS);
+        int versionCount = SegmentUtils.countMatches(classFlags, versionLayout);
+        int[] classFileVersionMinorH = decodeBandInt(
+                "class_file_version_minor_H", in, Codec.UNSIGNED5, versionCount);
+        int[] classFileVersionMajorH = decodeBandInt(
+                "class_file_version_major_H", in, Codec.UNSIGNED5, versionCount);
+        
+        
+        // Now process the attribute bands we have parsed
+        int sourceFileIndex = 0;
+        int enclosingMethodIndex = 0;
+        int signatureIndex = 0;
+        int innerClassIndex = 0;
+        int versionIndex = 0;
+        classAttributes = new ArrayList[classCount];
         for (int i = 0; i < classCount; i++) {
+            classAttributes[i] = new ArrayList();
             long flag = classFlags[i];
-            if (layout.matches(flag)) {
+            if (sourceFileLayout.matches(flag)) {
+                long result = classSourceFile[sourceFileIndex];
                 // we've got a value to read
                 // TODO File this as a sourcefile attribute and don't generate
                 // everything below
-                long result = layout.getCodec().decode(in);
-                Object value = layout.getValue(result, cpBands
+                Object value = sourceFileLayout.getValue(result, cpBands
                         .getConstantPool());
                 debug("Processed value " + value + " for SourceFile");
+                sourceFileIndex++;
+            }
+            if(enclosingMethodLayout.matches(flag)) {
+                // TODO
+            }
+            if(signatureLayout.matches(flag)) {
+//              TODO
+            }
+            if(innerClassLayout.matches(flag)) {
+                // TODO
+            }
+            if(versionLayout.matches(flag)) {
+                // TODO
             }
         }
-        debug("unimplemented class_EnclosingMethod_RC");
-        debug("unimplemented class_EnclosingMethod_RDN");
-        debug("unimplemented class_Signature_RS");
-        parseClassMetadataBands();
-        debug("unimplemented class_InnerClasses_N");
-        debug("unimplemented class_InnerClasses_RC");
-        debug("unimplemented class_InnerClasses_F");
-        debug("unimplemented class_InnerClasses_outer_RCN");
-        debug("unimplemented class_InnerClasses_inner_RCN");
-        debug("unimplemented class_file_version_minor_H");
-        debug("unimplemented class_file_version_major_H");
     }
 
+    
     private void parseCodeBands(InputStream in) throws Pack200Exception,
             IOException {
         AttributeLayout layout = attrMap.getAttributeLayout(
                 AttributeLayout.ATTRIBUTE_CODE, AttributeLayout.CONTEXT_METHOD);
 
-        int codeBands = SegmentUtils.countMatches(methodFlags, layout);
+        int codeCount = SegmentUtils.countMatches(methodFlags, layout);
         int[] codeHeaders = decodeBandInt("code_headers", in, Codec.BYTE1,
-                codeBands);
+                codeCount);
         int codeSpecialHeader = 0;
-        for (int i = 0; i < codeBands; i++) {
+        for (int i = 0; i < codeCount; i++) {
             if (codeHeaders[i] == 0)
                 codeSpecialHeader++;
         }
@@ -374,11 +459,11 @@
         int[] codeHandlerCountSpecials = decodeBandInt("code_handler_count",
                 in, Codec.UNSIGNED5, codeSpecialHeader);
 
-        codeMaxStack = new int[codeBands];
-        codeMaxNALocals = new int[codeBands];
-        codeHandlerCount = new int[codeBands];
+        codeMaxStack = new int[codeCount];
+        codeMaxNALocals = new int[codeCount];
+        codeHandlerCount = new int[codeCount];
         int special = 0;
-        for (int i = 0; i < codeBands; i++) {
+        for (int i = 0; i < codeCount; i++) {
             int header = 0xff & codeHeaders[i];
             if (header < 0) {
                 throw new IllegalStateException("Shouldn't get here");
@@ -403,26 +488,44 @@
                 throw new IllegalStateException("Shouldn't get here either");
             }
         }
+        int sumCodeHandlerCount = 0;
+        for (int i = 0; i < codeHandlerCount.length; i++) {
+            sumCodeHandlerCount+= codeHandlerCount[i];
+        }
+        int[] codeHandlerStartP = decodeBandInt("code_handler_start_P", in, Codec.BCI5, sumCodeHandlerCount);
+        int[] codeHandlerEndPO = decodeBandInt("code_handler_end_PO", in, Codec.BRANCH5, sumCodeHandlerCount);
+        int[] codeHandlerCatchPO = decodeBandInt("code_handler_catch_PO", in, Codec.BRANCH5, sumCodeHandlerCount);
+        int[] codeHandlerClassRCN = decodeBandInt("code_handler_class_RCN", in, Codec.UNSIGNED5, sumCodeHandlerCount);
+        
         int codeFlagsCount = segment.getSegmentHeader().getOptions().hasAllCodeFlags() ?
-                    codeBands : codeSpecialHeader;
+                codeCount : codeSpecialHeader;
         parseCodeAttrBands(in, codeFlagsCount);
     }
 
     private void parseCodeAttrBands(InputStream in, int codeFlagsCount) throws IOException, Pack200Exception {
         long[] codeFlags = parseFlags("code_flags", in, codeFlagsCount, Codec.UNSIGNED5, segment.getSegmentHeader().getOptions().hasCodeFlagsHi());
+        int codeAttrCount = 0;
         for (int i = 0; i < codeFlagsCount; i++) {
             long flag = codeFlags[i];
             if ((flag & (1 << 16)) != 0)
                 codeAttrCount++;
         }
-        if (codeAttrCount > 0)
-            throw new Error(
-                    "There are attribute flags, and I don't know what to do with them");
-        debug("unimplemented code_attr_count");
-        debug("unimplemented code_attr_indexes");
-        debug("unimplemented code_attr_calls");
-        
+        System.out.println("codeAttrCount = " + codeAttrCount);
+        int[] codeAttrCounts = decodeBandInt("code_attr_count", in, Codec.UNSIGNED5, codeAttrCount);
+        int[][] codeAttrIndexes = decodeBandInt("code_attr_indexes", in, Codec.UNSIGNED5, codeAttrCounts);
+        int callCount = 0;
+        for (int i = 0; i < codeAttrIndexes.length; i++) {
+            for (int j = 0; j < codeAttrIndexes[i].length; j++) {
+                int index = codeAttrIndexes[i][j];
+                AttributeLayout layout = attrMap.getAttributeLayout(index, AttributeLayout.CONTEXT_CODE);
+                callCount += layout.numBackwardsCallables();
+            }
+        }
+        System.out.println("callCount = " + callCount);
+        int[] codeAttrCalls = decodeBandInt("code_attr_calls", in, Codec.UNSIGNED5, callCount);
+       
         int lineNumberTableCount = SegmentUtils.countMatches(codeFlags, attrMap.getAttributeLayout(AttributeLayout.ATTRIBUTE_LINE_NUMBER_TABLE, AttributeLayout.CONTEXT_CODE));
+        System.out.println("lineNumberTables = " + lineNumberTableCount);
         int[] lineNumberTableN = decodeBandInt("code_LineNumberTable_N", in, Codec.UNSIGNED5, lineNumberTableCount);
         int[][] lineNumberTableBciP = decodeBandInt("code_LineNumberTable_bci_P", in, Codec.BCI5, lineNumberTableN);
         int[][] lineNumberTableLine = decodeBandInt("code_LineNumberTable_line", in, Codec.UNSIGNED5, lineNumberTableN);
@@ -430,6 +533,8 @@
         for (int i = 0; i < types.length; i++) {
             String type = types[i];
             int lengthNBand = SegmentUtils.countMatches(codeFlags, attrMap.getAttributeLayout(type, AttributeLayout.CONTEXT_CODE));
+            System.out.println(type + " count = " + lengthNBand);
+            
             int[] nBand = decodeBandInt("code_" + type + "_N", in, Codec.UNSIGNED5, lengthNBand);
             int[][] bciP = decodeBandInt("code_" + type + "_bci_P", in, Codec.BCI5, nBand);
             int[][] spanO = decodeBandInt("code_" + type + "_span_O", in, Codec.BRANCH5, nBand);
@@ -597,10 +702,6 @@
         }
     }
 
-    public int getClassAttrCount() {
-        return classAttrCount;
-    }
-
     public int[] getClassFieldCount() {
         return classFieldCount;
     }
@@ -647,10 +748,6 @@
 
     public long[][] getFieldFlags() {
         return fieldFlags;
-    }
-
-    public int getMethodAttrCount() {
-        return methodAttrCount;
     }
 
     public ArrayList[][] getMethodAttributes() {

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=587111&r1=587110&r2=587111&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 Mon Oct 22 07:31:32 2007
@@ -15,9 +15,7 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -95,9 +93,6 @@
  * by the Pack200 specification, which allow a codec to be referred to by
  * canonical number. TODO Add links to canonical numbers when this has been
  * done.
- * 
- * @author Alex Blewitt
- * @version $Revision: $
  */
 public abstract class Codec {
 	/**
@@ -129,7 +124,7 @@
 	public static final BHSDCodec DELTA5 = new BHSDCodec(5, 64, 1, 1);
 
 	/**
-	 * DELTA5 = (5,64,2,1): Used for the majority of numerical codings where
+	 * MDELTA5 = (5,64,2,1): Used for the majority of numerical codings where
 	 * there is a correlated sequence of signed values, but where most of them
 	 * are expected to be non-negative.
 	 */
@@ -147,7 +142,7 @@
 	public static final BHSDCodec UDELTA5 = new BHSDCodec(5, 64, 0, 1);
 
 	/**
-	 * USIGNED5 = (5,64): Used for small unsigned values.
+	 * UNSIGNED5 = (5,64): Used for small unsigned values.
 	 */
 	public static final BHSDCodec UNSIGNED5 = new BHSDCodec(5, 64);
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java Mon Oct 22 07:31:32 2007
@@ -15,20 +15,19 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
 
 public class CodecEncoding {
+
 	/**
 	 * The canonical encodings are defined to allow a single byte to represent
 	 * one of the standard encodings. The following values are defined in the
 	 * Pack200 specification, and this array cannot be changed.
 	 */
-	private static Codec[] canonicalCodec = { null, new BHSDCodec(1, 256),
+	private static final Codec[] canonicalCodec = { null, new BHSDCodec(1, 256),
 			new BHSDCodec(1, 256, 1), new BHSDCodec(1, 256, 0, 1),
 			new BHSDCodec(1, 256, 1, 1), new BHSDCodec(2, 256),
 			new BHSDCodec(2, 256, 1), new BHSDCodec(2, 256, 0, 1),
@@ -100,7 +99,7 @@
 	 * @throws Pack200Exception 
 	 */
 	public static Codec getCodec(int value, InputStream in, Codec defaultCodec) throws IOException, Pack200Exception {
-		// Sanity check to make sure that no-one's been buggering with
+		// Sanity check to make sure that no-one has changed
 		// the canonical codecs, which would really cause havoc
 		if (canonicalCodec.length != 116) 
 			throw new Error("Canonical encodings have been incorrectly modified");

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=587111&r1=587110&r2=587111&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 Mon Oct 22 07:31:32 2007
@@ -209,8 +209,8 @@
     private void parseCpLong(InputStream in) throws IOException,
             Pack200Exception {
         int cpLongCount = header.getCpLongCount();
-        cpLong = parseFlags("cp_Long", in, cpLongCount, new int[] { 1 },
-                Codec.UDELTA5, Codec.DELTA5)[0];
+        cpLong = parseFlags("cp_Long", in, cpLongCount,
+                Codec.UDELTA5, Codec.DELTA5);
     }
 
     /**
@@ -262,7 +262,18 @@
         String[] cpSignatureForm = parseReferences("cp_Signature_form", in,
                 Codec.DELTA5, cpSignatureCount, cpUTF8);
         cpSignature = new String[cpSignatureCount];
-        long last = 0;
+        int lCount = 0;
+        for (int i = 0; i < cpSignatureCount; i++) {
+            String form = cpSignatureForm[i];
+            char[] chars = form.toCharArray();
+            for (int j = 0; j < chars.length; j++) {
+                if(chars[j] == 'L') {
+                    lCount++;
+                }
+            }
+        }
+        String[] cpSignatureClasses = parseReferences("cp_Signature_classes", in, Codec.UDELTA5, lCount, cpClass);
+        int index = 0;
         for (int i = 0; i < cpSignatureCount; i++) {
             String form = cpSignatureForm[i];
             int len = form.length();
@@ -272,10 +283,10 @@
                 char c = form.charAt(j);
                 signature.append(c);
                 if (c == 'L') {
-                    int index = (int) (last = Codec.UDELTA5.decode(in, last));
-                    String className = cpClass[index];
+                    String className = cpSignatureClasses[index];
                     list.add(className);
                     signature.append(className);
+                    index++;
                 }
             }
             cpSignature[i] = signature.toString();

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java Mon Oct 22 07:31:32 2007
@@ -67,42 +67,22 @@
             Pack200Exception {
         int numberOfFiles = header.getNumberOfFiles();
         SegmentOptions options = header.getOptions();
-        if (false && System.getProperty("debug.pack200") != null) {
-            // TODO HACK
-            fileSize = new long[numberOfFiles];
-            fileModtime = new long[numberOfFiles];
-            fileOptions = new long[numberOfFiles];
-            fileName = new String[numberOfFiles];
-            Arrays.fill(fileName, "");
-            return;
-        }
-        long last;
+
         fileName = parseReferences("file_name", in, Codec.UNSIGNED5,
                 numberOfFiles, cpUTF8);
-        fileSize = new long[numberOfFiles];
-        if (options.hasFileSizeHi()) {
-            last = 0;
-            for (int i = 0; i < numberOfFiles; i++) {
-                fileSize[i] = (last = Codec.UNSIGNED5.decode(in, last)) << 32;
-            }
-        }
-        last = 0;
-        for (int i = 0; i < numberOfFiles; i++) {
-            fileSize[i] |= (last = Codec.UNSIGNED5.decode(in, last));
-        }
-        fileModtime = new long[numberOfFiles];
+        fileSize = parseFlags("file_size", in, numberOfFiles, Codec.UNSIGNED5,
+                options.hasFileSizeHi());
         if (options.hasFileModtime()) {
-            last = 0;
-            for (int i = 0; i < numberOfFiles; i++) {
-                fileModtime[i] |= (last = Codec.DELTA5.decode(in, last));
-            }
+            fileModtime = decodeBandLong("file_modtime", in, Codec.DELTA5,
+                    numberOfFiles);
+        } else {
+            fileModtime = new long[numberOfFiles];
         }
-        fileOptions = new long[numberOfFiles];
         if (options.hasFileOptions()) {
-            last = 0;
-            for (int i = 0; i < numberOfFiles; i++) {
-                fileOptions[i] |= (last = Codec.UNSIGNED5.decode(in, last));
-            }
+            fileOptions = decodeBandLong("file_options", in, Codec.UNSIGNED5,
+                    numberOfFiles);
+        } else {
+            fileOptions = new long[numberOfFiles];
         }
     }
     

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java Mon Oct 22 07:31:32 2007
@@ -62,12 +62,9 @@
         int innerClassCount = header.getInnerClassCount();
         icThisClass = parseReferences("ic_this_class", in, Codec.UDELTA5,
                 innerClassCount, cpClass);
-        icFlags = new int[innerClassCount];
-        long last = 0;
+        icFlags = decodeBandInt("ic_flags", in, Codec.UNSIGNED5, innerClassCount);
         int outerClasses = 0;
-        // ic_flags
         for (int i = 0; i < innerClassCount; i++) {
-            icFlags[i] = (int) (last = Codec.UNSIGNED5.decode(in, last));
             if ((icFlags[i] & 1 << 16) != 0)
                 outerClasses++;
         }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java Mon Oct 22 07:31:32 2007
@@ -15,14 +15,9 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 /**
  * Represents a problem with a Pack200 coding/decoding issue.
- * 
- * @author Alex Blewitt
- * @version $Revision: $
  */
 public class Pack200Exception extends Exception {
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java Mon Oct 22 07:31:32 2007
@@ -15,9 +15,7 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 import java.io.IOException;
 import java.io.InputStream;
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java Mon Oct 22 07:31:32 2007
@@ -15,9 +15,7 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -26,9 +24,6 @@
  * the first codec, and the remaining codes are decoded from the remaining
  * codec. Note that since this codec maintains state, the instances are
  * not reusable.
- *
- * @author Alex Blewitt
- * @version $Revision: $
  */
 public class RunCodec extends Codec {
 	private int k;

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=587111&r1=587110&r2=587111&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 Mon Oct 22 07:31:32 2007
@@ -16,10 +16,6 @@
  */
 package org.apache.harmony.pack200;
 
-// NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-// NOTE: Do not extract strings as messages; this code is still a
-// work-in-progress
-// NOTE: Also, don't get rid of 'else' statements for the hell of it ...
 import java.io.BufferedInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -64,9 +60,6 @@
  * In any case, if GZip decompression is being performed the input stream will
  * be buffered at a higher level, and thus this can read on a byte-oriented
  * basis.
- * 
- * @author Alex Blewitt
- * @version $Revision: $
  */
 public class Segment {
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentOptions.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentOptions.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentOptions.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentOptions.java Mon Oct 22 07:31:32 2007
@@ -15,9 +15,7 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 /**
  * Stores the combinations of bit flags that can be used in the segment header
  * options. Whilst this could be defined in {@link Segment}, it's cleaner to
@@ -25,9 +23,6 @@
  * to determine the semantic meaning of the flags. In languages with a
  * pre-processor, these may be defined by macros that do bitflag manipulation
  * instead.
- * 
- * @author Alex Blewitt
- * @version $Revision: $
  */
 public class SegmentOptions {
 	private static final int DEFLATE_HINT = 1 << 5;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java Mon Oct 22 07:31:32 2007
@@ -16,10 +16,6 @@
  */
 package org.apache.harmony.pack200.bytecode;
 
-// NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-// NOTE: Do not extract strings as messages; this code is still a
-// work-in-progress
-// NOTE: Also, don't get rid of 'else' statements for the hell of it ...
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFile.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFile.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFile.java Mon Oct 22 07:31:32 2007
@@ -15,9 +15,7 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200.bytecode;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 import java.io.DataOutputStream;
 import java.io.IOException;
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java Mon Oct 22 07:31:32 2007
@@ -16,10 +16,6 @@
  */
 package org.apache.harmony.pack200.bytecode;
 
-// NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-// NOTE: Do not extract strings as messages; this code is still a
-// work-in-progress
-// NOTE: Also, don't get rid of 'else' statements for the hell of it ...
 import java.io.DataOutputStream;
 import java.io.IOException;
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java Mon Oct 22 07:31:32 2007
@@ -16,16 +16,10 @@
  */
 package org.apache.harmony.pack200.bytecode;
 
-// NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-// NOTE: Do not extract strings as messages; this code is still a
-// work-in-progress
-// NOTE: Also, don't get rid of 'else' statements for the hell of it ...
 import java.io.DataOutputStream;
 import java.io.IOException;
 
-
 /**
- * @author alex
  * 
  */
 public abstract class ConstantPoolEntry extends ClassFileEntry {

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AbstractBandsTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AbstractBandsTestCase.java?rev=587111&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AbstractBandsTestCase.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AbstractBandsTestCase.java Mon Oct 22 07:31:32 2007
@@ -0,0 +1,81 @@
+/*
+ *  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.tests;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.pack200.AttrDefinitionBands;
+import org.apache.harmony.pack200.AttributeLayoutMap;
+import org.apache.harmony.pack200.Pack200Exception;
+import org.apache.harmony.pack200.Segment;
+import org.apache.harmony.pack200.SegmentHeader;
+import org.apache.harmony.pack200.SegmentOptions;
+
+/**
+ *
+ */
+public abstract class AbstractBandsTestCase extends TestCase {
+
+    protected int numClasses = 1;
+    protected int[] numMethods = {1};
+
+    public class MockSegmentHeader extends SegmentHeader {
+        public int getClassCount() {
+            return numClasses;
+        }
+        
+        public SegmentOptions getOptions() {
+            try {
+                return new SegmentOptions(0);
+            } catch (Pack200Exception e) {
+                return null;
+            }
+        }
+    }
+
+    public class MockAttributeDefinitionBands extends AttrDefinitionBands {
+
+        public MockAttributeDefinitionBands(Segment segment) {
+            super(segment);
+        }
+        
+        public AttributeLayoutMap getAttributeDefinitionMap() {
+            try {
+                return new AttributeLayoutMap();
+            } catch (Pack200Exception e) {
+                fail(e.getLocalizedMessage());
+            }
+            return null;
+        }
+        
+       
+
+    }
+
+    public class MockSegment extends Segment {
+        
+        protected AttrDefinitionBands getAttrDefinitionBands() {
+            return new MockAttributeDefinitionBands(this);
+        }     
+        
+        public SegmentHeader getSegmentHeader() {
+            return new MockSegmentHeader();
+        }
+    }
+    
+    
+}

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

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutMapTest.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutMapTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutMapTest.java Mon Oct 22 07:31:32 2007
@@ -15,9 +15,7 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200.tests;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 import junit.framework.TestCase;
 
 import org.apache.harmony.pack200.AttributeLayout;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java Mon Oct 22 07:31:32 2007
@@ -15,9 +15,7 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200.tests;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
 import junit.framework.TestCase;
 
 import org.apache.harmony.pack200.AttributeLayout;

Added: 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=587111&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java Mon Oct 22 07:31:32 2007
@@ -0,0 +1,57 @@
+/*
+ *  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.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.pack200.BHSDCodec;
+import org.apache.harmony.pack200.CodecEncoding;
+import org.apache.harmony.pack200.Pack200Exception;
+
+/**
+ * Tests for BHSDCodec
+ */
+public class BHSDCodecTest extends TestCase {
+
+    
+    public void testEncodeDecode() throws IOException, Pack200Exception {
+        for (int i = 1; i < 116; i++) {
+            
+            BHSDCodec codec = (BHSDCodec) CodecEncoding.getCodec(i, null, null);
+            
+            // Test encode-decode with a selection of numbers within the range of the codec
+            long delta = (codec.largest() - codec.smallest()) / 4;
+            for (long j = codec.smallest(); j <= codec.largest() + 1; j += delta) {
+                byte[] encoded = codec.encode(j, 0);
+                long decoded = codec.decode(new ByteArrayInputStream(encoded),
+                        0);
+                if (j != decoded) {
+                    fail("Failed with codec: " + codec + " expected: " + j
+                            + ", got: " + decoded);
+                }
+            }
+            
+            // Test encode-decode with 0            
+            assertEquals(0, codec.decode(new ByteArrayInputStream(codec.encode(
+                    0, 0)), 0));
+        }
+    }
+    
+}
\ No newline at end of file

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

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java Mon Oct 22 07:31:32 2007
@@ -26,18 +26,27 @@
 import org.apache.harmony.pack200.BHSDCodec;
 import org.apache.harmony.pack200.BandSet;
 import org.apache.harmony.pack200.Codec;
+import org.apache.harmony.pack200.CodecEncoding;
 import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.Segment;
+import org.apache.harmony.pack200.SegmentHeader;
 
 public class BandSetTest extends TestCase {
     
-    private BandSet bandSet = new BandSet(new Segment()) {
+    public class MockSegment extends Segment {
+        public SegmentHeader getSegmentHeader() {
+            return new SegmentHeader();
+        }
+    }
+
+    private BandSet bandSet = new BandSet(new MockSegment()) {
 
         public void pack(OutputStream outputStream) {
         }
 
         public void unpack(InputStream inputStream) throws IOException, Pack200Exception {
         }
+        
     };
     
     public void testDecodeBandInt() throws IOException, Pack200Exception {
@@ -52,13 +61,24 @@
     
     public void testDecodeBandLong() throws IOException, Pack200Exception {
         BHSDCodec codec = Codec.BYTE1;
-        byte[] bytes = new byte[]{(byte)3,(byte)56,(byte)122,(byte)78, Byte.MAX_VALUE, Byte.MIN_VALUE};
+        byte[] bytes = new byte[]{(byte)3,(byte)56,(byte)122,(byte)78, (byte)0, (byte)255};
         InputStream in = new ByteArrayInputStream(bytes);
-        long[] longs = bandSet.decodeBandLong("Test Band", in, codec, 4);
+        long[] longs = bandSet.decodeBandLong("Test Band", in, codec, 6);
         for (int i = 0; i < longs.length; i++) {
-            assertEquals("Wrong value in position " + i, longs[i], bytes[i]);
+            assertEquals("Wrong value in position " + i, (byte)longs[i], bytes[i]);
         }        
         //TODO: Should test this with other Codecs.
+    }
+    
+    public void testDecodeBandLong2() throws IOException, Pack200Exception {
+        
+        BHSDCodec codec = Codec.DELTA5;
+        byte[] bytes = new byte[]{3, 1, 2, 3, 4, 5}; // 3 is decoded to -2 by DELTA5, which signifies a switch to BYTE1
+        InputStream in = new ByteArrayInputStream(bytes);
+        long[] longs = bandSet.decodeBandLong("Test Band", in, codec, 5);
+        for (int i = 0; i < longs.length; i++) {
+            assertEquals("Wrong value in position " + i, longs[i], bytes[i + 1]);
+        }    
     }
     
     public void testParseFlags1() {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BcBandsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BcBandsTest.java?rev=587111&r1=587110&r2=587111&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BcBandsTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BcBandsTest.java Mon Oct 22 07:31:32 2007
@@ -43,17 +43,7 @@
  * should be replaced with properly encoded byte arrays when encoding is
  * implemented.
  */
-public class BcBandsTest extends TestCase {
-
-    
-    private int numClasses = 1;
-    private int[] numMethods = {1};
-
-    public class MockSegmentHeader extends SegmentHeader {
-        public int getClassCount() {
-            return numClasses;
-        }
-    }
+public class BcBandsTest extends AbstractBandsTestCase {
 
     public class MockClassBands extends ClassBands {
         public MockClassBands(Segment segment) {
@@ -107,26 +97,7 @@
         }
     }
 
-    public class MockAttributeDefinitionBands extends AttrDefinitionBands {
-
-        public MockAttributeDefinitionBands(Segment segment) {
-            super(segment);
-        }
-        
-        public AttributeLayoutMap getAttributeDefinitionMap() {
-            try {
-                return new AttributeLayoutMap();
-            } catch (Pack200Exception e) {
-                fail(e.getLocalizedMessage());
-            }
-            return null;
-        }
-        
-       
-
-    }
-
-    public class MockSegment extends Segment {
+    public class MockSegment extends AbstractBandsTestCase.MockSegment {
         protected AttrDefinitionBands getAttrDefinitionBands() {
             return new MockAttributeDefinitionBands(this);
         }
@@ -137,10 +108,6 @@
         
         protected ClassBands getClassBands() {
             return new MockClassBands(this);
-        }
-        
-        public SegmentHeader getSegmentHeader() {
-            return new MockSegmentHeader();
         }
     }
 



Mime
View raw message