harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r784043 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony: pack200/ unpack200/
Date Fri, 12 Jun 2009 09:11:44 GMT
Author: sjanuary
Date: Fri Jun 12 09:11:43 2009
New Revision: 784043

URL: http://svn.apache.org/viewvc?rev=784043&view=rev
Log:
Pack200 - Improved Javadoc and comments

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPConstant.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPDouble.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPFloat.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPInt.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPLong.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.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/IntList.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
Fri Jun 12 09:11:43 2009
@@ -26,11 +26,13 @@
 import java.util.List;
 import java.util.Map;
 
-
+/**
+ * Abstract superclass for a set of bands
+ */
 public abstract class BandSet {
 
     protected final SegmentHeader segmentHeader;
-    private final int effort;
+    final int effort;
 
     // Minimum size of band for each effort level where we consider alternative codecs
     // Note: these values have been tuned - please test carefully if changing them
@@ -39,23 +41,65 @@
     private long[] canonicalLargest;
     private long[] canonicalSmallest;
 
+    /**
+     * Create a new BandSet
+     * @param effort - the packing effort to be used (must be 1-9)
+     * @param header - the segment header
+     */
     public BandSet(int effort, SegmentHeader header) {
         this.effort = effort;
         this.segmentHeader = header;
     }
 
+    /**
+     * Write the packed set of bands to the given output stream
+     * @param out
+     * @throws IOException
+     * @throws Pack200Exception
+     */
     public abstract void pack(OutputStream out) throws IOException, Pack200Exception;
 
+    /**
+     * Encode a band without considering other Codecs
+     * @param band - the band
+     * @param codec - the Codec to use
+     * @return the encoded band
+     * @throws Pack200Exception
+     */
     public byte[] encodeScalar(int[] band, BHSDCodec codec) throws Pack200Exception {
         return codec.encode(band);
     }
 
+    /**
+     * Encode a single value with the given Codec
+     * @param value - the value to encode
+     * @param codec - Codec to use
+     * @return the encoded value
+     * @throws Pack200Exception
+     */
     public byte[] encodeScalar(int value, BHSDCodec codec) throws Pack200Exception {
         return codec.encode(value);
     }
 
+    /**
+     * Encode a band of integers. The default codec may be used, but other
+     * Codecs are considered if effort is greater than 1.
+     *
+     * @param name
+     *            - name of the band (used for debugging)
+     * @param ints
+     *            - the band
+     * @param defaultCodec
+     *            - the default Codec
+     * @return the encoded band
+     * @throws Pack200Exception
+     */
     public byte[] encodeBandInt(String name, int[] ints, BHSDCodec defaultCodec) throws Pack200Exception
{
         byte[] encodedBand = null;
+     // Useful for debugging
+//        if(ints.length > 0) {
+//            System.out.println("encoding " + name + " " + ints.length);
+//        }
         if(effort > 1 && (ints.length >= effortThresholds[effort])) {
             BandAnalysisResults results = analyseBand(name, ints, defaultCodec);
             Codec betterCodec = results.betterCodec;
@@ -230,7 +274,6 @@
         return results;
     }
 
-
     private boolean timeToStop(BandAnalysisResults results) {
         // if tried more than effort number of codecs for this band then return
         // Note: these values have been tuned - please test carefully if changing them
@@ -258,7 +301,6 @@
                     // TODO: can represent some negative deltas with overflow
                     byte[] encoded2 = potential.encode(band);
                     results.numCodecsTried++;
-                    results.codecsTried.add(potential);
                     byte[] specifierEncoded = defaultCodec.encode(CodecEncoding
                             .getSpecifier(potential, null));
                     int saved = encoded.length - encoded2.length
@@ -273,7 +315,6 @@
                     && potential.smallest() <= bandData.smallest) {
                 byte[] encoded2 = potential.encode(band);
                 results.numCodecsTried++;
-                results.codecsTried.add(potential);
                 byte[] specifierEncoded = defaultCodec.encode(CodecEncoding
                         .getSpecifier(potential, null));
                 int saved = encoded.length - encoded2.length
@@ -290,6 +331,15 @@
         }
     }
 
+    /**
+     * Returns true if the name of the source file can be predicted from the
+     * class name
+     *
+     * @param className
+     *            the class name
+     * @param sourceFileName
+     *            the source file name
+     */
     public boolean isPredictableSourceFileName(String className, String sourceFileName) {
         if (className.indexOf('.') != -1) {
             className = className.substring(className.lastIndexOf('.') + 1);
@@ -496,6 +546,23 @@
         }
     }
 
+    /**
+     * Encode a band of longs (values are split into their high and low 32 bits
+     * and then encoded as two separate bands
+     *
+     * @param name
+     *            - name of the band (for debugging purposes)
+     * @param flags
+     *            - the band
+     * @param loCodec
+     *            - Codec for the low 32-bits band
+     * @param hiCodec
+     *            - Codec for the high 32-bits band
+     * @param haveHiFlags
+     *            - ignores the high band if true as all values would be zero
+     * @return the encoded band
+     * @throws Pack200Exception
+     */
     protected byte[] encodeFlags(String name, long[] flags, BHSDCodec loCodec, BHSDCodec
hiCodec,
             boolean haveHiFlags) throws Pack200Exception {
         if(!haveHiFlags) {
@@ -522,6 +589,9 @@
         }
     }
 
+    /**
+     * Converts a list of Integers to an int[] array
+     */
     protected int[] listToArray(List integerList) {
         int[] array = new int[integerList.size()];
         for (int i = 0; i < array.length; i++) {
@@ -530,6 +600,9 @@
         return array;
     }
 
+    /**
+     * Converts a list of Longs to an long[] array
+     */
     protected long[] longListToArray(List longList) {
         long[] array = new long[longList.size()];
         for (int i = 0; i < array.length; i++) {
@@ -538,6 +611,9 @@
         return array;
     }
 
+    /**
+     * Converts a list of ConstantPoolEntrys to an int[] array of their indices
+     */
     protected int[] cpEntryListToArray(List list) {
         int[] array = new int[list.size()];
         for (int i = 0; i < array.length; i++) {
@@ -549,6 +625,10 @@
         return array;
     }
 
+    /**
+     * Converts a list of ConstantPoolEntrys or nulls to an int[] array of their
+     * indices +1 (or 0 for nulls)
+     */
     protected int[] cpEntryOrNullListToArray(List theList) {
         int[] array = new int[theList.size()];
         for (int j = 0; j < array.length; j++) {
@@ -603,6 +683,10 @@
 
         private Map distinctValues;
 
+        /**
+         * Create a new instance of BandData.  The band is then analysed.
+         * @param band - the band of integers
+         */
         public BandData(int[] band) {
             this.band = band;
             Integer one = new Integer(1);
@@ -649,24 +733,42 @@
             }
         }
 
+        /**
+         * Returns true if the deltas between adjacent band elements are mainly
+         * small (heuristic)
+         */
         public boolean mainlySmallDeltas() {
             // Note: the value below has been tuned - please test carefully if changing it
             return (float)smallDeltaCount/(float)band.length > 0.7F;
         }
+
+        /**
+         * Returns true if the band is well correlated (i.e. would be suitable
+         * for a delta encoding) (heuristic)
+         */
         public boolean wellCorrelated() {
             // Note: the value below has been tuned - please test carefully if changing it
             return averageAbsoluteDelta * 3.1 < averageAbsoluteValue;
         }
 
+        /**
+         * Returns true if the band deltas are mainly positive (heuristic)
+         */
         public boolean mainlyPositiveDeltas() {
             // Note: the value below has been tuned - please test carefully if changing it
             return (float)deltaIsAscending/(float)band.length > 0.95F;
         }
 
+        /**
+         * Returns true if any band elements are negative
+         */
         public boolean anyNegatives() {
             return smallest < 0;
         }
 
+        /**
+         * Returns the total number of distinct values found in the band
+         */
         public int numDistinctValues() {
             if(distinctValues == null) {
                 return band.length;
@@ -676,16 +778,26 @@
 
     }
 
+    /**
+     * Results obtained by trying different Codecs to encode a band
+     */
     public class BandAnalysisResults {
 
-        private final List codecsTried = new ArrayList(effort);
-
+        // The number of Codecs tried so far
         private int numCodecsTried = 0;
+
+        // The number of bytes saved by using betterCodec instead of the default codec
         private int saved = 0;
 
+        // Extra metadata to pass to the segment header (to be appended to the
+        // band_headers band)
         private int[] extraMetadata;
 
+        // The results of encoding the band with betterCodec
         private byte[] encodedBand;
+
+        // The best Codec found so far, or should be null if the default is the
+        // best so far
         private Codec betterCodec;
 
     }

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=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
Fri Jun 12 09:11:43 2009
@@ -26,7 +26,8 @@
 import org.objectweb.asm.Label;
 
 /**
- * Bytecode bands
+ * Bytecode bands (corresponds to the <code>bc_bands</code> set of bands in the
+ * pack200 specification)
  */
 public class BcBands extends BandSet {
 
@@ -85,6 +86,11 @@
         superClass = superName;
     }
 
+    /**
+     * 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() {
         bcThisField = getIndexInClass(bcThisField);
         bcThisMethod = getIndexInClass(bcThisMethod);

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPClass.java
Fri Jun 12 09:11:43 2009
@@ -16,7 +16,9 @@
  */
 package org.apache.harmony.pack200;
 
-
+/**
+ * Constant pool entry for a class
+ */
 public class CPClass extends CPConstant implements Comparable {
 
     private final String className;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPConstant.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPConstant.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPConstant.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPConstant.java
Fri Jun 12 09:11:43 2009
@@ -16,7 +16,11 @@
  */
 package org.apache.harmony.pack200;
 
-
-public abstract class CPConstant extends ConstantPoolEntry implements Comparable {
+/**
+ * Abstract superclass for constant pool constant entries such as numbers or
+ * Strings
+ */
+public abstract class CPConstant extends ConstantPoolEntry implements
+        Comparable {
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPDouble.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPDouble.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPDouble.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPDouble.java
Fri Jun 12 09:11:43 2009
@@ -16,10 +16,12 @@
  */
 package org.apache.harmony.pack200;
 
-
+/**
+ * Constant pool entry for a double.
+ */
 public class CPDouble extends CPConstant {
 
-    private double theDouble;
+    private final double theDouble;
 
     public CPDouble(double theDouble) {
         this.theDouble = theDouble;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPFloat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPFloat.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPFloat.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPFloat.java
Fri Jun 12 09:11:43 2009
@@ -16,10 +16,12 @@
  */
 package org.apache.harmony.pack200;
 
-
+/**
+ * Constant pool entry for a float.
+ */
 public class CPFloat extends CPConstant {
 
-    private float theFloat;
+    private final float theFloat;
 
     public CPFloat(float theFloat) {
         this.theFloat = theFloat;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPInt.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPInt.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPInt.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPInt.java
Fri Jun 12 09:11:43 2009
@@ -16,7 +16,9 @@
  */
 package org.apache.harmony.pack200;
 
-
+/**
+ * Constant pool entry for an int.
+ */
 public class CPInt extends CPConstant {
 
     private final int theInt;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPLong.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPLong.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPLong.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPLong.java
Fri Jun 12 09:11:43 2009
@@ -16,7 +16,9 @@
  */
 package org.apache.harmony.pack200;
 
-
+/**
+ * Constant pool entry for a long.
+ */
 public class CPLong extends CPConstant {
 
     private final long theLong;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPMethodOrField.java
Fri Jun 12 09:11:43 2009
@@ -16,6 +16,9 @@
  */
 package org.apache.harmony.pack200;
 
+/**
+ * Constant pool entry for a method or field.
+ */
 public class CPMethodOrField extends ConstantPoolEntry implements Comparable {
 
     private final CPClass className;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPNameAndType.java
Fri Jun 12 09:11:43 2009
@@ -16,6 +16,9 @@
  */
 package org.apache.harmony.pack200;
 
+/**
+ * Constant pool entry for a name and type pair.
+ */
 public class CPNameAndType extends ConstantPoolEntry implements Comparable {
 
     private final CPUTF8 name;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPSignature.java
Fri Jun 12 09:11:43 2009
@@ -18,6 +18,9 @@
 
 import java.util.List;
 
+/**
+ * Constant pool entry for a signature.
+ */
 public class CPSignature extends ConstantPoolEntry implements Comparable {
 
     private final CPUTF8 signatureForm;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPString.java
Fri Jun 12 09:11:43 2009
@@ -16,7 +16,9 @@
  */
 package org.apache.harmony.pack200;
 
-
+/**
+ * Constant pool entry for a String.
+ */
 public class CPString extends CPConstant {
 
     private final String string;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CPUTF8.java
Fri Jun 12 09:11:43 2009
@@ -16,7 +16,9 @@
  */
 package org.apache.harmony.pack200;
 
-
+/**
+ * Constant pool entry for a UTF8 entry, used for storing long Strings.
+ */
 public class CPUTF8 extends ConstantPoolEntry implements Comparable {
 
     private final String string;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ConstantPoolEntry.java
Fri Jun 12 09:11:43 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/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=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
Fri Jun 12 09:11:43 2009
@@ -299,6 +299,11 @@
                 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/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=784043&r1=784042&r2=784043&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
Fri Jun 12 09:11:43 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++) {

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=784043&r1=784042&r2=784043&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
Fri Jun 12 09:11:43 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/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java
Fri Jun 12 09:11:43 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/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
Fri Jun 12 09:11:43 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/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java
Fri Jun 12 09:11:43 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/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
Fri Jun 12 09:11:43 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);

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java?rev=784043&r1=784042&r2=784043&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
Fri Jun 12 09:11:43 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;
@@ -368,7 +365,6 @@
 
         protected int getLength(char uint_type) {
             int length = 0;
-            ;
             switch (uint_type) {
             case 'B':
                 length = 1;
@@ -428,7 +424,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;



Mime
View raw message