harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r617085 [12/14] - in /harmony/enhanced/classlib/branches/java6: depends/build/ depends/build/platform/ depends/libs/ depends/oss/ make/ make/linux.x86_64.libstdc++6/ make/windows.x86/ make/windows.x86_64/ modules/archive/META-INF/ modules/a...
Date Thu, 31 Jan 2008 10:04:22 GMT
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=617085&r1=617084&r2=617085&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 Thu Jan 31 02:04:05 2008
@@ -18,22 +18,20 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.harmony.pack200.bytecode.CPClass;
+import org.apache.harmony.pack200.bytecode.ClassConstantPool;
 
 /**
  * Pack200 Inner Class Bands
  */
 public class IcBands extends BandSet {
-    
-    public static class ICTuple {
-
-        public String C; // this class
-        public int F; // flags
-        public String C2; // outer class
-        public String N; // name
 
-    }
 
-    private ICTuple[] icAll;
+    private IcTuple[] icAll;
 
     private String[] cpUTF8;
 
@@ -63,12 +61,12 @@
                 outerClasses, cpClass);
         String[] icName = parseReferences("ic_name", in, Codec.DELTA5, outerClasses,
                 cpUTF8);
-        
+
         // Construct IC tuples
-        icAll = new ICTuple[icThisClass.length];
+        icAll = new IcTuple[icThisClass.length];
         int index = 0;
         for (int i = 0; i < icThisClass.length; i++) {
-            icAll[i] = new ICTuple();
+            icAll[i] = new IcTuple();
             icAll[i].C = icThisClass[i];
             icAll[i].F = icFlags[i];
             if((icFlags[i] & 1<<16) != 0) {
@@ -79,9 +77,72 @@
         }
     }
 
-    public ICTuple[] getIcTuples() {
+    public IcTuple[] getIcTuples() {
         return icAll;
     }
 
-  
+    /**
+     * Answer the relevant IcTuples for the specified className
+     * and class constant pool.
+     * @param className String name of the class X for ic_relevant(X)
+     * @param cp ClassConstantPool used to generate ic_relevant(X)
+     * @return array of IcTuple
+     */
+    public IcTuple[] getRelevantIcTuples(String className, ClassConstantPool cp) {
+        List relevantTuples = new ArrayList();
+        IcTuple[] allTuples = getIcTuples();
+        int allTuplesSize = allTuples.length;
+        SegmentUtils.debug("-------\nRelevant() " + className);
+        for(int index=0; index < allTuplesSize; index++) {
+            if(allTuples[index].outerClassString().equals(className)) {
+                relevantTuples.add(allTuples[index]);
+            }
+        }
+
+        SegmentUtils.debug("self halt");
+        List classPoolClasses = cp.allClasses();
+        boolean changed = true;
+        // For every class in both ic_this_class and cp,
+        // add it to ic_relevant. Repeat until no more
+        // changes to ic_relevant.
+        while(changed) {
+            changed = false;
+            for(int allTupleIndex=0; allTupleIndex < allTuplesSize; allTupleIndex++) {
+                Iterator it = classPoolClasses.iterator();
+                SegmentUtils.debug("\n\n----\nLooking through class pool for: " + allTuples[allTupleIndex].thisClassString());
+                while(it.hasNext()) {
+                    CPClass classInPool = (CPClass)it.next();
+                    String poolClassName = classInPool.name;
+                    SegmentUtils.debug("    " + poolClassName);
+                    if(poolClassName.equals(allTuples[allTupleIndex].thisClassString())) {
+                        // If the tuple isn't already in there, then add it
+                        SegmentUtils.debug("     -> match");
+                        if(relevantTuples.indexOf(allTuples[allTupleIndex]) == -1) {
+                            SegmentUtils.debug("        -> added");
+                            relevantTuples.add(allTuples[allTupleIndex]);
+                            changed = true;
+                        }
+                    }
+                    // TODO: is this right?
+                    if(poolClassName.equals(allTuples[allTupleIndex].outerClassString())) {
+                        // If the tuple isn't already in there, then add it
+                        SegmentUtils.debug("     -> omatch");
+                        if(relevantTuples.indexOf(allTuples[allTupleIndex]) == -1) {
+                            SegmentUtils.debug("        -> oadded");
+                            relevantTuples.add(allTuples[allTupleIndex]);
+                            changed = true;
+                        }
+                    }
+                }
+            }
+        }
+
+        IcTuple[] result = new IcTuple[relevantTuples.size()];
+        for(int index=0; index < result.length; index++) {
+            result[index] = (IcTuple)relevantTuples.get(index);
+            SegmentUtils.debug("Returning relevantTuple: " + result[index].thisClassString());
+        }
+        return result;
+    }
+
 }

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=617085&r1=617084&r2=617085&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 Thu Jan 31 02:04:05 2008
@@ -39,13 +39,13 @@
  * Group of metadata bands, e.g. class_RVA_bands, method_AD_bands etc
  */
 public class MetadataBandGroup {
-        
+
     private String type;
 
     public MetadataBandGroup(String type) {
         this.type = type;
     }
-    
+
     private List attributes;
 
     public int[] param_NB;
@@ -64,7 +64,7 @@
     public CPUTF8[] cases_RU;
     public int[] casearray_N;
     public CPUTF8[] nesttype_RS;
-    public int[] nestpair_N;        
+    public int[] nestpair_N;
     public CPUTF8[] nestname_RU;
 
     private Iterator caseI_Iterator;
@@ -86,9 +86,9 @@
     private Iterator casearray_Iterator;
 
     private Iterator T_iterator;
-    
+
     private Iterator nesttype_RS_Iterator;
-    
+
     private Iterator nestpair_N_Iterator;
 
     private Iterator nestname_RU_Iterator;
@@ -98,8 +98,8 @@
     private Iterator type_RS_Iterator;
 
     private Iterator pair_N_Iterator;
-    
-   
+
+
     public List getAttributes() {
         if(attributes == null) {
             attributes = new ArrayList();
@@ -146,13 +146,13 @@
         Annotation[] annotations = new Annotation[numAnnotations];
         for (int i = 0; i < numAnnotations; i++) {
             annotations[i] = getAnnotation(types[i], pairCounts[i], namesIterator);
-        }        
+        }
         return new RuntimeVisibleorInvisibleAnnotationsAttribute(type
                 .equals("RVA") ? "RuntimeVisibleAnnotations"
                 : "RuntimeInvisibleAnnotations",
                 annotations);
     }
-    
+
     private Attribute getParameterAttribute(int numParameters, Iterator namesIterator ) {
         ParameterAnnotation[] parameter_annotations = new ParameterAnnotation[numParameters];
         for (int i = 0; i < numParameters; i++) {
@@ -215,7 +215,7 @@
             case '@':
                 CPUTF8 type = (CPUTF8) nesttype_RS_Iterator.next();
                 int numPairs = ((Integer)nestpair_N_Iterator.next()).intValue();
-                
+
                 return getAnnotation(type, numPairs, nestname_RU_Iterator);
         }
         return null;
@@ -228,5 +228,5 @@
         }
         return boxed;
     }
-    
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java Thu Jan 31 02:04:05 2008
@@ -47,7 +47,7 @@
     private List attributes;
 
     private int backwardsCallCount;
