harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r785606 [3/4] - in /harmony/enhanced/classlib/branches/java6: ./ make/ modules/archive/src/main/java/java/util/jar/ modules/archive/src/main/java/java/util/zip/ modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ m...
Date Wed, 17 Jun 2009 14:00:28 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java Wed Jun 17 14:00:24 2009
@@ -85,6 +85,8 @@
      */
     public static final BHSDCodec UNSIGNED5 = new BHSDCodec(5, 64);
 
+    public int lastBandLength;
+
     /**
      * Decode a sequence of bytes from the given input stream, returning the
      * value as a long. Note that this method can only be applied for non-delta
@@ -99,7 +101,7 @@
      * @throws Pack200Exception
      *             if the encoding is a delta encoding
      */
-    public abstract long decode(InputStream in) throws IOException,
+    public abstract int decode(InputStream in) throws IOException,
             Pack200Exception;
 
     /**
@@ -112,7 +114,7 @@
      * @return the encoded bytes
      * @throws Pack200Exception
      */
-    public abstract byte[] encode(long value, long last)
+    public abstract byte[] encode(int value, int last)
             throws Pack200Exception;
 
     /**
@@ -124,7 +126,7 @@
      * @return the encoded bytes
      * @throws Pack200Exception
      */
-    public abstract byte[] encode(long value) throws Pack200Exception;
+    public abstract byte[] encode(int value) throws Pack200Exception;
 
     /**
      * Decode a sequence of bytes from the given input stream, returning the
@@ -154,7 +156,7 @@
      *             if there is a problem decoding the value or that the value is
      *             invalid
      */
-    public abstract long decode(InputStream in, long last) throws IOException,
+    public abstract int decode(InputStream in, long last) throws IOException,
             Pack200Exception;
 
     /**
@@ -168,36 +170,6 @@
      *            the number of values to decode
      * @param in
      *            the input stream to read from
-     * @return an array of <code>long</code> values corresponding to values
-     *         decoded
-     * @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 long[] decode(int n, InputStream in) throws IOException,
-            Pack200Exception {
-        long result[] = new long[n];
-        long last = 0;
-        for (int i = 0; i < n; i++) {
-            result[i] = last = decode(in, last);
-        }
-        return result;
-    }
-
-    /**
-     * Decodes a sequence of <code>n</code> values from <code>in</code>.
-     * This should probably be used in most cases, since some codecs (such as
-     *
-     * @{link PopCodec}) only work when the number of values to be read is
-     *        known.
-     *
-     * @param n
-     *            the number of values to decode
-     * @param in
-     *            the input stream to read from
      * @return an array of <code>int</code> values corresponding to values
      *         decoded
      * @throws IOException
@@ -209,38 +181,10 @@
      */
     public int[] decodeInts(int n, InputStream in) throws IOException,
             Pack200Exception {
+        lastBandLength = 0;
         int result[] = new int[n];
         int last = 0;
         for (int i = 0; i < n; i++) {
-            result[i] = last = (int) decode(in, last);
-        }
-        return result;
-    }
-
-    /**
-     * Decodes a sequence of <code>n</code> values from <code>in</code>.
-     *
-     * @param n
-     *            the number of values to decode
-     * @param in
-     *            the input stream to read from
-     * @param firstValue
-     *            the first value in the band if it has already been read
-     * @return an array of <code>long</code> values corresponding to values
-     *         decoded, with firstValue as the first value in the array.
-     * @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 long[] decode(int n, InputStream in, long firstValue)
-            throws IOException, Pack200Exception {
-        long result[] = new long[n + 1];
-        result[0] = firstValue;
-        long last = firstValue;
-        for (int i = 1; i < n + 1; i++) {
             result[i] = last = decode(in, last);
         }
         return result;
@@ -270,7 +214,7 @@
         result[0] = firstValue;
         int last = firstValue;
         for (int i = 1; i < n + 1; i++) {
-            result[i] = last = (int) decode(in, last);
+            result[i] = last = decode(in, last);
         }
         return result;
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java Wed Jun 17 14:00:24 2009
@@ -34,7 +34,7 @@
      * one of the standard encodings. The following values are defined in the
      * Pack200 specification, and this array cannot be changed.
      */
-    private static final Codec[] canonicalCodec = { null,
+    private static final BHSDCodec[] 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),
@@ -292,7 +292,7 @@
             int fDef = favouredCodec.equals(defaultForBand) ? 1 : 0;
             int uDef = unfavouredCodec.equals(defaultForBand) ? 1 : 0;
             int tDefL = 0;
-            long[] favoured = populationCodec.getFavoured();
+            int[] favoured = populationCodec.getFavoured();
             if(favoured != null) {
                 int k = favoured.length;
                 if(tokenCodec == Codec.BYTE1) {
@@ -334,4 +334,8 @@
 
         return null;
     }
+
+    public static BHSDCodec getCanonicalCodec(int i) {
+        return canonicalCodec[i];
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java Wed Jun 17 14:00:24 2009
@@ -16,7 +16,9 @@
  */
 package org.apache.harmony.pack200;
 
-
+/**
+ * Abstract superclass for constant pool entries
+ */
 public abstract class ConstantPoolEntry {
 
     private int index = -1;

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java Wed Jun 17 14:00:24 2009
@@ -93,9 +93,9 @@
         writeCpClass(out);
         writeCpSignature(out);
         writeCpDescr(out);
-        writeCpMethodOrField(cp_Field, out);
-        writeCpMethodOrField(cp_Method, out);
-        writeCpMethodOrField(cp_Imethod, out);
+        writeCpMethodOrField(cp_Field, out, "cp_Field");
+        writeCpMethodOrField(cp_Method, out, "cp_Method");
+        writeCpMethodOrField(cp_Imethod, out, "cp_Imethod");
     }
 
     private void writeCpUtf8(OutputStream out) throws IOException,
@@ -175,7 +175,7 @@
             cpInt[i] = integer.getInt();
             i++;
         }
-        out.write(encodeBandInt("cpInt", cpInt, Codec.UDELTA5));
+        out.write(encodeBandInt("cp_Int", cpInt, Codec.UDELTA5));
     }
 
     private void writeCpFloat(OutputStream out) throws IOException,
@@ -187,7 +187,7 @@
             cpFloat[i] = Float.floatToIntBits(fl.getFloat());
             i++;
         }
-        out.write(encodeBandInt("cpFloat", cpFloat, Codec.UDELTA5));
+        out.write(encodeBandInt("cp_Float", cpFloat, Codec.UDELTA5));
     }
 
     private void writeCpLong(OutputStream out) throws IOException,
@@ -278,11 +278,11 @@
             cpDescrType[i] = nameAndType.getTypeIndex();
             i++;
         }
-        out.write(encodeBandInt("cpDescrName", cpDescrName, Codec.DELTA5));
-        out.write(encodeBandInt("cpDescrType", cpDescrType, Codec.UDELTA5));
+        out.write(encodeBandInt("cp_Descr_Name", cpDescrName, Codec.DELTA5));
+        out.write(encodeBandInt("cp_Descr_Type", cpDescrType, Codec.UDELTA5));
     }
 
-    private void writeCpMethodOrField(Set cp, OutputStream out)
+    private void writeCpMethodOrField(Set cp, OutputStream out, String name)
             throws IOException, Pack200Exception {
         int[] cp_methodOrField_class = new int[cp.size()];
         int[] cp_methodOrField_desc = new int[cp.size()];
@@ -293,12 +293,17 @@
             cp_methodOrField_desc[i] = mOrF.getDescIndex();
             i++;
         }