-    
+
     private List attributeLayoutElements;
 
     public NewAttributeBands(Segment segment, AttributeLayout attributeLayout) throws IOException {
@@ -59,7 +59,7 @@
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.apache.harmony.pack200.BandSet#unpack(java.io.InputStream)
      */
     public void unpack(InputStream in) throws IOException, Pack200Exception {
@@ -78,7 +78,7 @@
     /**
      * Parse the bands relating to this AttributeLayout and return the correct
      * class file attributes as a List of {@link Attribute}
-     * @throws Pack200Exception 
+     * @throws Pack200Exception
      */
     public List parseAttributes(InputStream in, int occurrenceCount)
             throws IOException, Pack200Exception {
@@ -129,7 +129,7 @@
 
     /**
      * Resolve calls in the attribute layout and returns the number of backwards calls
-     * 
+     *
      * @param tokens -
      *            the attribute layout as a List of AttributeElements
      */
@@ -145,7 +145,7 @@
                     if (layoutElement instanceof Call) {
                         // Set the callable for each call
                         Call call = (Call) layoutElement;
-                        int index = call.callableIndex; 
+                        int index = call.callableIndex;
                         if (index == 0) { // Calls the parent callable
                             backwardsCalls++;
                             call.setCallable(callable);
@@ -319,17 +319,17 @@
 
         /**
          * Read the bands associated with this part of the layout
-         * 
+         *
          * @param in
          * @param count
-         * @throws Pack200Exception 
-         * @throws IOException 
+         * @throws Pack200Exception
+         * @throws IOException
          */
         public void readBands(InputStream in, int count) throws IOException, Pack200Exception;
 
         /**
          * Add the band data for this element at the given index to the attribute
-         * 
+         *
          * @param index
          * @param attribute
          */
@@ -342,18 +342,18 @@
         protected int getLength(char uint_type) {
             int length = 0;;
             switch(uint_type) {
-            case 'B': 
+            case 'B':
                 length = 1;
                 break;
-            case 'H': 
+            case 'H':
                 length = 2;
                 break;
-            case 'I': 
+            case 'I':
                 length = 4;
                 break;
-            case 'V': 
+            case 'V':
                 length = 0;
-                break;            
+                break;
             }
             return length;
         }
@@ -369,7 +369,7 @@
         }
 
         public void readBands(InputStream in, int count) throws IOException, Pack200Exception {
-            band = decodeBandLong(attributeLayout.getName() + "_" + tag, in, (BHSDCodec) getCodec(tag), count);
+            band = decodeBandLong(attributeLayout.getName() + "_" + tag, in, getCodec(tag), count);
         }
 
         public void addToAttribute(int n, NewAttribute attribute) {
@@ -395,7 +395,7 @@
             } else if (tag.startsWith("P")) {
                 char uint_type = tag.substring(1).toCharArray()[0];
                 int length = getLength(uint_type);
-                attribute.addBCIndex(length, (int) value);                
+                attribute.addBCIndex(length, (int) value);
             } else if (tag.startsWith("OS")) {
                 char uint_type = tag.substring(1).toCharArray()[0];
                 int length = getLength(uint_type);
@@ -406,11 +406,11 @@
                 } else if(length == 4) {
                     value = (int)value;
                 }
-                attribute.addBCLength(length, (int) value);  
+                attribute.addBCLength(length, (int) value);
             } else if (tag.startsWith("O")) {
                 char uint_type = tag.substring(1).toCharArray()[0];
                 int length = getLength(uint_type);
-                attribute.addBCLength(length, (int) value);                
+                attribute.addBCLength(length, (int) value);
             }
         }
 
@@ -442,7 +442,7 @@
             countElement.readBands(in, count);
             int arrayCount = 0;
             for (int i = 0; i < count; i++) {
-                arrayCount += countElement.getValue(i);                
+                arrayCount += countElement.getValue(i);
             }
             for (Iterator iter = layoutElements.iterator(); iter.hasNext();) {
                 LayoutElement element = (LayoutElement) iter.next();
@@ -453,14 +453,14 @@
         public void addToAttribute(int index, NewAttribute attribute) {
             // Add the count value
             countElement.addToAttribute(index, attribute);
-            
+
             // Add the corresponding array values
             int offset = 0;
             for (int i = 0; i < index; i++) {
                 offset += countElement.getValue(i);
             }
             long numElements = countElement.getValue(index);
-            for (int i = offset; i < offset + numElements; i++) {                
+            for (int i = offset; i < offset + numElements; i++) {
                 for (Iterator iter = layoutElements.iterator(); iter.hasNext();) {
                     LayoutElement element = (LayoutElement) iter.next();
                     element.addToAttribute(i, attribute);
@@ -469,13 +469,13 @@
         }
     }
 
-    
+
     /**
      * A Union is a type of layout element where the tag value acts as a
      * selector for one of the union cases
      */
     private class Union extends LayoutElement {
-        
+
         private Integral unionTag;
         private List unionCases;
         private List defaultCaseBody;
@@ -506,7 +506,7 @@
             for (int i = 0; i < values.length; i++) {
                 boolean found = false;
                 for (Iterator iter = unionCases.iterator(); iter.hasNext();) {
-                    UnionCase unionCase = (UnionCase) iter.next();                    
+                    UnionCase unionCase = (UnionCase) iter.next();
                     if(unionCase.hasTag(values[i])) {
                         found = true;
                     }
@@ -592,7 +592,7 @@
              */
             if(callableIndex > 0) {
                 callable.addCount(count);
-            } 
+            }
         }
 
         public void addToAttribute(int n, NewAttribute attribute) {
@@ -606,7 +606,7 @@
     private class Reference extends LayoutElement {
 
         private String tag;
-        
+
         private Object band;
 
         private int length;
@@ -677,13 +677,13 @@
     private class Callable implements AttributeLayoutElement {
 
         private List body;
-        
+
         private boolean isBackwardsCallable;
 
         public Callable(List body) throws IOException {
             this.body = body;
         }
-        
+
         private int count;
         private int index;
 
@@ -692,11 +692,11 @@
          * so they don't have to keep track of the internal index
          * of the callable
          * @param attribute
-         */        
+         */
         public void addNextToAttribute(NewAttribute attribute) {
             for (Iterator iter = body.iterator(); iter.hasNext();) {
                 LayoutElement element = (LayoutElement) iter.next();
-                element.addToAttribute(index, attribute);                
+                element.addToAttribute(index, attribute);
             }
             index++;
         }
@@ -721,7 +721,7 @@
             // Ignore n because bands also contain element parts from calls
             for (Iterator iter = body.iterator(); iter.hasNext();) {
                 LayoutElement element = (LayoutElement) iter.next();
-                element.addToAttribute(index, attribute);                
+                element.addToAttribute(index, attribute);
             }
             index++;
         }
@@ -729,7 +729,7 @@
         public boolean isBackwardsCallable() {
             return isBackwardsCallable;
         }
-        
+
         /**
          * Tells this Callable that it is a backwards callable
          */
@@ -737,7 +737,7 @@
             this.isBackwardsCallable = true;
         }
     }
-    
+
     /**
      * A Union case
      */
@@ -899,7 +899,7 @@
      * Once the attribute bands have been read the callables can be informed
      * about the number of times each is subject to a backwards call. This
      * method is used to set this information.
-     * 
+     *
      * @param backwardsCalls
      *            one int for each backwards callable, which contains the number
      *            of times that callable is subject to a backwards call.

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java Thu Jan 31 02:04:05 2008
@@ -25,7 +25,7 @@
 
 	/**
 	 * Create a new Pack200 exception with the given message and cause
-	 * 
+	 *
 	 * @param message
 	 *            the text message to display
 	 */
@@ -35,7 +35,7 @@
 
 	/**
 	 * Create a new Pack200 exception with the given message and cause
-	 * 
+	 *
 	 * @param message
 	 *            the text message to display
 	 * @param cause
@@ -47,7 +47,7 @@
 
 	/**
 	 * Create a new Pack200 exception with the given message and cause
-	 * 
+	 *
 	 * @param cause
 	 *            the throwable that caused this problem
 	 */

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=617085&r1=617084&r2=617085&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 Thu Jan 31 02:04:05 2008
@@ -25,7 +25,7 @@
 	private Codec unvafouredCodec;
 	private int l;
     private long[] favoured;
-	
+
 	public PopulationCodec(Codec favouredCodec, Codec tableCodec, Codec unvafouredCodec) {
 		this.favouredCodec = favouredCodec;
 		this.tokenCodec = tableCodec;
@@ -40,18 +40,18 @@
 		this.unvafouredCodec = unvafouredCodec;
 	}
 
-	
+
 	public long 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,
 			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, Pack200Exception {
 		favoured = new long[n]; // there must be <= n  values, but probably a lot less
 		long result[];
@@ -90,7 +90,7 @@
 			}
 		}
 		// read favorites
-		result = tokenCodec.decode(n, in);		
+		result = tokenCodec.decode(n, in);
         // read unfavorites
         last = 0;
         for(int i = 0; i < n; i++) {

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=617085&r1=617084&r2=617085&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 Thu Jan 31 02:04:05 2008
@@ -51,7 +51,7 @@
 			return value;
 		} else {
 			this.last = bCodec.decode(in,last);
-			return this.last;			
+			return this.last;
 		}
 	}
 	public String toString() {

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=617085&r1=617084&r2=617085&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 Thu Jan 31 02:04:05 2008
@@ -20,6 +20,7 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
 import java.util.zip.GZIPInputStream;
@@ -28,9 +29,11 @@
 import org.apache.harmony.pack200.bytecode.CPClass;
 import org.apache.harmony.pack200.bytecode.CPField;
 import org.apache.harmony.pack200.bytecode.CPMethod;
+import org.apache.harmony.pack200.bytecode.CPUTF8;
 import org.apache.harmony.pack200.bytecode.ClassConstantPool;
 import org.apache.harmony.pack200.bytecode.ClassFile;
 import org.apache.harmony.pack200.bytecode.ClassFileEntry;
+import org.apache.harmony.pack200.bytecode.InnerClassesAttribute;
 import org.apache.harmony.pack200.bytecode.SourceFileAttribute;
 
 /**
@@ -40,19 +43,19 @@
  * combine (non-GZipped) archives into a single large archive by concatenation
  * alone. Thus all the hard work in unpacking an archive falls to understanding
  * a segment.
- * 
+ *
  * This class implements the Pack200 specification by an entry point ({@link #parse(InputStream)})
  * which in turn delegates to a variety of other parse methods. Each parse
  * method corresponds (roughly) to the name of the bands in the Pack200
  * specification.
- * 
+ *
  * The first component of a segment is the header; this contains (amongst other
  * things) the expected counts of constant pool entries, which in turn defines
  * how many values need to be read from the stream. Because values are variable
  * width (see {@link Codec}), it is not possible to calculate the start of the
  * next segment, although one of the header values does hint at the size of the
  * segment if non-zero, which can be used for buffering purposes.
- * 
+ *
  * Note that this does not perform any buffering of the input stream; each value
  * will be read on a byte-by-byte basis. It does not perform GZip decompression
  * automatically; both of these are expected to be done by the caller if the
@@ -65,15 +68,14 @@
 
 
 	/**
+     * TODO: Do we need this method now we have Archive as the main entry point?
+     *
 	 * Decode a segment from the given input stream. This does not attempt to
 	 * re-assemble or export any class files, but it contains enough information
 	 * to be able to re-assemble class files by external callers.
-	 * 
+	 *
 	 * @param in
-	 *            the input stream to read from TODO At this point, this must be
-	 *            a non-GZipped input stream, but this decoding could be done in
-	 *            this method in the future (but perhaps more likely on an
-	 *            archive as a whole)
+	 *            the input stream to read from
 	 * @return a segment parsed from the input stream
 	 * @throws IOException
 	 *             if a problem occurs during reading from the underlying stream
@@ -84,19 +86,6 @@
 	public static Segment parse(InputStream in) throws IOException,
 			Pack200Exception {
 		Segment segment = new Segment();
-		// See if file is GZip compressed
-		if (!in.markSupported()) {
-			in = new BufferedInputStream(in);
-			if (!in.markSupported())
-				throw new IllegalStateException();
-		}
-		in.mark(2);
-		if (((in.read() & 0xFF) | (in.read() & 0xFF) << 8) == GZIPInputStream.GZIP_MAGIC) {
-			in.reset();
-			in = new BufferedInputStream(new GZIPInputStream(in));
-		} else {
-			in.reset();
-		}
         segment.parseSegment(in);
 		return segment;
 	}
@@ -105,7 +94,7 @@
     private SegmentHeader header;
 
     private CpBands cpBands;
-    
+
     private AttrDefinitionBands attrDefinitionBands;
 
     private IcBands icBands;
@@ -116,6 +105,10 @@
 
     private FileBands fileBands;
 
+    private boolean overrideDeflateHint;
+
+    private boolean deflateHint;
+
 	private ClassFile buildClassFile(int classNum) throws Pack200Exception {
 		ClassFile classFile = new ClassFile();
 		classFile.major = header.getDefaultClassMajorVersion(); // TODO If
@@ -163,6 +156,51 @@
 			cfMethods[i] = cp.add(new CPMethod(classBands.getMethodDescr()[classNum][i],
                     classBands.getMethodFlags()[classNum][i], classBands.getMethodAttributes()[classNum][i]));
 		}
+		// TODO: maybe this is a better place to add ic_relevant?
+		// This seems like the right thing to do.
+		boolean addedClasses = false;
+		InnerClassesAttribute innerClassesAttribute = new InnerClassesAttribute("InnerClasses");
+		IcTuple[] ic_relevant = getIcBands().getRelevantIcTuples(fullName, cp);
+
+		for(int index = 0; index < ic_relevant.length; index++) {
+		    String innerClassString = ic_relevant[index].thisClassString();
+		    String outerClassString = ic_relevant[index].outerClassString();
+		    String simpleClassName = ic_relevant[index].simpleClassName();
+
+		    CPClass innerClass = null;
+		    CPUTF8 innerName = null;
+		    CPClass outerClass = null;
+
+		    if(ic_relevant[index].isAnonymous()) {
+		        innerClass = new CPClass(innerClassString);
+		    } else {
+	            innerClass = new CPClass(innerClassString);
+	            innerName = new CPUTF8(simpleClassName, ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+		    }
+
+		    // TODO: I think we need to worry about if the
+		    // OUTER class is a member or not - not the
+		    // ic_relevant itself.
+//		    if(ic_relevant[index].isMember()) {
+		        outerClass = new CPClass(outerClassString);
+//		    }
+
+	        int flags = ic_relevant[index].F;
+	        innerClassesAttribute.addInnerClassesEntry(innerClass, outerClass, innerName, flags);
+	        addedClasses = true;
+		}
+		if(addedClasses) {
+		    // Need to add the InnerClasses attribute to the
+		    // existing classFile attributes.
+		    Attribute[] originalAttrs = classFile.attributes;
+		    Attribute[] newAttrs = new Attribute[originalAttrs.length + 1];
+		    for(int index=0; index < originalAttrs.length; index++) {
+		        newAttrs[index] = originalAttrs[index];
+		    }
+		    newAttrs[newAttrs.length - 1] = innerClassesAttribute;
+		    classFile.attributes = newAttrs;
+		    cp.add(innerClassesAttribute);
+		}
 		// sort CP according to cp_All
 		cp.resolve(this);
 		// print out entries
@@ -189,7 +227,7 @@
 	/**
 	 * This performs the actual work of parsing against a non-static instance of
 	 * Segment.
-	 * 
+	 *
 	 * @param in
 	 *            the input stream to read from
 	 * @throws IOException
@@ -202,7 +240,7 @@
 			Pack200Exception {
 		debug("-------");
         header = new SegmentHeader();
-        header.unpack(in);        
+        header.unpack(in);
         cpBands = new CpBands(this);
         cpBands.unpack(in);
         attrDefinitionBands = new AttrDefinitionBands(this);
@@ -216,11 +254,11 @@
         fileBands = new FileBands(this);
         fileBands.unpack(in);
 	}
-    
+
     /**
      * Unpacks a packed stream (either .pack. or .pack.gz) into a corresponding
      * JarOuputStream.
-     * 
+     *
      * @throws Pack200Exception
      *             if there is a problem unpacking
      * @throws IOException
@@ -229,18 +267,17 @@
     public void unpack(InputStream in, JarOutputStream out) throws IOException,
             Pack200Exception {
         if (!in.markSupported())
-            in = new BufferedInputStream(in);
-        // TODO Can handle multiple concatenated streams, so should deal with
-        // that possibility
-        parse(in).unpack(in, out);
+            in = new BufferedInputStream(in);        
+        parseSegment(in);
+        writeJar(out);
     }
-    
+
     /**
      * This is a local debugging message to aid the developer in writing this
      * class. It will be removed before going into production. If the property
      * 'debug.pack200' is set, this will generate messages to stderr; otherwise,
      * it will be silent.
-     * 
+     *
      * @param message
      * @deprecated this should be removed from production code
      */
@@ -258,7 +295,7 @@
 	 * reading, since the file bits may not be loaded and thus just copied from
 	 * one stream to another. Doesn't close the output stream when finished, in
 	 * case there are more entries (e.g. further segments) to be written.
-	 * 
+	 *
 	 * @param out
 	 *            the JarOutputStream to write data to
 	 * @param in
@@ -277,7 +314,7 @@
         long[] fileOptions = fileBands.getFileOptions();
         long[] fileSize = fileBands.getFileSize();
         byte[][] fileBits = fileBands.getFileBits();
-       
+
 		// out.setLevel(JarEntry.DEFLATED)
 		// now write the files out
 		int classNum = 0;
@@ -289,6 +326,9 @@
 			long modtime = archiveModtime + fileModtime[i];
 			boolean deflate = (fileOptions[i] & 1) == 1
 					|| options.shouldDeflate();
+            if (overrideDeflateHint) { // Overridden by a command line argument
+                deflate = deflateHint;
+            }
 			boolean isClass = (fileOptions[i] & 2) == 2 || name == null
 					|| name.equals("");
 			if (isClass) {
@@ -356,6 +396,28 @@
 
     protected IcBands getIcBands() {
         return icBands;
+    }
+
+
+    public void setLogLevel(int logLevel) {
+
+    }
+
+    public void setLogStream(OutputStream stream) {
+
+    }
+
+    public void log(int logLevel, String message) {
+
+    }
+
+    /**
+     * Override the archive's deflate hint with the given boolean
+     * @param deflateHint - the deflate hint to use
+     */
+    public void overrideDeflateHint(boolean deflateHint) {
+        this.overrideDeflateHint = true;
+        this.deflateHint = deflateHint;
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java Thu Jan 31 02:04:05 2008
@@ -33,7 +33,7 @@
 
 public class SegmentConstantPool {
     /**
-     * 
+     *
      */
     private CpBands bands;
 
@@ -89,13 +89,13 @@
             throw new Error("Get value incomplete");
         }
     }
-    
+
     /**
      * Subset the constant pool of the specified type
      * to be just that which has the specified class
      * name. Answer the ConstantPoolEntry at the
      * desiredIndex of the subsetted pool.
-     * 
+     *
      * @param cp type of constant pool array to search
      * @param desiredIndex index of the constant pool
      * @param desiredClassName class to use to generate a
@@ -117,9 +117,9 @@
     		throw new Error("Don't know how to handle " + cp);
     	}
     	realIndex = matchSpecificPoolEntryIndex(array, desiredClassName, index);
-    	return getConstantPoolEntry(cp, (long)realIndex);
+    	return getConstantPoolEntry(cp, realIndex);
     }
-    
+
     /**
      * Given the name of a class, answer the CPClass associated
      * with that class. Answer null if the class doesn't exist.
@@ -133,13 +133,13 @@
     		return null;
     	}
     	try {
-    		return getConstantPoolEntry(CP_CLASS, (long)index);
+    		return getConstantPoolEntry(CP_CLASS, index);
     	}
     	catch (Pack200Exception ex) {
     		throw new Error("Error getting class pool entry");
     	}
     }
-    
+
     /**
      * Answer the init method for the specified class.
      * @param cp constant pool to search (must be CP_METHOD)
@@ -156,7 +156,7 @@
     	} else {
     		throw new Error("Nothing but CP_METHOD can be an <init>");
     	}
-    	return getConstantPoolEntry(cp, (long)realIndex);
+    	return getConstantPoolEntry(cp, realIndex);
     }
 
     /**
@@ -166,12 +166,12 @@
      * fields defined in the superclass. Similarly, _this bytecodes
      * use just those methods/fields defined in this class, and _init
      * bytecodes use just those methods that start with <init>.
-     * 
+     *
      * This method takes an array of names, a String to match for,
      * an index and a boolean as parameters, and answers the array
      * position in the array of the indexth element which matches
      * (or equals) the String (depending on the state of the boolean)
-     * 
+     *
      * In other words, if the class array consists of:
      *  Object [position 0, 0th instance of Object]
      *  String [position 1, 0th instance of String]
@@ -181,7 +181,7 @@
      * then classSpecificPoolEntryIndex(..., "Object", 2, false) will
      * answer 4. classSpecificPoolEntryIndex(..., "String", 0, false)
      * will answer 1.
-     * 
+     *
      * @param nameArray Array of Strings against which the compareString is tested
      * @param compareString String for which to search
      * @param desiredIndex nth element with that match (counting from 0)
@@ -199,7 +199,7 @@
      *  - the secondaryArray[index] .matches() the secondaryCompareString
      * When the desiredIndex number of hits has been reached, the index
      * into the original two arrays of the element hit is returned.
-     * 
+     *
      * @param primaryArray The first array to search
      * @param secondaryArray The second array (must be same .length as primaryArray)
      * @param primaryCompareString The String to compare against primaryArray using .equals()
@@ -210,7 +210,7 @@
     protected int matchSpecificPoolEntryIndex(String[] primaryArray, String[] secondaryArray, String primaryCompareString, String secondaryCompareRegex, int desiredIndex) {
     	int instanceCount = -1;
     	for(int index=0; index < primaryArray.length; index++) {
-    		if((primaryArray[index].equals(primaryCompareString)) && 
+    		if((primaryArray[index].equals(primaryCompareString)) &&
     				secondaryArray[index].matches(secondaryCompareRegex)) {
     			instanceCount++;
     			if(instanceCount == desiredIndex) {
@@ -220,10 +220,13 @@
     	}
     	// We didn't return in the for loop, so the desiredMatch
     	// with desiredIndex must not exist in the array.
+    	if(secondaryCompareRegex.equals("^<init>.*")) {
+    	    SegmentUtils.debug("self halt");
+    	}
     	return -1;
     }
-    
-    
+
+
     public ConstantPoolEntry getConstantPoolEntry(int cp, long value) throws Pack200Exception {
         int index = (int) value;
         if (index == -1) {
@@ -261,7 +264,7 @@
             throw new Error("Get value incomplete");
         }
     }
-    
+
     public ConstantPoolEntry[] getCpAll() throws Pack200Exception {
         	ArrayList cpAll = new ArrayList();
         	// TODO: this is 1.5-specific. Try to get rid
@@ -296,11 +299,11 @@
         	for(int index=0; index < bands.getCpIMethodClass().length; index++) {
         		cpAll.add(getConstantPoolEntry(CP_IMETHOD, index));
         	}
-        	
+
         	ConstantPoolEntry[] result = new ConstantPoolEntry[cpAll.size()];
         	cpAll.toArray(result);
         	return result;
         }
 
-	
+
     }

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=617085&r1=617084&r2=617085&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 Thu Jan 31 02:04:05 2008
@@ -22,11 +22,11 @@
 import java.io.InputStream;
 
 public class SegmentHeader {
-   
+
     private int archiveMajor;
 
-    private int archiveMinor;    
-    
+    private int archiveMinor;
+
     private long archiveModtime;
 
     private long archiveSize;
@@ -74,14 +74,14 @@
     private int segmentsRemaining;
 
     private SegmentOptions options;
-    
-    
+
+
     /**
      * The magic header for a Pack200 Segment is 0xCAFED00D. I wonder where they
      * get their inspiration from ...
      */
     private static final int[] magic = { 0xCA, 0xFE, 0xD0, 0x0D };
-    
+
     public void unpack(InputStream in) throws IOException,
             Pack200Exception, Error, Pack200Exception {
         long word[] = decodeScalar("archive_magic_word", in, Codec.BYTE1,
@@ -99,17 +99,17 @@
         parseArchiveSpecialCounts(in);
         parseCpCounts(in);
         parseClassCounts(in);
-        
+
         if (getBandHeadersSize() > 0) {
-            byte[] bandHeaders = new byte[(int) getBandHeadersSize()];
+            byte[] bandHeaders = new byte[getBandHeadersSize()];
             readFully(in, bandHeaders);
             setBandHeadersData(bandHeaders);
         }
     }
-    
+
     /**
      * Sets the minor version of this archive
-     * 
+     *
      * @param version
      *            the minor version of the archive
      * @throws Pack200Exception
@@ -120,10 +120,10 @@
             throw new Pack200Exception("Invalid segment minor version");
         archiveMinor = version;
     }
-    
+
     /**
      * Sets the major version of this archive.
-     * 
+     *
      * @param version
      *            the minor version of the archive
      * @throws Pack200Exception
@@ -134,7 +134,7 @@
             throw new Pack200Exception("Invalid segment major version: " + version);
         archiveMajor = version;
     }
-    
+
     public long getArchiveModtime() {
         return archiveModtime;
     }
@@ -222,16 +222,16 @@
     public long getArchiveSize() {
         return archiveSize;
     }
-    
+
     /**
      * Obtain the band headers data as an input stream. If no band headers are
      * present, this will return an empty input stream to prevent any further
      * reads taking place.
-     * 
+     *
      * Note that as a stream, data consumed from this input stream can't be
      * re-used. Data is only read from this stream if the encoding is such that
      * additional information needs to be decoded from the stream itself.
-     * 
+     *
      * @return the band headers input stream
      */
     public InputStream getBandHeadersInputStream() {
@@ -241,19 +241,19 @@
         return bandHeadersInputStream;
 
     }
-    
+
     public int getNumberOfFiles() {
         return numberOfFiles;
     }
-    
+
     public int getSegmentsRemaining() {
         return segmentsRemaining;
     }
-    
+
     public SegmentOptions getOptions() {
         return options;
     }
-    
+
     private void parseArchiveFileCounts(InputStream in) throws IOException,
             Pack200Exception {
         if (options.hasArchiveFileCounts()) {
@@ -276,7 +276,7 @@
                     in, Codec.UNSIGNED5));
         }
     }
-    
+
     private void parseClassCounts(InputStream in) throws IOException,
             Pack200Exception {
         innerClassCount = (int)decodeScalar("ic_count", in, Codec.UNSIGNED5);
@@ -286,7 +286,7 @@
                 Codec.UNSIGNED5);
         classCount = (int)decodeScalar("class_count", in, Codec.UNSIGNED5);
     }
-    
+
     private void parseCpCounts(InputStream in) throws IOException,
             Pack200Exception {
         cpUTF8Count = (int)decodeScalar("cp_Utf8_count", in, Codec.UNSIGNED5);
@@ -306,11 +306,11 @@
         cpMethodCount = (int)decodeScalar("cp_Method_count", in, Codec.UNSIGNED5);
         cpIMethodCount = (int)decodeScalar("cp_Imethod_count", in, Codec.UNSIGNED5);
     }
-    
+
     /**
      * Decode a number of scalars from the band file. A scalar is like a band,
      * but does not perform any band code switching.
-     * 
+     *
      * @param name
      *            the name of the scalar (primarily for logging/debugging
      *            purposes)
@@ -332,11 +332,11 @@
         debug("Parsed #" + name + " (" + n + ")");
         return codec.decode(n, in);
     }
-    
+
     /**
      * Decode a scalar from the band file. A scalar is like a band, but does not
      * perform any band code switching.
-     * 
+     *
      * @param name
      *            the name of the scalar (primarily for logging/debugging
      *            purposes)
@@ -358,7 +358,7 @@
         debug("Parsed #" + name + " as " + ret);
         return ret;
     }
-    
+
     public void setArchiveModtime(long archiveModtime) {
         this.archiveModtime = archiveModtime;
     }
@@ -370,7 +370,7 @@
     private void setAttributeDefinitionCount(long valuie) {
         this.attributeDefinitionCount = (int) valuie;
     }
-    
+
     private void setBandHeadersData(byte[] bandHeaders) {
         this.bandHeadersInputStream = new ByteArrayInputStream(bandHeaders);
     }
@@ -378,12 +378,12 @@
     public void setSegmentsRemaining(long value) {
         segmentsRemaining = (int) value;
     }
-    
+
     /**
      * Completely reads in a byte array, akin to the implementation in
      * {@link java.lang.DataInputStream}. TODO Refactor out into a separate
      * InputStream handling class
-     * 
+     *
      * @param in
      *            the input stream to read from
      * @param data
@@ -411,7 +411,7 @@
     public int getBandHeadersSize() {
         return bandHeadersSize;
     }
-    
+
     protected void debug(String message) {
       if (System.getProperty("debug.pack200") != null) {
           System.err.println(message);

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentOptions.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentOptions.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentOptions.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentOptions.java Thu Jan 31 02:04:05 2008
@@ -61,7 +61,7 @@
 
 	/**
 	 * Creates a new segment options with the given integer value.
-	 * 
+	 *
 	 * @param options
 	 *            the integer value to use as the flags
 	 * @throws Pack200Exception

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentUtils.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentUtils.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentUtils.java Thu Jan 31 02:04:05 2008
@@ -18,36 +18,15 @@
 
 // TODO Write doc
 public final class SegmentUtils {
-    
+
 	public static int countArgs(String descriptor) {
 	    return countArgs(descriptor, 1);
-//		int bra = descriptor.indexOf("(");
-//		int ket = descriptor.indexOf(")");
-//		if (bra == -1 || ket == -1 || ket < bra)
-//			throw new IllegalArgumentException("No arguments");
-//
-//		boolean inType = false;
-//		int count = 0;
-//		for (int i = bra + 1; i < ket; i++) {
-//			char charAt = descriptor.charAt(i);
-//			if (inType && charAt == ';') {
-//				inType = false;
-//			} else if (!inType && charAt == 'L') {
-//				inType = true;
-//				count++;
-//			} else if (charAt == '[' || inType) {
-//				// NOP
-//			} else {
-//				count++;
-//			}
-//		}
-//		return count;
 	}
 
 	public static int countInvokeInterfaceArgs(String descriptor) {
 	    return countArgs(descriptor, 2);
 	}
-	
+
 	/**
 	 * Count the number of arguments in the descriptor. Each
 	 * long or double counts as widthOfLongsAndDoubles; all other
@@ -94,7 +73,7 @@
 	    }
 	    return count;
 	}
-	   
+
 	public static int countMatches(long[] flags, IMatcher matcher) {
 		int count = 0;
 		for (int i = 0; i < flags.length; i++) {
@@ -103,7 +82,7 @@
 		}
 		return count;
 	}
-    
+
     public static int countBit16(int[] flags) {
         int count = 0;
         for (int i = 0; i < flags.length; i++) {
@@ -112,7 +91,7 @@
         }
         return count;
     }
-    
+
     public static int countBit16(long[] flags) {
         int count = 0;
         for (int i = 0; i < flags.length; i++) {
@@ -121,14 +100,14 @@
         }
         return count;
     }
-    
+
     public static int countBit16(long[][] flags) {
         int count = 0;
         for (int i = 0; i < flags.length; i++) {
             for (int j = 0; j < flags[i].length; j++) {
                 if ((flags[i][j] & (1 << 16)) != 0)
                     count++;
-            }            
+            }
         }
         return count;
     }
@@ -141,15 +120,48 @@
 		return count;
 	}
 
+	/**
+	 * Given a String classX (the name of a class) and the
+	 * collection of inner class tuples ic_all, answer
+	 * ic_relevant(classX)
+	 * @param classX String class name
+	 * @param ic_all ICTuple[] all the inner class tuples
+	 * @return ICTuple[] all the relevant tuples sorted as in
+	 */
+	public static IcTuple[] icRelevant(String classX, IcTuple[] ic_all) {
+	    return null;
+	}
+
+	public static boolean isRelevant(String outerClass, IcTuple tuple) {
+	    if(tuple.C.equals(outerClass)) {
+	        // If the outer class name is explicitly
+	        // specified and it's the correct one, the
+	        // tuple is relevant.
+	        return true;
+	    }
+
+	    if(tuple.C != null) {
+	        // If the outer class name is explicitly specified
+	        // (non-null) and it's not the correct one, the
+	        // tuple is not relevant.
+	        return false;
+	    }
+
+	    // Now we know that tuple.C is null, so it might be
+	    // relevant. Find out.
+	    return false;
+	}
+
+
 	private SegmentUtils() {
 		// Intended to be a helper class
 	}
-	
+
     /**
      * This is a debugging message to aid the developer in writing this
      * class. If the property 'debug.pack200' is set, this will
 	 * generate messages to stderr; otherwise, it will be silent.
-     * 
+     *
      * @param message
      * @deprecated this may be removed from production code
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationDefaultAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationDefaultAttribute.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationDefaultAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationDefaultAttribute.java Thu Jan 31 02:04:05 2008
@@ -38,7 +38,7 @@
     protected void writeBody(DataOutputStream dos) throws IOException {
         element_value.writeBody(dos);
     }
-    
+
     protected void resolve(ClassConstantPool pool) {
         super.resolve(pool);
         element_value.resolve(pool);

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationsAttribute.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationsAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/AnnotationsAttribute.java Thu Jan 31 02:04:05 2008
@@ -24,29 +24,29 @@
  */
 public abstract class AnnotationsAttribute extends Attribute {
 
-    
+
     /**
      * Class to represent the annotation structure for class file attributes
      */
     public static class Annotation {
-        
+
         private int num_pairs;
         private CPUTF8[] element_names;
         private ElementValue[] element_values;
         private CPUTF8 type;
-        
+
         // Resolved values
         private int type_index;
         private int[] name_indexes;
-        
-    
+
+
         public Annotation(int num_pairs, CPUTF8 type, CPUTF8[] element_names, ElementValue[] element_values) {
             this.num_pairs = num_pairs;
             this.type = type;
             this.element_names = element_names;
             this.element_values = element_values;
         }
-    
+
         public int getLength() {
             int length = 4;
             for (int i = 0; i < num_pairs; i++) {
@@ -55,7 +55,7 @@
             }
             return length;
         }
-        
+
         public void resolve(ClassConstantPool pool) {
             type.resolve(pool);
             type_index = pool.indexOf(type);
@@ -75,22 +75,22 @@
                 element_values[i].writeBody(dos);
             }
         }
-        
+
     }
 
     public static class ElementValue {
-        
+
         private Object value;
         private int tag;
-        
+
         // resolved value index if it's a constant
         private int constant_value_index = -1;
-    
+
         public ElementValue(int tag, Object value) {
             this.tag = tag;
             this.value = value;
         }
-        
+
         public void resolve(ClassConstantPool pool) {
             if(value instanceof CPConstant) {
                 ((CPConstant)value).resolve(pool);
@@ -100,7 +100,7 @@
                 constant_value_index = pool.indexOf((CPClass)value);
             } else if (value instanceof CPNameAndType) {
                 ((CPNameAndType)value).resolve(pool);
-            } else if (value instanceof Annotation) {            
+            } else if (value instanceof Annotation) {
                 ((Annotation)value).resolve(pool);
             } else if (value instanceof ElementValue[]) {
                 ElementValue[] nestedValues = (ElementValue[])value;
@@ -116,7 +116,7 @@
                 dos.writeShort(constant_value_index);
             } else if (value instanceof CPNameAndType) {
                 ((CPNameAndType)value).writeBody(dos);
-            } else if (value instanceof Annotation) {            
+            } else if (value instanceof Annotation) {
                 ((Annotation)value).writeBody(dos);
             } else if (value instanceof ElementValue[]) {
                 ElementValue[] nestedValues = (ElementValue[])value;
@@ -158,6 +158,6 @@
         super(attributeName);
     }
 
-    
+
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java Thu Jan 31 02:04:05 2008
@@ -62,7 +62,7 @@
      * when attributes are nested within other attributes - the outer attribute
      * needs to take the inner attribute headers into account when calculating
      * its length.
-     * 
+     *
      * @return int adjusted length
      */
     protected int getLengthIncludingHeader() {
@@ -76,7 +76,7 @@
     /**
      * Answer true if the receiver needs to have BCI renumbering applied to it;
      * otherwise answer false.
-     * 
+     *
      * @return boolean BCI renumbering required
      */
     public boolean hasBCIRenumbering() {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/BCIRenumberedAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/BCIRenumberedAttribute.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/BCIRenumberedAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/BCIRenumberedAttribute.java Thu Jan 31 02:04:05 2008
@@ -25,23 +25,23 @@
 public abstract class BCIRenumberedAttribute extends Attribute {
 
     protected boolean renumbered = false;
-    
+
     /* (non-Javadoc)
      * @see org.apache.harmony.pack200.bytecode.Attribute#hasBCIRenumbering()
      */
     public boolean hasBCIRenumbering() {
         return true;
     }
-    
+
     public BCIRenumberedAttribute(String attributeName) {
         super(attributeName);
     }
-    
+
     protected abstract int getLength();
     protected abstract void writeBody(DataOutputStream dos) throws IOException;
     public abstract String toString();
     protected abstract int[] getStartPCs();
-    
+
     /**
      * In Pack200, line number tables are BCI renumbered.
      * This method takes the byteCodeOffsets (which is
@@ -49,7 +49,7 @@
      * byte code array of each instruction) and updates the
      * start_pcs so that it points to the instruction index
      * itself, not the BCI renumbering of the instruction.
-     * 
+     *
      * @param byteCodeOffsets List of Integer offsets of the bytecode array
      */
     public void renumber(List byteCodeOffsets) {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ByteCode.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ByteCode.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ByteCode.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ByteCode.java Thu Jan 31 02:04:05 2008
@@ -124,22 +124,22 @@
 			for(int index = 0; index < nested.length; index++) {
 				int argLength = getNestedPosition(index)[1];
 				switch(argLength) {
-				
+
 				case 1:
 					setOperandByte(pool.indexOf(nested[index]), getNestedPosition(index)[0]);
 					break;
-					
-				case 2: 
+
+				case 2:
 					setOperand2Bytes(pool.indexOf(nested[index]), getNestedPosition(index)[0]);
 					break;
-				
+
 				case 4:
 					// TODO: need to handle wides?
 					SegmentUtils.debug("Need to handle wides");
 					// figure out and if so, handle and put a break here.
 					// break;
-				
-				default: 
+
+				default:
 					SegmentUtils.debug("Unhandled resolve " + this);
 				}
 			}
@@ -153,7 +153,7 @@
 	 * operand to be the appropriate values. All values in
 	 * operands[] will be masked with 0xFF so they fit into
 	 * a byte.
-	 * @param operands int[] rewrite operand bytes 
+	 * @param operands int[] rewrite operand bytes
 	 */
 	public void setOperandBytes(int[] operands) {
 		int firstOperandIndex = getByteCodeForm().firstOperandIndex();
@@ -162,23 +162,23 @@
 			// No operand rewriting permitted for this bytecode
 			throw new Error("Trying to rewrite " + this + " that has no rewrite");
 		}
-		
+
 		if(byteCodeFormLength != operands.length) {
 			throw new Error("Trying to rewrite " + this + " with " + operands.length + " but bytecode has length " + byteCodeForm.operandLength());
 		}
-		
+
 		for(int index=0; index < byteCodeFormLength; index++) {
 			rewrite[index + firstOperandIndex] = operands[index] & 0xFF;
 		}
 	}
-    
+
 	/**
 	 * Given an int operand, set the rewrite bytes for
 	 * that position and the one immediately following it
 	 * to a high-byte, low-byte encoding of the operand.
-	 * 
+	 *
 	 * @param operand int to set the rewrite bytes to
-	 * @param position int position in the operands of the 
+	 * @param position int position in the operands of the
 	 * 	rewrite bytes. For a rewrite array of {100, -1, -1, -1}
 	 *  position 0 is the first -1, position 1 is the second -1,
 	 *  etc.
@@ -190,15 +190,15 @@
 			// No operand rewriting permitted for this bytecode
 			throw new Error("Trying to rewrite " + this + " that has no rewrite");
 		}
-		
+
 		if(firstOperandIndex + position + 1 > byteCodeFormLength) {
 			throw new Error("Trying to rewrite " + this + " with an int at position " + position + " but this won't fit in the rewrite array");
 		}
-		
+
 	    rewrite[firstOperandIndex + position] = (operand & 0xFF00) >> 8;
 	    rewrite[firstOperandIndex + position + 1] = operand & 0xFF;
 	}
-	
+
 	/**
 	 * This is just like setOperandInt, but takes special care when the
 	 * operand is less than 0 to make sure it's written correctly.
@@ -218,9 +218,9 @@
 	 * Given an int operand, treat it as a byte and set
 	 * the rewrite byte for that position to that value.
 	 * Mask of anything beyond 0xFF.
-	 * 
+	 *
 	 * @param operand int to set the rewrite byte to (unsigned)
-	 * @param position int position in the operands of the 
+	 * @param position int position in the operands of the
 	 * 	rewrite bytes. For a rewrite array of {100, -1, -1, -1}
 	 *  position 0 is the first -1, position 1 is the second -1,
 	 *  etc.
@@ -232,29 +232,29 @@
 			// No operand rewriting permitted for this bytecode
 			throw new Error("Trying to rewrite " + this + " that has no rewrite");
 		}
-		
+
 		if(firstOperandIndex + position > byteCodeFormLength) {
 			throw new Error("Trying to rewrite " + this + " with an byte at position " + position + " but this won't fit in the rewrite array");
 		}
-		
-		rewrite[firstOperandIndex + position] = operand & 0xFF;		
+
+		rewrite[firstOperandIndex + position] = operand & 0xFF;
 	}
-	
-	
+
+
 	public String toString() {
 		return getByteCodeForm().getName();
 	}
-	
+
 	public void setNested(ClassFileEntry[] nested) {
 		this.nested = nested;
 	}
-	
+
 	/**
 	 * nestedPositions is an array of arrays of ints. Each
 	 * subarray specifies a position of a nested
 	 * element (from the nested[] array) and the length of
 	 * that element.
-	 * 
+	 *
 	 * For instance, one might have a nested of:
 	 * 	{CPClass java/lang/Foo, CPFloat 3.14}
 	 * The nestedPositions would then be:
@@ -265,17 +265,17 @@
 	 * occurrences of -1). The CPFloat will be resolved to
 	 * an int position and inserted at positions 2 and 3 of
 	 * the rewrite arguments.
-	 *  
+	 *
 	 * @param nestedPositions
 	 */
 	public void setNestedPositions(int[][] nestedPositions) {
 		this.nestedPositions = nestedPositions;
 	}
-	
+
 	public int[][] getNestedPositions() {
 		return nestedPositions;
 	}
-	
+
 	public int[] getNestedPosition(int index) {
 		return getNestedPositions()[index];
 	}
@@ -285,7 +285,7 @@
      * a multi-bytecode instruction (such as
      * aload0_putfield_super); otherwise, it will answer
      * false.
-     * 
+     *
      * @return boolean true if multibytecode, false otherwise
      */
 	public boolean hasMultipleByteCodes() {
@@ -298,10 +298,10 @@
      * to know where they are in order to calculate their
      * targets). This method lets the CodeAttribute specify
      * where the byte code is.
-     * 
+     *
      * Since there are no aload0+label instructions, this
      * method doesn't worry about multioperation bytecodes.
-     * 
+     *
      * @param byteCodeOffset int position in code array.
      */
     public void setByteCodeIndex(int byteCodeOffset) {
@@ -312,7 +312,7 @@
     public int getByteCodeIndex() {
         return byteCodeOffset;
     }
-    
+
     /**
      * Some ByteCodes (in particular, those with labels)
      * have to keep track of byteCodeTargets. These are
@@ -320,17 +320,17 @@
      * relative to the byteCodeOffset, but later get fixed
      * up to point to the absolute position in the CodeAttribute
      * array. This method sets the targets.
-     * 
+     *
      * @param byteCodeTarget int index in array
      */
     public void setByteCodeTargets(int[] byteCodeTargets) {
         this.byteCodeTargets = byteCodeTargets;
     }
-    
+
     public int[] getByteCodeTargets() {
         return byteCodeTargets;
     }
-    
+
     /**
      * Some ByteCodes (in particular, those with labels
      * need to be fixed up after all the bytecodes in the
@@ -346,23 +346,23 @@
      * Some bytecodes (the ones with variable lengths) can't
      * have a static rewrite array - they need the ability to
      * update the array. This method permits that.
-     * 
+     *
      * Note that this should not be called from bytecodes
      * which have a static rewrite; use the table in ByteCodeForm
      * instead to specify those rewrites.
-     * 
+     *
      * @param rewrite
      */
     public void setRewrite(int[] rewrite) {
         this.rewrite = rewrite;
     }
-    
+
     /**
      * Some bytecodes (the ones with variable lengths) can't
      * have a static rewrite array - they need the ability to
      * update the array. This method permits their associated
      * bytecode formst to query their rewrite array.
-     * 
+     *
      * Note that this should not be called from bytecodes
      * which have a static rewrite; use the table in ByteCodeForm
      * instead to specify those rewrites.

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java Thu Jan 31 02:04:05 2008
@@ -34,7 +34,7 @@
 		this.utf8 = new CPUTF8(name, ClassConstantPool.DOMAIN_NORMALASCIIZ);
 	}
 
-	
+
 	public boolean equals(Object obj) {
 		if (this == obj)
 			return true;
@@ -60,7 +60,7 @@
 		return new ClassFileEntry[] { utf8, };
 	}
 
-	
+
 	public int hashCode() {
 		final int PRIME = 31;
 		int result = 1;
@@ -81,12 +81,14 @@
 	public String getName() {
 		return name;
 	}
-	
+
 	protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeShort(index);
 	}
-	
+
    public String comparisonString() {
+       // TODO: what to do about inner classes?
+       if(name==null) {return "null:name (probably an inner class?)";};
         return getName();
    }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java Thu Jan 31 02:04:05 2008
@@ -26,7 +26,7 @@
 		this.value = value;
 	}
 
-	
+
 	public boolean equals(Object obj) {
 		if (this == obj)
 			return true;
@@ -43,7 +43,7 @@
 		return true;
 	}
 
-	
+
 	public int hashCode() {
 		final int PRIME = 31;
 		int result = 1;

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java Thu Jan 31 02:04:05 2008
@@ -25,12 +25,12 @@
         this.domain = ClassConstantPool.DOMAIN_DOUBLE;
 	}
 
-	
+
 	protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeDouble(getNumber().doubleValue());
 	}
 
-	
+
 	public String toString() {
 		return "Double: " + getValue();
 	}

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java Thu Jan 31 02:04:05 2008
@@ -36,13 +36,13 @@
 	}
 
 
-	
+
 	protected ClassFileEntry[] getNestedClassFileEntries() {
 		return new ClassFileEntry[] {className, nameAndType};
 	}
 
 
-	
+
 	protected void resolve(ClassConstantPool pool) {
 		super.resolve(pool);
 		nameAndTypeIndex = pool.indexOf(nameAndType);
@@ -54,13 +54,15 @@
 		dos.writeShort(nameAndTypeIndex);
 	}
 
-	
+
 	public String toString() {
 		return "FieldRef: " + className + "#" + nameAndType;
 	}
 
+    public String comparisonString() {
+        return (className.getName() + Character.MAX_VALUE) + nameAndType.descriptor + Character.MAX_VALUE + nameAndType.name;
+    }
 
-	
 	public int hashCode() {
 		final int PRIME = 31;
 		int result = 1;
@@ -70,7 +72,7 @@
 	}
 
 
-	
+
 	public boolean equals(Object obj) {
 		if (this == obj)
 			return true;

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java Thu Jan 31 02:04:05 2008
@@ -25,12 +25,12 @@
 	      this.domain = ClassConstantPool.DOMAIN_FLOAT;
 	}
 
-	
+
 	protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeFloat(getNumber().floatValue());
 	}
 
-	
+
 	public String toString() {
 		return "Float: " + getValue();
 	}

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java Thu Jan 31 02:04:05 2008
@@ -26,12 +26,12 @@
 		this.domain = ClassConstantPool.DOMAIN_INTEGER;
 	}
 
-	
+
 	protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeInt(getNumber().intValue());
 	}
 
-	
+
 	public String toString() {
 		return "Integer: " + getValue();
 	}

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInterfaceMethodRef.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInterfaceMethodRef.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInterfaceMethodRef.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInterfaceMethodRef.java Thu Jan 31 02:04:05 2008
@@ -28,7 +28,7 @@
 	 * for an invokeinterface call. This is equal to 1 + the
 	 * count of all the args, where longs and doubles count for
 	 * 2 and all others count for 1.
-	 * 
+	 *
 	 * @return integer count
 	 */
 	public int invokeInterfaceCount() {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java Thu Jan 31 02:04:05 2008
@@ -26,12 +26,12 @@
         this.domain = ClassConstantPool.DOMAIN_LONG;
 	}
 
-	
+
 	protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeLong(getNumber().longValue());
 	}
 
-	
+
 	public String toString() {
 		return "Long: " + getValue();
 	}

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java Thu Jan 31 02:04:05 2008
@@ -45,7 +45,7 @@
 	}
 
 
-	
+
 	protected ClassFileEntry[] getNestedClassFileEntries() {
 		int attributeCount = attributes.size();
 		ClassFileEntry[] entries = new ClassFileEntry[attributeCount+2];
@@ -58,7 +58,7 @@
 	}
 
 
-	
+
 	protected void resolve(ClassConstantPool pool) {
 		super.resolve(pool);
 		nameIndex = pool.indexOf(name);
@@ -69,12 +69,12 @@
 		}
 	}
 
-	
+
 	public String toString() {
 		return "Field: " + name + "(" + descriptor + ")";
 	}
 
-	
+
 	public int hashCode() {
 		final int PRIME = 31;
 		int result = 1;
@@ -86,7 +86,7 @@
 	}
 
 
-	
+
 	public boolean equals(Object obj) {
 		if (this == obj)
 			return true;
@@ -116,7 +116,7 @@
 	}
 
 
-	
+
 	protected void doWrite(DataOutputStream dos) throws IOException {
 		dos.writeShort(flags);
 		dos.writeShort(nameIndex);
@@ -127,7 +127,7 @@
 			Attribute attribute = (Attribute) attributes.get(i);
 			attribute.doWrite(dos);
 		}
-		
+
 	}
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java Thu Jan 31 02:04:05 2008
@@ -68,7 +68,7 @@
 		return new ClassFileEntry[] { name, descriptor };
 	}
 
-	
+
 	protected void resolve(ClassConstantPool pool) {
 		super.resolve(pool);
 		descriptorIndex = pool.indexOf(descriptor);
@@ -79,18 +79,18 @@
 	 * field_info { u2 access_flags; u2 name_index; u2 descriptor_index; u2
 	 * attributes_count; attribute_info attributes[attributes_count]; }
 	 */
-	
+
 	protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeShort(nameIndex);
 		dos.writeShort(descriptorIndex);
 	}
 
-	
+
 	public String toString() {
 		return "NameAndType: " + name + "(" + descriptor + ")";
 	}
 
-	
+
 	public int hashCode() {
 		final int PRIME = 31;
 		int result = 1;
@@ -99,7 +99,7 @@
 		return result;
 	}
 
-	
+
 	public boolean equals(Object obj) {
 		if (this == obj)
 			return true;
@@ -131,14 +131,14 @@
 	public int invokeInterfaceCount() {
 	    return 1 + SegmentUtils.countInvokeInterfaceArgs(descriptor.underlyingString());
 	}
-	
+
 
     /* (non-Javadoc)
      * @see org.apache.harmony.pack200.bytecode.ConstantPoolEntry#comparisonString()
      */
     public String comparisonString() {
         // First come those things which don't have an
-        // associated signature. Then come the native signatures, 
+        // associated signature. Then come the native signatures,
         // then finally the class signatures.
         // TODO: I think Character.MAX_VALUE is no longer the
         // biggest character, what with the weird codepage thing

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java Thu Jan 31 02:04:05 2008
@@ -81,13 +81,13 @@
         // This one is tricky. The sorting appears to be
         // done based on the indices of the method descriptor
         // and class name in the classpool *after* sorting them.
-       
+
        // If we haven't yet been resolved, just do a normal
        // compare (so things like .contains() work).
         if(!isResolved()) {
             return super.comparisonString();
         }
-        
+
         // If we get here, the receiver has been resolved; there
         // is a different sort order.
         StringBuffer result = new StringBuffer();
@@ -95,7 +95,7 @@
         int padLength = 6;
         int classIndexLength = ("" + classNameIndex).length();
         int nameAndTypeIndexLength = ("" + nameAndTypeIndex).length();
-        
+
         for(int index=0; index < (padLength - classIndexLength); index++) {
             result.append('0');
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java Thu Jan 31 02:04:05 2008
@@ -30,19 +30,19 @@
 
 	}
 
-	
+
 	protected void writeBody(DataOutputStream dos) throws IOException {
 		dos.writeShort(nameIndex);
 	}
 
-	
+
 	public String toString() {
 		return "String: " + getValue();
 	}
 
 	/**
 	 * Allows the constant pool entries to resolve their nested entries
-	 * 
+	 *
 	 * @param pool
 	 */
 	protected void resolve(ClassConstantPool pool) {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java Thu Jan 31 02:04:05 2008
@@ -44,7 +44,7 @@
 			return false;
 		return true;
 	}
-	
+
 	public int hashCode() {
 		final int PRIME = 31;
 		int result = 1;
@@ -76,7 +76,7 @@
 	public String underlyingString() {
 	    return utf8;
 	}
-	
+
 	public String comparisonString() {
 	    // Should use either normalComparisonString or signatureComparisonString.
 	    // If we get here, that might indicate an error.
@@ -84,10 +84,14 @@
 	}
 
 	public String normalComparisonString() {
+	   // TODO: what to do about inner classes?
+	   if(utf8==null) {return "null:utf8 (probably an inner class?)";};
         return utf8;
     }
 
     public String signatureComparisonString() {
+        // TODO: what to do about inner classes?
+        if(utf8==null) {return "null:utf8 (probably an inner class?)";};
         StringBuffer alphaChars = new StringBuffer();
         StringBuffer extraChars = new StringBuffer();
         if(utf8.length() > 0){

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java Thu Jan 31 02:04:05 2008
@@ -17,7 +17,6 @@
 package org.apache.harmony.pack200.bytecode;
 
 import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 
@@ -26,41 +25,7 @@
 
 
 public class ClassConstantPool {
-    
-    class PoolComparator implements Comparator {
-        /* (non-Javadoc)
-         * Note: this comparator imposes orderings that are inconsistent with equals.
-         * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
-         */
-        public int compare(Object o1, Object o2) {
-            // If we compare anything other than ConstantPoolEntries
-            // with this comparator, it is an error.
-            ConstantPoolEntry cpe1 = (ConstantPoolEntry)o1;
-            ConstantPoolEntry cpe2 = (ConstantPoolEntry)o2;
-
-            int domain1 = cpe1.getDomain();
-            int domain2 = cpe2.getDomain();
-            
-            if(domain1 < domain2) {
-                return -1;
-            }
-            if(domain1 > domain2) {
-                return 1;
-            }
-            
-            // Domains must be the same, need to compare
-            // based on name.
-            // TODO: what means name?
-            String compare1 = cpe1.comparisonString();
-            String compare2 = cpe2.comparisonString();
-            return compare1.compareTo(compare2);
-//            if(cpe1.creationOrder < cpe2.creationOrder) {
-//                return -1;
-//            } else {
-//                return 1;
-//            }
-        }
-    }
+
     // These are the domains in sorted order.
     public static int DOMAIN_UNDEFINED = 0;
     public static int DOMAIN_INTEGER = 1;
@@ -92,11 +57,11 @@
 		// We don't want duplicates.
 		// Only add in constant pools, but resolve all types since they may
 		// introduce new constant pool entries
-// This is a handy way to see what's adding a ClassFileEntry - set a breakpoint on the print 
-//	    if(entry instanceof CPUTF8) {
-//	        System.out.println("AAH:" + ((CPUTF8)entry).comparisonString());
+// This is a handy way to see what's adding a ClassFileEntry - set a breakpoint on the print
+//	    if(entry instanceof CPFieldRef) {
+//	        SegmentUtils.debug("AAH:" + ((CPFieldRef)entry).comparisonString());
 //	        if (((CPUTF8)entry).underlyingString().matches("Code")) {
-//	            System.out.println("Adding");
+//	            SegmentUtils.debug("Adding");
 //	        }
 //	    }
 		if (entry instanceof ConstantPoolEntry) {
@@ -156,7 +121,7 @@
       }
 		resolve();
 	}
-	
+
 	public void resolve() {
 		resolved= true;
 		Iterator it = entries.iterator();
@@ -169,7 +134,7 @@
 			ClassFileEntry entry = (ClassFileEntry) it.next();
 			entry.resolve(this);
 		}
-		
+
 		// Now that everything has been resolved, do one
 		// final sort of the class pool. This fixes up
 		// references, which are sorted by index in the
@@ -189,4 +154,22 @@
 		}
 	}
 
+	/**
+	 * Answer the collection of CPClasses currently held
+	 * by the ClassPoolSet. This is used to calculate relevant
+	 * classes when generating the set of relevant inner
+	 * classes (ic_relevant())
+	 * @return ArrayList collection of all classes.
+	 *
+	 * NOTE: when this list is answered, the classes may not
+	 * yet be resolved.
+	 */
+	public List allClasses() {
+	    List classesList = new ArrayList();
+	    Iterator it = classPoolSet.partialIterator(DOMAIN_CLASSREF, DOMAIN_CLASSREF);
+	    while(it.hasNext()) {
+	        classesList.add(it.next());
+	    }
+	    return classesList;
+	}
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java Thu Jan 31 02:04:05 2008
@@ -35,7 +35,7 @@
 
 	/**
 	 * Allows the constant pool entries to resolve their nested entries
-	 * 
+	 *
 	 * @param pool
 	 */
 	protected void resolve(ClassConstantPool pool) {
@@ -45,7 +45,7 @@
 	protected boolean isResolved() {
 	    return resolved;
 	}
-	
+
 	public abstract String toString();
 
 	public final void write(DataOutputStream dos) throws IOException {



Mime
View raw message