-        out.write(encodeBandInt("cp_methodOrField_class",
+        out.write(encodeBandInt(name + "_class",
                 cp_methodOrField_class, Codec.DELTA5));
-        out.write(encodeBandInt("cp_methodOrField_desc", cp_methodOrField_desc,
+        out.write(encodeBandInt(name + "_desc", cp_methodOrField_desc,
                 Codec.UDELTA5));
     }
 
+    /**
+     * All input classes for the segment have now been read in, so this method
+     * is called so that this class can calculate/complete anything it could not
+     * do while classes were being read.
+     */
     public void finaliseBands() {
         addCPUtf8("");
         removeSignaturesFromCpUTF8();

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java Wed Jun 17 14:00:24 2009
@@ -26,6 +26,11 @@
 import org.apache.harmony.pack200.Archive.File;
 import org.objectweb.asm.ClassReader;
 
+/**
+ * Bands containing information about files in the pack200 archive and the file
+ * contents for non-class-files. Corresponds to the <code>file_bands</code> set
+ * of bands described in the specification.
+ */
 public class FileBands extends BandSet {
 
     private final CPUTF8[] fileName;
@@ -74,6 +79,11 @@
          }
     }
 
+    /**
+     * All input classes for the segment have now been read in, so this method
+     * is called so that this class can calculate/complete anything it could not
+     * do while classes were being read.
+     */
     public void finaliseBands() {
         file_name = new int[fileName.length];
         for (int i = 0; i < file_name.length; i++) {
@@ -104,7 +114,7 @@
         int index = 0;
         for (int i = 0; i < bytes.length; i++) {
             for (int j = 0; j < bytes[i].length; j++) {
-                band[index++] = bytes[i][j];
+                band[index++] = bytes[i][j] & 0xFF;
             }
         }
         return band;

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java Wed Jun 17 14:00:24 2009
@@ -26,6 +26,10 @@
 import java.util.Set;
 import java.util.TreeSet;
 
+/**
+ * Inner class bands (corresponds to the <code>ic_bands</code> set of bands in
+ * the pack200 specification)
+ */
 public class IcBands extends BandSet {
 
     private final Set innerClasses = new TreeSet();
@@ -39,6 +43,11 @@
         this.cpBands = cpBands;
     }
 
+    /**
+     * All input classes for the segment have now been read in, so this method
+     * is called so that this class can calculate/complete anything it could not
+     * do while classes were being read.
+     */
     public void finaliseBands() {
         segmentHeader.setIc_count(innerClasses.size());
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java Wed Jun 17 14:00:24 2009
@@ -19,9 +19,9 @@
 import java.util.Arrays;
 
 /**
- * IntList is based on java.util.ArrayList, but is written specifically for ints
- * in order to reduce boxing and unboxing to Integers and reduce the memory
- * required.
+ * IntList is based on <code>java.util.ArrayList</code>, but is written
+ * specifically for ints in order to reduce boxing and unboxing to Integers,
+ * reduce the memory required and improve performance of pack200.
  */
 public class IntList {
 

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java Wed Jun 17 14:00:24 2009
@@ -36,9 +36,9 @@
     private int numBackwardsCalls = 0;
 
     public List param_NB = new ArrayList(); // TODO: Lazy instantiation?
-    public List anno_N = new ArrayList();
+    public IntList anno_N = new IntList();
     public List type_RS = new ArrayList();
-    public List pair_N = new ArrayList();
+    public IntList pair_N = new IntList();
     public List name_RU = new ArrayList();
     public List T = new ArrayList();
     public List caseI_KI = new ArrayList();
@@ -49,9 +49,9 @@
     public List caseet_RS = new ArrayList();
     public List caseec_RU = new ArrayList();
     public List cases_RU = new ArrayList();
-    public List casearray_N = new ArrayList();
+    public IntList casearray_N = new IntList();
     public List nesttype_RS = new ArrayList();
-    public List nestpair_N = new ArrayList();
+    public IntList nestpair_N = new IntList();
     public List nestname_RU = new ArrayList();
 
     private final CpBands cpBands;
@@ -59,7 +59,18 @@
 
     /**
      * Constructs a new MetadataBandGroup
-     * @param type - must be either AD, RVA, RIA, RVPA or RIPA.
+     *
+     * @param type
+     *            must be either AD, RVA, RIA, RVPA or RIPA.
+     * @param context
+     *            <code>CONTEXT_CLASS</code>, <code>CONTEXT_METHOD</code> or
+     *            <code>CONTEXT_FIELD</code>
+     * @param cpBands
+     *            constant pool bands
+     * @param segmentHeader
+     *            segment header
+     * @param effort
+     *            packing effort
      */
     public MetadataBandGroup(String type, int context, CpBands cpBands, SegmentHeader segmentHeader, int effort) {
         super(effort, segmentHeader);
@@ -82,9 +93,9 @@
                 contextStr = "Method";
             }
             if(!type.equals("AD")) {
-                out.write(encodeBandInt(contextStr + "_" + type + " anno_N",  listToArray(anno_N), Codec.UNSIGNED5));
+                out.write(encodeBandInt(contextStr + "_" + type + " anno_N",  anno_N.toArray(), Codec.UNSIGNED5));
                 out.write(encodeBandInt(contextStr + "_" + type + " type_RS",  cpEntryListToArray(type_RS), Codec.UNSIGNED5));
-                out.write(encodeBandInt(contextStr + "_" + type + " pair_N",  listToArray(pair_N), Codec.UNSIGNED5));
+                out.write(encodeBandInt(contextStr + "_" + type + " pair_N",  pair_N.toArray(), Codec.UNSIGNED5));
                 out.write(encodeBandInt(contextStr + "_" + type + " name_RU",  cpEntryListToArray(name_RU), Codec.UNSIGNED5));
             }
             out.write(encodeBandInt(contextStr + "_" + type + " T",  tagListToArray(T), Codec.BYTE1));
@@ -96,9 +107,9 @@
             out.write(encodeBandInt(contextStr + "_" + type + " caseet_RS",  cpEntryListToArray(caseet_RS), Codec.UNSIGNED5));
             out.write(encodeBandInt(contextStr + "_" + type + " caseec_RU",  cpEntryListToArray(caseec_RU), Codec.UNSIGNED5));
             out.write(encodeBandInt(contextStr + "_" + type + " cases_RU",  cpEntryListToArray(cases_RU), Codec.UNSIGNED5));
-            out.write(encodeBandInt(contextStr + "_" + type + " casearray_N",  listToArray(casearray_N), Codec.UNSIGNED5));
+            out.write(encodeBandInt(contextStr + "_" + type + " casearray_N",  casearray_N.toArray(), Codec.UNSIGNED5));
             out.write(encodeBandInt(contextStr + "_" + type + " nesttype_RS",  cpEntryListToArray(nesttype_RS), Codec.UNSIGNED5));
-            out.write(encodeBandInt(contextStr + "_" + type + " nestpair_N",  listToArray(nestpair_N), Codec.UNSIGNED5));
+            out.write(encodeBandInt(contextStr + "_" + type + " nestpair_N",  nestpair_N.toArray(), Codec.UNSIGNED5));
             out.write(encodeBandInt(contextStr + "_" + type + " nestname_RU",  cpEntryListToArray(nestname_RU), Codec.UNSIGNED5));
         }
     }
@@ -111,9 +122,21 @@
         return ints;
     }
 
+    /**
+     * Add an annotation to this set of bands
+     *
+     * @param desc
+     * @param nameRU
+     * @param t
+     * @param values
+     * @param caseArrayN
+     * @param nestTypeRS
+     * @param nestNameRU
+     * @param nestPairN
+     */
     public void addAnnotation(String desc, List nameRU, List t, List values, List caseArrayN, List nestTypeRS, List nestNameRU, List nestPairN) {
         type_RS.add(cpBands.getCPSignature(desc));
-        pair_N.add(new Integer(t.size()));
+        pair_N.add(t.size());
 
         for (Iterator iterator = nameRU.iterator(); iterator.hasNext();) {
             String name = (String) iterator.next();
@@ -152,9 +175,9 @@
             // do nothing here for [ or @ (handled below)
         }
         for (Iterator iterator = caseArrayN.iterator(); iterator.hasNext();) {
-            Integer arraySize = (Integer) iterator.next();
+            int arraySize = ((Integer)iterator.next()).intValue();
             casearray_N.add(arraySize);
-            numBackwardsCalls += arraySize.intValue();
+            numBackwardsCalls += arraySize;
         }
         for (Iterator iterator = nesttype_RS.iterator(); iterator.hasNext();) {
             String type = (String) iterator.next();
@@ -171,6 +194,9 @@
         }
     }
 
+    /**
+     * Returns true if any annotations have been added to this set of bands
+     */
     public boolean hasContent() {
         return type_RS.size() > 0;
     }
@@ -180,12 +206,62 @@
     }
 
     public void incrementAnnoN() {
-        Integer latest = (Integer)anno_N.remove(anno_N.size() -1);
-        anno_N.add(new Integer(latest.intValue() + 1));
+        anno_N.increment(anno_N.size() - 1);
     }
 
     public void newEntryInAnnoN() {
-        anno_N.add(new Integer(1));
+        anno_N.add(1);
+    }
+
+    /**
+     * Remove the latest annotation that was added to this group
+     */
+    public void removeLatest() {
+        int latest = anno_N.remove(anno_N.size() -1);
+        for (int i = 0; i < latest; i++) {
+            type_RS.remove(type_RS.size() - 1);
+            int pairs = pair_N.remove(pair_N.size() - 1);
+            for (int j = 0; j < pairs; j++) {
+                removeOnePair();
+            }
+        }
+    }
+
+    /*
+     * Convenience method for removeLatest
+     */
+    private void removeOnePair() {
+        String tag = (String) T.remove(T.size() - 1);
+        if (tag.equals("B") || tag.equals("C") || tag.equals("I")
+                || tag.equals("S") || tag.equals("Z")) {
+            caseI_KI.remove(caseI_KI.size() - 1);
+        } else if (tag.equals("D")) {
+            caseD_KD.remove(caseD_KD.size() - 1);
+        } else if (tag.equals("F")) {
+            caseF_KF.remove(caseF_KF.size() - 1);
+        } else if (tag.equals("J")) {
+            caseJ_KJ.remove(caseJ_KJ.size() - 1);
+        } else if (tag.equals("C")) {
+            casec_RS.remove(casec_RS.size() - 1);
+        } else if (tag.equals("e")) {
+            caseet_RS.remove(caseet_RS.size() - 1);
+            caseec_RU.remove(caseet_RS.size() - 1);
+        } else if (tag.equals("s")) {
+            cases_RU.remove(cases_RU.size() - 1);
+        } else if (tag.equals("[")) {
+            int arraySize = casearray_N.remove(casearray_N.size() - 1);
+            numBackwardsCalls -= arraySize;
+            for (int k = 0; k < arraySize; k++) {
+                removeOnePair();
+            }
+        } else if (tag.equals("@")) {
+            nesttype_RS.remove(nesttype_RS.size() - 1);
+            int numPairs = nestpair_N.remove(nestpair_N.size() - 1);
+            numBackwardsCalls -= numPairs;
+            for (int i = 0; i < numPairs; i++) {
+                removeOnePair();
+            }
+        }
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java Wed Jun 17 14:00:24 2009
@@ -22,7 +22,7 @@
 import org.objectweb.asm.ClassReader;
 
 /**
- * Wrapper for ClassReader than enables pack200 to obtain extra class file
+ * Wrapper for ClassReader that enables pack200 to obtain extra class file
  * information
  */
 public class Pack200ClassReader extends ClassReader {
@@ -30,6 +30,7 @@
     private boolean lastConstantHadWideIndex;
     private int lastUnsignedShort;
     private boolean anySyntheticAttributes;
+    private String fileName;
 
     /**
      * @param b
@@ -96,4 +97,12 @@
         return anySyntheticAttributes;
     }
 
+    public void setFileName(String name) {
+        this.fileName = name;
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java Wed Jun 17 14:00:24 2009
@@ -22,7 +22,7 @@
 
 /**
  * A PopulationCodec is a Codec that is well suited to encoding data that shows
- * statistical or repetetive patterns, containign for example a few numbers
+ * statistical or repetitive patterns, containing for example a few numbers
  * which are repeated a lot throughout the set, but not necessarily
  * sequentially.
  */
@@ -32,12 +32,12 @@
     private Codec tokenCodec;
     private final Codec unvafouredCodec;
     private int l;
-    private long[] favoured;
+    private int[] favoured;
 
-    public PopulationCodec(Codec favouredCodec, Codec tableCodec,
+    public PopulationCodec(Codec favouredCodec, Codec tokenCodec,
             Codec unvafouredCodec) {
         this.favouredCodec = favouredCodec;
-        this.tokenCodec = tableCodec;
+        this.tokenCodec = tokenCodec;
         this.unvafouredCodec = unvafouredCodec;
     }
 
@@ -49,26 +49,27 @@
         this.unvafouredCodec = unvafouredCodec;
     }
 
-    public long decode(InputStream in) throws IOException, Pack200Exception {
+    public int decode(InputStream in) throws IOException, Pack200Exception {
         throw new Pack200Exception(
                 "Population encoding does not work unless the number of elements are known");
     }
 
-    public long decode(InputStream in, long last) throws IOException,
+    public int decode(InputStream in, long last) throws IOException,
             Pack200Exception {
         throw new Pack200Exception(
                 "Population encoding does not work unless the number of elements are known");
     }
 
-    public long[] decode(int n, InputStream in) throws IOException,
+    public int[] decodeInts(int n, InputStream in) throws IOException,
             Pack200Exception {
-        favoured = new long[n]; // there must be <= n values, but probably a lot
+        lastBandLength = 0;
+        favoured = new int[n]; // there must be <= n values, but probably a lot
         // less
-        long result[];
+        int result[];
         // read table of favorites first
-        long smallest = Long.MAX_VALUE;
-        long last = 0;
-        long value = 0;
+        int smallest = Integer.MAX_VALUE;
+        int last = 0;
+        int value = 0;
         int k = -1;
         while (true) {
             value = favouredCodec.decode(in, last);
@@ -83,6 +84,7 @@
             }
             last = value;
         }
+        lastBandLength += k;
         // if tokenCodec needs to be derived from the T, L and K values
         if (tokenCodec == null) {
             if (k < 256) {
@@ -102,12 +104,14 @@
             }
         }
         // read favorites
-        result = tokenCodec.decode(n, in);
+        lastBandLength += n;
+        result = tokenCodec.decodeInts(n, in);
         // read unfavorites
         last = 0;
         for (int i = 0; i < n; i++) {
-            int index = (int) result[i];
+            int index = result[i];
             if (index == 0) {
+                lastBandLength++;
                 result[i] = last = unvafouredCodec.decode(in, last);
             } else {
                 result[i] = favoured[index - 1];
@@ -116,17 +120,7 @@
         return result;
     }
 
-    public int[] decodeInts(int n, InputStream in) throws IOException,
-            Pack200Exception {
-        long[] result = decode(n, in);
-        int[] intRes = new int[result.length];
-        for (int i = 0; i < intRes.length; i++) {
-            intRes[i] = (int) result[i];
-        }
-        return intRes;
-    }
-
-    public long[] getFavoured() {
+    public int[] getFavoured() {
         return favoured;
     }
 
@@ -138,14 +132,23 @@
         return unvafouredCodec;
     }
 
-    public byte[] encode(long value, long last) throws Pack200Exception {
-        // TODO Auto-generated method stub
-        return null;
+    public byte[] encode(int value, int last) throws Pack200Exception {
+        throw new Pack200Exception(
+        "Population encoding does not work unless the number of elements are known");
     }
 
-    public byte[] encode(long value) throws Pack200Exception {
-        // TODO Auto-generated method stub
-        return null;
+    public byte[] encode(int value) throws Pack200Exception {
+        throw new Pack200Exception(
+        "Population encoding does not work unless the number of elements are known");
+    }
+
+    public byte[] encode(int[] favoured, int[] tokens, int[] unfavoured) throws Pack200Exception {
+        byte[] favouredEncoded = favouredCodec.encode(favoured);
+        byte[] tokensEncoded = tokenCodec.encode(tokens);
+        byte[] unfavouredEncoded = unvafouredCodec.encode(unfavoured);
+        byte[] band = new byte[favouredEncoded.length + tokensEncoded.length + unfavouredEncoded.length];
+
+        return band;
     }
 
     public Codec getTokenCodec() {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java Wed Jun 17 14:00:24 2009
@@ -31,7 +31,7 @@
     private int k;
     private final Codec aCodec;
     private final Codec bCodec;
-    private long last;
+    private int last;
 
     public RunCodec(int k, Codec aCodec, Codec bCodec) throws Pack200Exception {
         if (k <= 0)
@@ -44,14 +44,14 @@
         this.bCodec = bCodec;
     }
 
-    public long decode(InputStream in) throws IOException, Pack200Exception {
+    public int decode(InputStream in) throws IOException, Pack200Exception {
         return decode(in, this.last);
     }
 
-    public long decode(InputStream in, long last) throws IOException,
+    public int decode(InputStream in, long last) throws IOException,
             Pack200Exception {
         if (--k >= 0) {
-            long value = aCodec.decode(in, this.last);
+            int value = aCodec.decode(in, this.last);
             this.last = (k == 0 ? 0 : value);
             return normalise(aCodec, value);
         } else {
@@ -60,7 +60,7 @@
         }
     }
 
-    private long normalise(Codec codecUsed, long value) {
+    private int normalise(Codec codecUsed, int value) {
         if (codecUsed instanceof BHSDCodec && ((BHSDCodec) codecUsed).isDelta()) {
             BHSDCodec bhsd = (BHSDCodec) codecUsed;
             long cardinality = bhsd.cardinality();
@@ -83,6 +83,7 @@
         normalise(bValues, bCodec);
         System.arraycopy(aValues, 0, band, 0, k);
         System.arraycopy(bValues, 0, band, k, n - k);
+        lastBandLength = aCodec.lastBandLength + bCodec.lastBandLength;
         return band;
     }
 
@@ -100,7 +101,7 @@
             }
         } else if (codecUsed instanceof PopulationCodec) {
             PopulationCodec popCodec = (PopulationCodec) codecUsed;
-            long[] favoured = (long[]) popCodec.getFavoured().clone();
+            int[] favoured = (int[]) popCodec.getFavoured().clone();
             Arrays.sort(favoured);
             for (int i = 0; i < band.length; i++) {
                 boolean favouredValue = Arrays.binarySearch(favoured, band[i]) > -1;
@@ -126,12 +127,12 @@
                 + "]";
     }
 
-    public byte[] encode(long value, long last) throws Pack200Exception {
+    public byte[] encode(int value, int last) throws Pack200Exception {
         // TODO Auto-generated method stub
         return null;
     }
 
-    public byte[] encode(long value) throws Pack200Exception {
+    public byte[] encode(int value) throws Pack200Exception {
         // TODO Auto-generated method stub
         return null;
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java Wed Jun 17 14:00:24 2009
@@ -16,12 +16,14 @@
  */
 package org.apache.harmony.pack200;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.harmony.pack200.Archive.File;
 import org.objectweb.asm.AnnotationVisitor;
 import org.objectweb.asm.Attribute;
 import org.objectweb.asm.ClassReader;
@@ -31,6 +33,9 @@
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Type;
 
+/**
+ * A Pack200 archive consists of one or more Segments.
+ */
 public class Segment implements ClassVisitor {
 
     private SegmentHeader segmentHeader;
@@ -44,24 +49,43 @@
     private final SegmentFieldVisitor fieldVisitor = new SegmentFieldVisitor();
     private final SegmentMethodVisitor methodVisitor = new SegmentMethodVisitor();
     private Pack200ClassReader currentClassReader;
+    private PackingOptions options;
     private boolean stripDebug;
-    private int effort;
+    private Attribute[] nonStandardAttributePrototypes;
 
-    public void pack(List classes, List files, OutputStream out, boolean stripDebug, int effort)
+    /**
+     * The main method on Segment. Reads in all the class files, packs them and
+     * then writes the packed segment out to the given OutputStream.
+     *
+     * @param classes
+     *            List of Pack200ClassReaders, one for each class file in the
+     *            segment
+     * @param files
+     *            List of Archive.Files, one for each file in the segment
+     * @param out
+     *            the OutputStream to write the packed Segment to
+     * @param options
+     *            packing options
+     * @throws IOException
+     * @throws Pack200Exception
+     */
+    public void pack(List classes, List files, OutputStream out, PackingOptions options)
             throws IOException, Pack200Exception {
-        this.effort = effort;
-        this.stripDebug = stripDebug;
+        this.options = options;
+        this.stripDebug = options.isStripDebug();
+        int effort = options.getEffort();
+        nonStandardAttributePrototypes = options.getUnknownAttributePrototypes();
         segmentHeader = new SegmentHeader();
         segmentHeader.setFile_count(files.size());
         segmentHeader.setHave_all_code_flags(!stripDebug);
         cpBands = new CpBands(this, effort);
-        attributeDefinitionBands = new AttributeDefinitionBands(this, effort);
+        attributeDefinitionBands = new AttributeDefinitionBands(this, effort, nonStandardAttributePrototypes);
         icBands = new IcBands(segmentHeader, cpBands, effort);
-        classBands = new ClassBands(this, classes.size(), effort);
+        classBands = new ClassBands(this, classes.size(), effort, stripDebug);
         bcBands = new BcBands(cpBands, this, effort);
         fileBands = new FileBands(cpBands, segmentHeader, files, classes, effort);
 
-        processClasses(classes);
+        processClasses(classes, files);
 
         cpBands.finaliseBands();
         attributeDefinitionBands.finaliseBands();
@@ -70,26 +94,54 @@
         bcBands.finaliseBands();
         fileBands.finaliseBands();
 
+        // Using a temporary stream because we have to pack the other bands
+        // before segmentHeader because the band_headers band is only created
+        // when the other bands are packed, but comes before them in the packed
+        // file.
+        ByteArrayOutputStream tempStream = new ByteArrayOutputStream();
+
+        cpBands.pack(tempStream);
+        attributeDefinitionBands.pack(tempStream);
+        icBands.pack(tempStream);
+        classBands.pack(tempStream);
+        bcBands.pack(tempStream);
+        fileBands.pack(tempStream);
+
         segmentHeader.pack(out);
-        cpBands.pack(out);
-        attributeDefinitionBands.pack(out);
-        icBands.pack(out);
-        classBands.pack(out);
-        bcBands.pack(out);
-        fileBands.pack(out);
+        tempStream.writeTo(out);
     }
 
-    private void processClasses(List classes) {
+    private void processClasses(List classes, List files) throws Pack200Exception {
         segmentHeader.setClass_count(classes.size());
         for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
             Pack200ClassReader classReader = (Pack200ClassReader) iterator
                     .next();
             currentClassReader = classReader;
-            int flags = ClassReader.SKIP_FRAMES;
+            int flags = 0;
             if(stripDebug) {
                 flags |= ClassReader.SKIP_DEBUG;
             }
-            classReader.accept(this, flags);
+            try {
+                classReader.accept(this, flags);
+            } catch (PassException pe) {
+                // Pass this class through as-is rather than packing it
+                // TODO: probably need to deal with any inner classes
+                classBands.removeCurrentClass();
+                String name = classReader.getFileName();
+                boolean found = false;
+                for (Iterator iterator2 = files.iterator(); iterator2
+                        .hasNext();) {
+                    File file = (File) iterator2.next();
+                    if(file.getName().equals(name)) {
+                        found = true;
+                        file.setContents(classReader.b);
+                        break;
+                    }
+                }
+                if(!found) {
+                    throw new Pack200Exception("Error passing file " + name);
+                }
+            }
         }
     }
 
@@ -117,7 +169,30 @@
                 desc, visible);
     }
 
-    public void visitAttribute(Attribute arg0) {
+    public void visitAttribute(Attribute attribute) {
+        if(attribute.isUnknown()) {
+            String action = options.getUnknownAttributeAction();
+            if(action.equals(PackingOptions.PASS)) {
+                passCurrentClass();
+            } else if (action.equals(PackingOptions.ERROR)) {
+                throw new Error("Unknown attribute encountered");
+            } // else skip
+        } else {
+            if(attribute instanceof NewAttribute) {
+                NewAttribute newAttribute = (NewAttribute) attribute;
+                if(newAttribute.isUnknown(AttributeDefinitionBands.CONTEXT_CLASS)) {
+                    String action = options.getUnknownClassAttributeAction(newAttribute.type);
+                    if(action.equals(PackingOptions.PASS)) {
+                        passCurrentClass();
+                    } else if (action.equals(PackingOptions.ERROR)) {
+                        throw new Error("Unknown attribute encountered");
+                    } // else skip
+                }
+                classBands.addClassAttribute(newAttribute);
+            } else {
+                throw new RuntimeException("Unexpected attribute encountered: " + attribute.type);
+            }
+        }
     }
 
     public void visitInnerClass(String name, String outerName,
@@ -141,9 +216,12 @@
         classBands.endOfClass();
     }
 
-    /*
-     * This class delegates to BcBands for bytecode related visits and to
-     * ClassBands for everything else
+    /**
+     * This class implements MethodVisitor to visit the contents and metadata
+     * related to methods in a class file.
+     *
+     * It delegates to BcBands for bytecode related visits and to ClassBands for
+     * everything else.
      */
     public class SegmentMethodVisitor implements MethodVisitor {
 
@@ -156,17 +234,53 @@
             return new SegmentAnnotationVisitor(MetadataBandGroup.CONTEXT_METHOD);
         }
 
-        public void visitAttribute(Attribute arg0) {
-            classBands.addUnknownMethodAttribute(arg0);
+        public void visitAttribute(Attribute attribute) {
+            if(attribute.isUnknown()) {
+                String action = options.getUnknownAttributeAction();
+                if(action.equals(PackingOptions.PASS)) {
+                    passCurrentClass();
+                } else if (action.equals(PackingOptions.ERROR)) {
+                    throw new Error("Unknown attribute encountered");
+                } // else skip
+            } else {
+                if(attribute instanceof NewAttribute) {
+                    NewAttribute newAttribute = (NewAttribute) attribute;
+                    if (attribute.isCodeAttribute()) {
+                        if (newAttribute.isUnknown(AttributeDefinitionBands.CONTEXT_CODE)) {
+                            String action = options
+                                    .getUnknownCodeAttributeAction(newAttribute.type);
+                            if (action.equals(PackingOptions.PASS)) {
+                                passCurrentClass();
+                            } else if (action.equals(PackingOptions.ERROR)) {
+                                throw new Error("Unknown attribute encountered");
+                            } // else skip
+                        }
+                        classBands.addCodeAttribute(newAttribute);
+                    } else {
+                        if (newAttribute.isUnknown(AttributeDefinitionBands.CONTEXT_METHOD)) {
+                            String action = options
+                                    .getUnknownMethodAttributeAction(newAttribute.type);
+                            if (action.equals(PackingOptions.PASS)) {
+                                passCurrentClass();
+                            } else if (action.equals(PackingOptions.ERROR)) {
+                                throw new Error("Unknown attribute encountered");
+                            } // else skip
+                        }
+                        classBands.addMethodAttribute(newAttribute);
+                    }
+                } else {
+                    throw new RuntimeException("Unexpected attribute encountered: " + attribute.type);
+                }
+            }
         }
 
         public void visitCode() {
-            classBands.addCode(stripDebug);
+            classBands.addCode();
         }
 
         public void visitFrame(int arg0, int arg1, Object[] arg2, int arg3,
                 Object[] arg4) {
-            // TODO Auto-generated method stub
+            // TODO: Java 6 - implement support for this
 
         }
 
@@ -265,6 +379,10 @@
         return classBands;
     }
 
+    /**
+     * SegmentAnnotationVisitor implements <code>AnnotationVisitor</code> to
+     * visit Annotations found in a class file.
+     */
     public class SegmentAnnotationVisitor implements AnnotationVisitor {
 
         private int context = -1;
@@ -280,7 +398,6 @@
         private final List nestNameRU = new ArrayList();
         private final List nestPairN = new ArrayList();
 
-
         public SegmentAnnotationVisitor(int context, String desc,
                 boolean visible) {
             this.context = context;
@@ -362,7 +479,6 @@
                 }
 
                 public void visitEnd() {
-                    throw new RuntimeException("Not yet supported");
                 }
 
                 public void visitEnum(String name, String desc, String value) {
@@ -443,6 +559,10 @@
         }
     }
 
+    /**
+     * SegmentFieldVisitor implements <code>FieldVisitor</code> to visit the
+     * metadata relating to fields in a class file.
+     */
     public class SegmentFieldVisitor implements FieldVisitor {
 
         public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
@@ -450,8 +570,30 @@
                     desc, visible);
         }
 
-        public void visitAttribute(Attribute arg0) {
-            classBands.addUnknownFieldAttribute(arg0);
+        public void visitAttribute(Attribute attribute) {
+            if(attribute.isUnknown()) {
+                String action = options.getUnknownAttributeAction();
+                if(action.equals(PackingOptions.PASS)) {
+                    passCurrentClass();
+                } else if (action.equals(PackingOptions.ERROR)) {
+                    throw new Error("Unknown attribute encountered");
+                } // else skip
+            } else {
+                if(attribute instanceof NewAttribute) {
+                    NewAttribute newAttribute = (NewAttribute) attribute;
+                    if(newAttribute.isUnknown(AttributeDefinitionBands.CONTEXT_FIELD)) {
+                        String action = options.getUnknownFieldAttributeAction(newAttribute.type);
+                        if(action.equals(PackingOptions.PASS)) {
+                            passCurrentClass();
+                        } else if (action.equals(PackingOptions.ERROR)) {
+                            throw new Error("Unknown attribute encountered");
+                        } // else skip
+                    }
+                    classBands.addFieldAttribute(newAttribute);
+                } else {
+                    throw new RuntimeException("Unexpected attribute encountered: " + attribute.type);
+                }
+            }
         }
 
         public void visitEnd() {
@@ -481,4 +623,18 @@
     public Pack200ClassReader getCurrentClassReader() {
         return currentClassReader;
     }
+
+    private void passCurrentClass() {
+        throw new PassException();
+    }
+
+    /**
+     * Exception indicating that the class currently being visited contains an
+     * unknown attribute, which means that by default the class file needs to be
+     * passed through as-is in the file_bands rather than being packed with
+     * pack200.
+     */
+    public class PassException extends RuntimeException {
+
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java Wed Jun 17 14:00:24 2009
@@ -20,12 +20,17 @@
 import java.io.OutputStream;
 
 /**
- * SegmentHeader is the header band of a {@link Segment}
+ * SegmentHeader is the header band of a {@link Segment}. Corresponds to
+ * <code>segment_header</code> in the pack200 specification.
  */
 public class SegmentHeader extends BandSet {
 
+    /**
+     * Create a new SegmentHeader
+     */
     public SegmentHeader() {
-        super(1, null); // Don't do anything special for the header
+        super(1, null); // Pass 1 for effort because bands in the segment header
+                        // should always use the default encoding
     }
 
     private static final int[] magic = { 0xCA, 0xFE, 0xD0, 0x0D };

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java Wed Jun 17 14:00:24 2009
@@ -34,9 +34,9 @@
 
 /**
  * Archive is the main entry point to unpack200. An archive is constructed with
- * either two file names, a pack file and an output file name or two input
- * streams corresponding to the input and the output streams. Then
- * <code>unpack()</code> is called, to unpack the pack200 archive.
+ * either two file names, a pack file and an output file name or an input stream
+ * and an output streams. Then <code>unpack()</code> is called, to unpack the
+ * pack200 archive.
  */
 public class Archive {
 

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java Wed Jun 17 14:00:24 2009
@@ -84,6 +84,10 @@
     public int[] decodeBandInt(String name, InputStream in, BHSDCodec codec,
             int count) throws IOException, Pack200Exception {
         int[] band;
+        // Useful for debugging
+//        if(count > 0) {
+//            System.out.println("decoding " + name + " " + count);
+//        }
         Codec codecUsed = codec;
         if (codec.getB() == 1 || count == 0) {
             return codec.decodeInts(count, in);
@@ -108,20 +112,14 @@
             // First element should not be discarded
             band = codec.decodeInts(count - 1, in, first);
         }
-        if (codecUsed instanceof BHSDCodec && ((BHSDCodec) codecUsed).isDelta()) {
-            BHSDCodec bhsd = (BHSDCodec) codecUsed;
-            long cardinality = bhsd.cardinality();
-            for (int i = 0; i < band.length; i++) {
-                while (band[i] > bhsd.largest()) {
-                    band[i] -= cardinality;
-                }
-                while (band[i] < bhsd.smallest()) {
-                    band[i] += cardinality;
-                }
-            }
-        } else if (codecUsed instanceof PopulationCodec) {
+        // Useful for debugging -E options:
+        //if(!codecUsed.equals(codec)) {
+        //    int bytes = codecUsed.lastBandLength;
+        //    System.out.println(count + " " + name + " encoded with " + codecUsed + " "  + bytes);
+        //}
+        if (codecUsed instanceof PopulationCodec) {
             PopulationCodec popCodec = (PopulationCodec) codecUsed;
-            long[] favoured = (long[]) popCodec.getFavoured().clone();
+            int[] favoured = (int[]) popCodec.getFavoured().clone();
             Arrays.sort(favoured);
             for (int i = 0; i < band.length; i++) {
                 boolean favouredValue = Arrays.binarySearch(favoured, band[i]) > -1;

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java Wed Jun 17 14:00:24 2009
@@ -127,9 +127,6 @@
     /**
      * Resolve calls in the attribute layout and returns the number of backwards
      * calls
-     *
-     * @param tokens -
-     *            the attribute layout as a List of AttributeElements
      */
     private void resolveCalls() {
         int backwardsCalls = 0;
@@ -201,6 +198,7 @@
 
     private AttributeLayoutElement readNextAttributeElement(StringReader stream)
             throws IOException {
+        stream.mark(1);
         int nextChar = stream.read();
         if (nextChar == -1) {
             return null;
@@ -209,6 +207,7 @@
             List body = readBody(getStreamUpToMatchingBracket(stream));
             return new Callable(body);
         } else {
+            stream.reset();
             return readNextLayoutElement(stream);
         }
     }
@@ -368,7 +367,6 @@
 
         protected int getLength(char uint_type) {
             int length = 0;
-            ;
             switch (uint_type) {
             case 'B':
                 length = 1;
@@ -428,7 +426,7 @@
                 int length = getLength(uint_type);
                 attribute.addBCIndex(length, (int) value);
             } else if (tag.startsWith("OS")) {
-                char uint_type = tag.substring(1).toCharArray()[0];
+                char uint_type = tag.substring(2).toCharArray()[0];
                 int length = getLength(uint_type);
                 if (length == 1) {
                     value = (byte) value;

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java Wed Jun 17 14:00:24 2009
@@ -103,16 +103,16 @@
     public void read(InputStream in) throws IOException, Pack200Exception,
             Error, Pack200Exception {
 
-        long word[] = decodeScalar("archive_magic_word", in, Codec.BYTE1,
+        int word[] = decodeScalar("archive_magic_word", in, Codec.BYTE1,
                 magic.length);
         for (int m = 0; m < magic.length; m++)
             if (word[m] != magic[m])
                 throw new Error("Bad header");
-        setArchiveMinorVersion((int) decodeScalar("archive_minver", in,
+        setArchiveMinorVersion(decodeScalar("archive_minver", in,
                 Codec.UNSIGNED5));
-        setArchiveMajorVersion((int) decodeScalar("archive_majver", in,
+        setArchiveMajorVersion(decodeScalar("archive_majver", in,
                 Codec.UNSIGNED5));
-        options = new SegmentOptions((int) decodeScalar("archive_options", in,
+        options = new SegmentOptions(decodeScalar("archive_options", in,
                 Codec.UNSIGNED5));
         parseArchiveFileCounts(in);
         parseArchiveSpecialCounts(in);
@@ -290,7 +290,7 @@
                     Codec.UNSIGNED5));
             setArchiveModtime(decodeScalar("archive_modtime", in,
                     Codec.UNSIGNED5));
-            numberOfFiles = (int) decodeScalar("file_count", in,
+            numberOfFiles = decodeScalar("file_count", in,
                     Codec.UNSIGNED5);
         }
     }
@@ -298,7 +298,7 @@
     private void parseArchiveSpecialCounts(InputStream in) throws IOException,
             Pack200Exception {
         if (getOptions().hasSpecialFormats()) {
-            bandHeadersSize = (int) decodeScalar("band_headers_size", in,
+            bandHeadersSize = decodeScalar("band_headers_size", in,
                     Codec.UNSIGNED5);
             setAttributeDefinitionCount(decodeScalar("attr_definition_count",
                     in, Codec.UNSIGNED5));
@@ -307,37 +307,37 @@
 
     private void parseClassCounts(InputStream in) throws IOException,
             Pack200Exception {
-        innerClassCount = (int) decodeScalar("ic_count", in, Codec.UNSIGNED5);
-        defaultClassMinorVersion = (int) decodeScalar("default_class_minver",
+        innerClassCount = decodeScalar("ic_count", in, Codec.UNSIGNED5);
+        defaultClassMinorVersion = decodeScalar("default_class_minver",
                 in, Codec.UNSIGNED5);
-        defaultClassMajorVersion = (int) decodeScalar("default_class_majver",
+        defaultClassMajorVersion = decodeScalar("default_class_majver",
                 in, Codec.UNSIGNED5);
-        classCount = (int) decodeScalar("class_count", in, Codec.UNSIGNED5);
+        classCount = decodeScalar("class_count", in, Codec.UNSIGNED5);
     }
 
     private void parseCpCounts(InputStream in) throws IOException,
             Pack200Exception {
-        cpUTF8Count = (int) decodeScalar("cp_Utf8_count", in, Codec.UNSIGNED5);
+        cpUTF8Count = decodeScalar("cp_Utf8_count", in, Codec.UNSIGNED5);
         if (getOptions().hasCPNumberCounts()) {
-            cpIntCount = (int) decodeScalar("cp_Int_count", in, Codec.UNSIGNED5);
-            cpFloatCount = (int) decodeScalar("cp_Float_count", in,
+            cpIntCount = decodeScalar("cp_Int_count", in, Codec.UNSIGNED5);
+            cpFloatCount = decodeScalar("cp_Float_count", in,
                     Codec.UNSIGNED5);
-            cpLongCount = (int) decodeScalar("cp_Long_count", in,
+            cpLongCount = decodeScalar("cp_Long_count", in,
                     Codec.UNSIGNED5);
-            cpDoubleCount = (int) decodeScalar("cp_Double_count", in,
+            cpDoubleCount = decodeScalar("cp_Double_count", in,
                     Codec.UNSIGNED5);
         }
-        cpStringCount = (int) decodeScalar("cp_String_count", in,
+        cpStringCount = decodeScalar("cp_String_count", in,
                 Codec.UNSIGNED5);
-        cpClassCount = (int) decodeScalar("cp_Class_count", in, Codec.UNSIGNED5);
-        cpSignatureCount = (int) decodeScalar("cp_Signature_count", in,
+        cpClassCount = decodeScalar("cp_Class_count", in, Codec.UNSIGNED5);
+        cpSignatureCount = decodeScalar("cp_Signature_count", in,
                 Codec.UNSIGNED5);
-        cpDescriptorCount = (int) decodeScalar("cp_Descr_count", in,
+        cpDescriptorCount = decodeScalar("cp_Descr_count", in,
                 Codec.UNSIGNED5);
-        cpFieldCount = (int) decodeScalar("cp_Field_count", in, Codec.UNSIGNED5);
-        cpMethodCount = (int) decodeScalar("cp_Method_count", in,
+        cpFieldCount = decodeScalar("cp_Field_count", in, Codec.UNSIGNED5);
+        cpMethodCount = decodeScalar("cp_Method_count", in,
                 Codec.UNSIGNED5);
-        cpIMethodCount = (int) decodeScalar("cp_Imethod_count", in,
+        cpIMethodCount = decodeScalar("cp_Imethod_count", in,
                 Codec.UNSIGNED5);
     }
 
@@ -360,11 +360,11 @@
      *             if there is a problem decoding the value or that the value is
      *             invalid
      */
-    private long[] decodeScalar(String name, InputStream in, BHSDCodec codec,
+    private int[] decodeScalar(String name, InputStream in, BHSDCodec codec,
             int n) throws IOException, Pack200Exception {
         segment.log(Segment.LOG_LEVEL_VERBOSE, "Parsed #" + name + " (" + n
                 + ")");
-        return codec.decode(n, in);
+        return codec.decodeInts(n, in);
     }
 
     /**
@@ -386,9 +386,9 @@
      *             if there is a problem decoding the value or that the value is
      *             invalid
      */
-    private long decodeScalar(String name, InputStream in, BHSDCodec codec)
+    private int decodeScalar(String name, InputStream in, BHSDCodec codec)
             throws IOException, Pack200Exception {
-        long ret = codec.decode(in);
+        int ret = codec.decode(in);
         segment
                 .log(Segment.LOG_LEVEL_VERBOSE, "Parsed #" + name + " as "
                         + ret);

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/BCIRenumberedAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/BCIRenumberedAttribute.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/BCIRenumberedAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/BCIRenumberedAttribute.java Wed Jun 17 14:00:24 2009
@@ -60,6 +60,7 @@
      *
      * @param byteCodeOffsets
      *            List of Integer offsets of the bytecode array
+     * @throws Pack200Exception
      */
     public void renumber(List byteCodeOffsets) throws Pack200Exception {
         if (renumbered) {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java Wed Jun 17 14:00:24 2009
@@ -343,6 +343,9 @@
      * after all the bytecodes in the CodeAttribute have been added. (This can't
      * be done beforehand because the CodeAttribute needs to be complete before
      * targets can be assigned.)
+     *
+     * @param codeAttribute
+     *            the code attribute
      */
     public void applyByteCodeTargetFixup(CodeAttribute codeAttribute) {
         getByteCodeForm().fixUpByteCodeTargets(this, codeAttribute);

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPClass.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPClass.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPClass.java Wed Jun 17 14:00:24 2009
@@ -34,6 +34,8 @@
      * Creates a new CPClass
      *
      * @param name
+     * @param globalIndex
+     *            index in CpBands
      * @throws NullPointerException
      *             if name is null
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPConstant.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPConstant.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPConstant.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPConstant.java Wed Jun 17 14:00:24 2009
@@ -29,6 +29,8 @@
      *
      * @param tag
      * @param value
+     * @param globalIndex
+     *            index in CpBands
      * @throws NullPointerException
      *             if value is null
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPNameAndType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPNameAndType.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPNameAndType.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPNameAndType.java Wed Jun 17 14:00:24 2009
@@ -39,7 +39,7 @@
      *
      * @param name
      * @param descriptor
-     * @param domain
+     * @param globalIndex - index in CpBands
      * @throws NullPointerException
      *             if name or descriptor is null
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPRef.java Wed Jun 17 14:00:24 2009
@@ -37,6 +37,8 @@
      * @param type
      * @param className
      * @param descriptor
+     * @param globalIndex
+     *            index in CpBands
      * @throws NullPointerException
      *             if descriptor or className is null
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPUTF8.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPUTF8.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPUTF8.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CPUTF8.java Wed Jun 17 14:00:24 2009
@@ -30,7 +30,7 @@
      * Creates a new CPUTF8 instance
      *
      * @param utf8
-     * @param domain
+     * @param globalIndex - index in CpBands
      * @throws NullPointerException
      *             if utf8 is null
      */

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -0,0 +1 @@
+/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java:782694-785553

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -0,0 +1 @@
+/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java:782694-785553

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200UnpackerAdapter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200UnpackerAdapter.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200UnpackerAdapter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200UnpackerAdapter.java Wed Jun 17 14:00:24 2009
@@ -24,6 +24,7 @@
 import java.util.jar.JarOutputStream;
 import java.util.jar.Pack200.Unpacker;
 
+import org.apache.harmony.pack200.Pack200Adapter;
 import org.apache.harmony.pack200.Pack200Exception;
 
 /**

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java Wed Jun 17 14:00:24 2009
@@ -34,6 +34,7 @@
 
 import org.apache.harmony.pack200.Archive;
 import org.apache.harmony.pack200.Pack200Exception;
+import org.apache.harmony.pack200.PackingOptions;
 import org.apache.harmony.unpack200.Segment;
 
 public class ArchiveTest extends TestCase {
@@ -47,7 +48,7 @@
                 "/org/apache/harmony/pack200/tests/hw.jar").toURI()));
         file = File.createTempFile("helloworld", ".pack.gz");
         out = new FileOutputStream(file);
-        new Archive(in, out, true).pack();
+        new Archive(in, out, null).pack();
         in.close();
         out.close();
 
@@ -97,7 +98,10 @@
                 "/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
         file = File.createTempFile("sql", ".pack");
         out = new FileOutputStream(file);
-        new Archive(in, out, false).pack();
+        PackingOptions options = new PackingOptions();
+        options.setGzip(false);
+        Archive ar = new Archive(in, out, options);
+        ar.pack();
         in.close();
         out.close();
 
@@ -125,7 +129,9 @@
                 .toURI()));
         file = File.createTempFile("largeClass", ".pack");
         out = new FileOutputStream(file);
-        new Archive(in, out, false).pack();
+        PackingOptions options = new PackingOptions();
+        options.setGzip(false);
+        new Archive(in, out, options).pack();
         in.close();
         out.close();
 
@@ -152,7 +158,9 @@
                 "/org/apache/harmony/pack200/tests/jndi.jar").toURI()));
         file = File.createTempFile("jndi", ".pack");
         out = new FileOutputStream(file);
-        new Archive(in, out, false).pack();
+        PackingOptions options = new PackingOptions();
+        options.setGzip(false);
+        new Archive(in, out, options).pack();
         in.close();
         out.close();
 
@@ -176,8 +184,9 @@
                 "/org/apache/harmony/pack200/tests/hw.jar").toURI()));
         file = File.createTempFile("helloworld", ".pack.gz");
         out = new FileOutputStream(file);
-        Archive archive = new Archive(in, out, true);
-        archive.setSegmentLimit(0);
+        PackingOptions options = new PackingOptions();
+        options.setSegmentLimit(0);
+        Archive archive = new Archive(in, out, options);
         archive.pack();
         in.close();
         out.close();
@@ -186,8 +195,9 @@
                 "/org/apache/harmony/pack200/tests/hw.jar").toURI()));
         file = File.createTempFile("helloworld", ".pack.gz");
         out = new FileOutputStream(file);
-        archive = new Archive(in, out, true);
-        archive.setSegmentLimit(-1);
+        options = new PackingOptions();
+        options.setSegmentLimit(-1);
+        archive = new Archive(in, out, options);
         archive.pack();
         in.close();
         out.close();
@@ -196,8 +206,9 @@
                 "/org/apache/harmony/pack200/tests/hw.jar").toURI()));
         file = File.createTempFile("helloworld", ".pack.gz");
         out = new FileOutputStream(file);
-        archive = new Archive(in, out, true);
-        archive.setSegmentLimit(5000);
+        options = new PackingOptions();
+        options.setSegmentLimit(5000);
+        archive = new Archive(in, out, options);
         archive.pack();
         in.close();
         out.close();
@@ -208,8 +219,10 @@
                 .getResource("/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
         file = File.createTempFile("sql", ".pack");
         out = new FileOutputStream(file);
-        Archive archive = new Archive(in, out, false);
-        archive.stripDebugAttributes();
+        PackingOptions options = new PackingOptions();
+        options.setGzip(false);
+        options.setStripDebug(true);
+        Archive archive = new Archive(in, out, options);
         archive.pack();
         in.close();
         out.close();
@@ -239,7 +252,9 @@
                 .toURI()));
         file = File.createTempFile("annotations", ".pack");
         out = new FileOutputStream(file);
-        new Archive(in, out, false).pack();
+        PackingOptions options = new PackingOptions();
+        options.setGzip(false);
+        new Archive(in, out, options).pack();
         in.close();
         out.close();
 
@@ -264,8 +279,10 @@
         in = new JarFile(f1);
         file = File.createTempFile("jndiE0", ".pack");
         out = new FileOutputStream(file);
-        Archive archive = new Archive(in, out, false);
-        archive.setEffort(0);
+        PackingOptions options = new PackingOptions();
+        options.setGzip(false);
+        options.setEffort(0);
+        Archive archive = new Archive(in, out, options);
         archive.pack();
         in.close();
         out.close();
@@ -298,7 +315,7 @@
 				file = File.createTempFile("temp", ".pack.gz");
 		        out = new FileOutputStream(file);
 //		        System.out.println("packing " + children[i]);
-		        new Archive(in, out, true).pack();
+		        new Archive(in, out, null).pack();
 		        in.close();
 		        out.close();
 
@@ -319,6 +336,7 @@
             String name = entry.getName();
             JarEntry entry2 = jarFile2.getJarEntry(name);
             assertNotNull("Missing Entry: " + name, entry2);
+//            assertEquals(entry.getTime(), entry2.getTime());
             if (!name.equals("META-INF/MANIFEST.MF")) { // Manifests aren't
                                                         // necessarily
                                                         // byte-for-byte

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java Wed Jun 17 14:00:24 2009
@@ -42,9 +42,13 @@
                 // range of the codec
                 long largest = codec.largest();
                 long smallest = codec.isSigned() ? codec.smallest() : 0;
+                if(smallest < Integer.MIN_VALUE) smallest = Integer.MIN_VALUE;
                 long difference = (largest - smallest) / 4;
                 for (long j = smallest; j <= largest; j += difference) {
-                    byte[] encoded = codec.encode(j, 0);
+                    if(j > Integer.MAX_VALUE) {
+                        break;
+                    }
+                    byte[] encoded = codec.encode((int)j, 0);
                     long decoded = 0;
                     try {
                         decoded = codec.decode(

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java Wed Jun 17 14:00:24 2009
@@ -23,6 +23,7 @@
 import junit.framework.TestCase;
 
 import org.apache.harmony.pack200.BHSDCodec;
+import org.apache.harmony.pack200.CanonicalCodecFamilies;
 import org.apache.harmony.pack200.Codec;
 import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.RunCodec;
@@ -203,8 +204,6 @@
                 (byte) 255, (byte) 191 }, 51130559, 0);
         decode(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
                 (byte) 192, (byte) 192, 0 }, 51130560, 0);
-        decode(Codec.UNSIGNED5, new byte[] { (byte) 255, (byte) 252,
-                (byte) 252, (byte) 252, (byte) 252 }, 0xFFFFFFFFL, 0);
         decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192 });
         decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192 });
         decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
@@ -212,6 +211,27 @@
         decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
                 (byte) 192, (byte) 192 });
     }
+    public void testCodecFamilies() {
+        checkAscendingCardinalities(CanonicalCodecFamilies.nonDeltaUnsignedCodecs1);
+        checkAscendingCardinalities(CanonicalCodecFamilies.nonDeltaUnsignedCodecs2);
+        checkAscendingCardinalities(CanonicalCodecFamilies.nonDeltaUnsignedCodecs3);
+        checkAscendingCardinalities(CanonicalCodecFamilies.nonDeltaUnsignedCodecs4);
+        checkAscendingCardinalities(CanonicalCodecFamilies.nonDeltaUnsignedCodecs5);
+        checkAscendingCardinalities(CanonicalCodecFamilies.deltaUnsignedCodecs1);
+        checkAscendingCardinalities(CanonicalCodecFamilies.deltaUnsignedCodecs2);
+        checkAscendingCardinalities(CanonicalCodecFamilies.deltaUnsignedCodecs3);
+        checkAscendingCardinalities(CanonicalCodecFamilies.deltaUnsignedCodecs4);
+        checkAscendingCardinalities(CanonicalCodecFamilies.deltaUnsignedCodecs5);
+    }
+
+    private void checkAscendingCardinalities(BHSDCodec[] family) {
+        for (int i = 1; i < family.length; i++) {
+            BHSDCodec previous = family[i-1];
+            BHSDCodec codec = family[i];
+            assertTrue(codec.largest() >= previous.largest());
+            assertTrue(codec.smallest() <= previous.smallest());
+        }
+    }
 
     private void decodeFail(final Codec codec, final byte[] data)
             throws IOException, Pack200Exception {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java Wed Jun 17 14:00:24 2009
@@ -55,7 +55,7 @@
             throws IOException, Pack200Exception {
         InputStream in = new ByteArrayInputStream(data);
 
-        long[] result = new PopulationCodec(codec, codec, codec).decode(
+        int[] result = new PopulationCodec(codec, codec, codec).decodeInts(
                 expectedResult.length, in);
         assertEquals(expectedResult.length, result.length);
         for (int i = 0; i < expectedResult.length; i++) {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ClassBandsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ClassBandsTest.java?rev=785606&r1=785605&r2=785606&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ClassBandsTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ClassBandsTest.java Wed Jun 17 14:00:24 2009
@@ -92,8 +92,8 @@
         byte[] classThis = Codec.DELTA5.encode(1, 0);
         byte[] classSuper = Codec.DELTA5.encode(2, 0);
         byte[] classInterfaceCount = Codec.DELTA5.encode(2, 0);
-        byte[] classInterfaceRef1 = encodeBandLong(
-                new long[] { 3, 4 }, Codec.DELTA5);
+        byte[] classInterfaceRef1 = encodeBandInt(
+                new int[] { 3, 4 }, Codec.DELTA5);
         byte[] classFieldCount = Codec.DELTA5.encode(0, 0);
         byte[] classMethodCount = Codec.DELTA5.encode(0, 0);
         byte[] classFlags = Codec.UNSIGNED5.encode(0, 0);
@@ -132,10 +132,10 @@
         byte[] classInterfaceCount = Codec.DELTA5.encode(0, 0);
         byte[] classFieldCount = Codec.DELTA5.encode(0, 0);
         byte[] classMethodCount = Codec.DELTA5.encode(3, 0);
-        byte[] methodDescr = encodeBandLong(new long[] { 0, 1, 2 },
+        byte[] methodDescr = encodeBandInt(new int[] { 0, 1, 2 },
                 Codec.MDELTA5);
-        byte[] methodFlagsLo = encodeBandLong(
-                new long[] { 0, 0, 0 }, Codec.UNSIGNED5);
+        byte[] methodFlagsLo = encodeBandInt(
+                new int[] { 0, 0, 0 }, Codec.UNSIGNED5);
         byte[] classFlags = Codec.UNSIGNED5.encode(0, 0);
         byte[][] allArrays = new byte[][] { classThis, classSuper,
                 classInterfaceCount, classFieldCount, classMethodCount,
@@ -166,7 +166,7 @@
         cpDescriptor = null;
     }
 
-    public byte[] encodeBandLong(long[] data, BHSDCodec codec)
+    public byte[] encodeBandInt(int[] data, BHSDCodec codec)
             throws IOException, Pack200Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         for (int i = 0; i < data.length; i++) {

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java:768152-782693
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java:768152-785553

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java:768152-782693
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java:768152-785553

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/text/parser/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 14:00:24 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/parser:768152-782693
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/parser:768152-785553



Mime
View raw message