harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r646264 [8/13] - in /harmony/enhanced/classlib/branches/java6: depends/build/ depends/build/platform/ depends/files/ modules/accessibility/ modules/annotation/ modules/applet/ modules/archive/ modules/archive/src/main/java/java/util/jar/ mo...
Date Wed, 09 Apr 2008 11:02:07 GMT
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=646264&r1=646263&r2=646264&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 Wed Apr  9 04:01:14 2008
@@ -31,11 +31,21 @@
 
 	transient int nameIndex;
 
+	/**
+	 * Create a new CPNameAndType
+	 * @param name
+	 * @param descriptor
+	 * @param domain
+	 * @throws NullPointerException if name or descriptor is null
+	 */
 	public CPNameAndType(CPUTF8 name, CPUTF8 descriptor, int domain) {
 		super(ConstantPoolEntry.CP_NameAndType);
 		this.name = name;
 		this.descriptor = descriptor;
         this.domain = domain;
+        if(name == null || descriptor == null) {
+            throw new NullPointerException("Null arguments are not allowed");
+        }
 	}
 
 	protected ClassFileEntry[] getNestedClassFileEntries() {
@@ -67,8 +77,8 @@
 	public int hashCode() {
 		final int PRIME = 31;
 		int result = 1;
-		result = PRIME * result + ((descriptor == null) ? 0 : descriptor.hashCode());
-		result = PRIME * result + ((name == null) ? 0 : name.hashCode());
+		result = PRIME * result + descriptor.hashCode();
+		result = PRIME * result + name.hashCode();
 		return result;
 	}
 
@@ -81,15 +91,9 @@
 		if (getClass() != obj.getClass())
 			return false;
 		final CPNameAndType other = (CPNameAndType) obj;
-		if (descriptor == null) {
-			if (other.descriptor != null)
-				return false;
-		} else if (!descriptor.equals(other.descriptor))
+		if (!descriptor.equals(other.descriptor))
 			return false;
-		if (name == null) {
-			if (other.name != null)
-				return false;
-		} else if (!name.equals(other.name))
+		if (!name.equals(other.name))
 			return false;
 		return true;
 	}
@@ -104,43 +108,4 @@
 	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,
-        // then finally the class signatures.
-        // TODO: I think Character.MAX_VALUE is no longer the
-        // biggest character, what with the weird codepage thing
-        // going on. How to sort these things so that even if
-        // they're in some oddball codepage they'll still end
-        // up sorted correctly?
-        String descriptorString = descriptor.underlyingString();
-        StringBuffer comparisonBuffer = new StringBuffer();
-        if((descriptorString.indexOf("(")) == -1) {
-            // it's a variable reference
-            comparisonBuffer.append(descriptor.underlyingString());
-        } else {
-            // it's a signature. Append something that will
-            // make the comparison buffer bigger than all
-            // non-signature references.
-            comparisonBuffer.append(Character.MAX_VALUE);
-            // do the natives first
-            if(descriptorString.length() <= 4) {
-                // it's a native signature
-                comparisonBuffer.append(descriptor.underlyingString());
-            } else {
-                // it's a non-native signature. Append something
-                // that will make the comparison buffer bigger
-                // than all native signature references.
-                comparisonBuffer.append(Character.MAX_VALUE);
-                comparisonBuffer.append(descriptor.underlyingString());
-            }
-        }
-        comparisonBuffer.append(name.underlyingString());
-        return comparisonBuffer.toString();
-    }
 }

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=646264&r1=646263&r2=646264&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 Wed Apr  9 04:01:14 2008
@@ -27,10 +27,20 @@
 	protected CPNameAndType nameAndType;
 	transient int nameAndTypeIndex;
 
+    /**
+	 * Create a new CPRef
+	 * @param type
+	 * @param className
+	 * @param descriptor
+	 * @throws NullPointerException if descriptor or className is null
+	 */
 	public CPRef(byte type, CPClass className, CPNameAndType descriptor) {
 		super(type);
 		this.className = className;
 		this.nameAndType = descriptor;
+		if(descriptor == null || className == null) {
+            throw new NullPointerException("Null arguments are not allowed");
+		}
 	}
 
 	public boolean equals(Object obj) {
@@ -40,16 +50,13 @@
 			return false;
 		if (getClass() != obj.getClass())
 			return false;
+		if (this.hashCode() != obj.hashCode()) {
+		    return false;
+		}
 		final CPRef other = (CPRef) obj;
-		if (className == null) {
-			if (other.className != null)
-				return false;
-		} else if (!className.equals(other.className))
+		if (!className.equals(other.className))
 			return false;
-		if (nameAndType == null) {
-			if (other.nameAndType != null)
-				return false;
-		} else if (!nameAndType.equals(other.nameAndType))
+		if (!nameAndType.equals(other.nameAndType))
 			return false;
 		return true;
 	}
@@ -62,13 +69,8 @@
 	}
 
 	public int hashCode() {
-		final int PRIME = 31;
-		int result = 1;
-		result = PRIME * result
-				+ ((className == null) ? 0 : className.hashCode());
-		result = PRIME * result
-				+ ((nameAndType == null) ? 0 : nameAndType.hashCode());
-		return result;
+		final int PRIME = 37;
+		return (PRIME * className.hashCode()) + nameAndType.hashCode();
 	}
 
 	protected void resolve(ClassConstantPool pool) {
@@ -77,49 +79,22 @@
 		classNameIndex = pool.indexOf(className);
 	}
 
-   public String comparisonString() {
-        // 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();
-        // Pad all numbers to 6 digits so they sort correctly.
-        int padLength = 6;
-        int classIndexLength = ("" + classNameIndex).length();
-        int nameAndTypeIndexLength = ("" + nameAndTypeIndex).length();
-
-        for(int index=0; index < (padLength - classIndexLength); index++) {
-            result.append('0');
-        }
-        result.append("" + classNameIndex);
-        result.append(":");
-        for(int index=0; index < (padLength - nameAndTypeIndexLength); index++) {
-            result.append('0');
-        }
-        result.append("" + nameAndTypeIndex);
-        return result.toString();
-    }
-
+    protected String cachedToString = null;
 	public String toString() {
-		String type;
-		if (getTag() == ConstantPoolEntry.CP_Fieldref) {
-			type = "FieldRef"; //$NON-NLS-1$
-		} else if (getTag() == ConstantPoolEntry.CP_Methodref) {
-			type = "MethoddRef"; //$NON-NLS-1$
-		} else if (getTag() == ConstantPoolEntry.CP_InterfaceMethodref) {
-			type = "InterfaceMethodRef"; //$NON-NLS-1$
-		} else {
-			type = "unknown"; //$NON-NLS-1$
-		}
-		return type + ": " + className + "#" + nameAndType; //$NON-NLS-1$ //$NON-NLS-2$
+	    if(cachedToString == null) {
+	        String type;
+	        if (getTag() == ConstantPoolEntry.CP_Fieldref) {
+	            type = "FieldRef"; //$NON-NLS-1$
+	        } else if (getTag() == ConstantPoolEntry.CP_Methodref) {
+	            type = "MethoddRef"; //$NON-NLS-1$
+	        } else if (getTag() == ConstantPoolEntry.CP_InterfaceMethodref) {
+	            type = "InterfaceMethodRef"; //$NON-NLS-1$
+	        } else {
+	            type = "unknown"; //$NON-NLS-1$
+	        }
+	        cachedToString = type + ": " + className + "#" + nameAndType; //$NON-NLS-1$ //$NON-NLS-2$
+	    }
+		return cachedToString;
 	}
 
 	protected void writeBody(DataOutputStream dos) throws IOException {

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=646264&r1=646263&r2=646264&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 Wed Apr  9 04:01:14 2008
@@ -52,8 +52,4 @@
 	protected ClassFileEntry[] getNestedClassFileEntries() {
 		return new ClassFileEntry[] { name };
  	}
-
-	public String comparisonString() {
-	    return ((CPUTF8)getValue()).underlyingString();
-	}
 }

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=646264&r1=646263&r2=646264&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 Wed Apr  9 04:01:14 2008
@@ -22,8 +22,14 @@
 
 public class CPUTF8 extends ConstantPoolEntry {
 
-    private String utf8;
+    private final String utf8;
 
+    /**
+     * Creates a new CPUTF8 instance
+     * @param utf8
+     * @param domain
+     * @throws NullPointerException if utf8 is null
+     */
     public CPUTF8(String utf8, int domain) {
 		super(ConstantPoolEntry.CP_UTF8);
 		this.utf8 = utf8;
@@ -31,6 +37,9 @@
         if(domain == ClassConstantPool.DOMAIN_UNDEFINED) {
             throw new RuntimeException();
         }
+        if(utf8 == null) {
+            throw new NullPointerException("Null arguments are not allowed");
+        }
 	}
 
 	public boolean equals(Object obj) {
@@ -41,19 +50,12 @@
 		if (this.getClass() != obj.getClass())
 			return false;
 		final CPUTF8 other = (CPUTF8) obj;
-		if (utf8 == null) {
-			if (other.utf8 != null)
-				return false;
-		} else if (!utf8.equals(other.utf8))
-			return false;
-		return true;
+		return utf8.equals(other.utf8);
 	}
 
 	public int hashCode() {
 		final int PRIME = 31;
-		int result = 1;
-		result = PRIME * result + ((utf8 == null) ? 0 : utf8.hashCode());
-		return result;
+		return PRIME + utf8.hashCode();
 	}
 
 	public String toString() {
@@ -64,11 +66,7 @@
 		byte[] bytes;
 		try {
 			// TODO Check that this is the right UTF-8 for bytes
-			if (utf8 == null) {
-				bytes = new byte[0];
-			} else {
-				bytes = utf8.getBytes("UTF-8");
-			}
+			bytes = utf8.getBytes("UTF-8");
 		} catch (UnsupportedEncodingException e) {
 			throw new RuntimeException("Couldn't convert string " + utf8
 					+ " to UTF-8");
@@ -80,42 +78,4 @@
 	public String underlyingString() {
 	    return utf8;
 	}
-
-	public String comparisonString() {
-	    // Should use either normalComparisonString or signatureComparisonString.
-	    // If we get here, that might indicate an error.
-	    throw new Error("Should use specific kinds of comparisonString() on CPUTF8s");
-	}
-
-	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){
-            if(utf8.charAt(0) == '(') {
-                // Things with return values (which apparently
-                // always begin with '(') sort after things
-                // without return values.
-                // TODO: need a better way for this - possibly in the comparator?
-                alphaChars.append(Character.MAX_VALUE);
-            }
-        }
-        // TODO: need a better way for this - possibly in the comparator?
-        extraChars.append(Character.MAX_VALUE);
-        for(int index=0; index < utf8.length(); index++) {
-            if( (utf8.charAt(index) == '(') || (utf8.charAt(index) == ')') || (utf8.charAt(index) == '[') || (utf8.charAt(index) == ']') ) {
-                extraChars.append(utf8.charAt(index));
-            } else {
-                alphaChars.append(utf8.charAt(index));
-            }
-        }
-        return(alphaChars.toString() + extraChars.toString());
-    }
 }

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=646264&r1=646263&r2=646264&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 Wed Apr  9 04:01:14 2008
@@ -17,8 +17,11 @@
 package org.apache.harmony.pack200.bytecode;
 
 import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.harmony.pack200.Segment;
 
@@ -26,130 +29,191 @@
 public class ClassConstantPool {
 
     // These are the domains in sorted order.
-    public static int DOMAIN_UNDEFINED = 0;
-    public static int DOMAIN_INTEGER = 1;
-    public static int DOMAIN_FLOAT = 2;
-    public static int DOMAIN_STRING = 3;
-    public static int DOMAIN_NORMALASCIIZ = 4;
-    public static int DOMAIN_LONG = 5;
-    public static int DOMAIN_DOUBLE = 6;
-    public static int DOMAIN_CLASSREF = 7;
-    public static int DOMAIN_SIGNATUREASCIIZ = 8;
-    public static int DOMAIN_NAMEANDTYPE = 9;
-    public static int DOMAIN_FIELD = 10;
-    public static int DOMAIN_METHOD = 11;
-    public static int DOMAIN_ATTRIBUTEASCIIZ = 12;
-    public static int NUM_DOMAINS = DOMAIN_ATTRIBUTEASCIIZ + 1;
-
-//    protected SortedSet sortedEntries = new TreeSet(new PoolComparator());
-    protected ClassPoolSet classPoolSet = new ClassPoolSet();
-	public String toString() {
-		return entries.toString();
-	}
-	private List others = new ArrayList();
-
-	private List entries = new ArrayList();
-
-	private boolean resolved;
-
-	public ClassFileEntry add(ClassFileEntry entry) {
-		// We don't want duplicates.
-		// Only add in constant pools, but resolve all types since they may
-		// introduce new constant pool entries
+    public static final int DOMAIN_UNDEFINED = 0;
+    public static final int DOMAIN_INTEGER = 1;
+    public static final int DOMAIN_FLOAT = 2;
+    public static final int DOMAIN_STRING = 3;
+    public static final int DOMAIN_NORMALASCIIZ = 4;
+    public static final int DOMAIN_LONG = 5;
+    public static final int DOMAIN_DOUBLE = 6;
+    public static final int DOMAIN_CLASSREF = 7;
+    public static final int DOMAIN_SIGNATUREASCIIZ = 8;
+    public static final int DOMAIN_NAMEANDTYPE = 9;
+    public static final int DOMAIN_FIELD = 10;
+    public static final int DOMAIN_METHOD = 11;
+    public static final int DOMAIN_ATTRIBUTEASCIIZ = 12;
+    public static final int NUM_DOMAINS = DOMAIN_ATTRIBUTEASCIIZ + 1;
+
+    protected HashSet entriesContainsSet = new HashSet();
+    protected HashSet othersContainsSet = new HashSet();
+
+    protected Map indexCache = null;
+
+    public String toString() {
+        return entries.toString();
+    }
+    private List others = new ArrayList(500);
+    private List entries = new ArrayList(500);
+
+    private boolean resolved;
+
+    public ClassFileEntry add(ClassFileEntry entry) {
+        // 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 CPFieldRef) {
-//	        SegmentUtils.debug("AAH:" + ((CPFieldRef)entry).comparisonString());
-//	        if (((CPUTF8)entry).underlyingString().matches("Code")) {
-//	            SegmentUtils.debug("Adding");
-//	        }
-//	    }
-		if (entry instanceof ConstantPoolEntry) {
-            classPoolSet.add(entry);
-			if (!entries.contains(entry)) {
-				entries.add(entry);
-				if (entry instanceof CPLong ||entry instanceof CPDouble)
-					entries.add(entry); //these get 2 slots because of their size
-			}
-		} else {
-			if (!others.contains(entry))
-				others.add(entry);
-		}
-		ClassFileEntry[] nestedEntries = entry.getNestedClassFileEntries();
-		for (int i = 0; i < nestedEntries.length; i++) {
-			add(nestedEntries[i]);
-		}
-		return entry;
-	}
-
-	public int indexOf(ClassFileEntry entry) {
-		if (!resolved)
-			throw new IllegalStateException("Constant pool is not yet resolved; this does not make any sense");
-		int entryIndex = entries.indexOf(entry);
-		// If the entry isn't found, answer -1. Otherwise answer the entry.
-		if(entryIndex != -1) {
-		    return entryIndex + 1;
-		}
-		return -1;
-	}
-
-	public int size() {
-		return entries.size();
-	}
-
-	public ClassFileEntry get(int i) {
-		if (!resolved)
-			throw new IllegalStateException("Constant pool is not yet resolved; this does not make any sense");
-		return (ClassFileEntry) entries.get(--i);
-	}
-
-	public void resolve(Segment segment) {
-	    entries = new ArrayList();
-      Iterator sortedIterator = classPoolSet.iterator();
-      while(sortedIterator.hasNext()) {
-          ConstantPoolEntry entry = (ConstantPoolEntry)sortedIterator.next();
-          entries.add(entry);
-          // need to do this both here and in the sort below
-          // so the indices are correct.
-          if (entry instanceof CPLong ||entry instanceof CPDouble)
-              entries.add(entry); //these get 2 slots because of their size
+//      if(entry instanceof CPLong) {
+//          org.apache.harmony.pack200.SegmentUtils.debug("AAH:" + ((CPUTF8)entry).underlyingString());
+//          if (((CPUTF8)entry).underlyingString().indexOf('\b') != -1) {
+//          boolean halt = false;
+//          for(int index=0; index < entries.size(); index++) {
+//              ClassFileEntry foo = (ClassFileEntry)(entries.get(index));
+//              if(foo instanceof CPUTF8) {
+//                 if(((CPUTF8)foo).underlyingString().matches(".*MRUBundleFileList.java.*"))  {
+//                      halt = true;
+//                  }
+//
+//              }
+//          }
+//      }
+        if (entry instanceof ConstantPoolEntry) {
+          if (!entriesContainsSet.contains(entry)) {
+                entriesContainsSet.add(entry);
+                entries.add(entry);
+            }
+        } else {
+          if (!othersContainsSet.contains(entry)) {
+                othersContainsSet.add(entry);
+                others.add(entry);
+          }
+
+        }
+        ClassFileEntry[] nestedEntries = entry.getNestedClassFileEntries();
+        for (int i = 0; i < nestedEntries.length; i++) {
+            add(nestedEntries[i]);
+        }
+        return entry;
+    }
+
+    protected void initializeIndexCache() {
+        indexCache = new HashMap();
+        for(int index=0; index < entries.size(); index++) {
+            ClassFileEntry indexEntry = (ClassFileEntry)entries.get(index);
+            if(indexCache.containsKey(indexEntry)) {
+                // key is already in there - do nothing
+                // This will happen if a long or double
+                // is the entry - they take up 2 slots.
+            } else {
+                indexCache.put(indexEntry, new Integer(index));
+            }
+        }
+    }
+
+    public int indexOf(ClassFileEntry entry) {
+        if (!resolved)
+            throw new IllegalStateException("Constant pool is not yet resolved; this does not make any sense");
+        if(null == indexCache) {
+            initializeIndexCache();
+        }
+        Integer entryIndex = ((Integer)indexCache.get(entry));
+        // If the entry isn't found, answer -1. Otherwise answer the entry.
+        if(entryIndex != null) {
+            return entryIndex.intValue() + 1;
+        }
+        return -1;
+    }
+
+    public int size() {
+        return entries.size();
+    }
+
+    public ClassFileEntry get(int i) {
+        if (!resolved)
+            throw new IllegalStateException("Constant pool is not yet resolved; this does not make any sense");
+        return (ClassFileEntry) entries.get(--i);
+    }
+
+    public void resolve(Segment segment) {
+        Iterator it;
+      resolved= true;
+      it = entries.iterator();
+      while (it.hasNext()) {
+          ClassFileEntry entry = (ClassFileEntry) it.next();
+          entry.resolve(this);
       }
-		resolve();
-	}
+      it = others.iterator();
+      while (it.hasNext()) {
+          ClassFileEntry entry = (ClassFileEntry) it.next();
+          entry.resolve(this);
+      }
+
+      sortClassPool(segment);
+    }
 
-	public void resolve() {
-		resolved= true;
-		Iterator it = entries.iterator();
-		while (it.hasNext()) {
-			ClassFileEntry entry = (ClassFileEntry) it.next();
-			entry.resolve(this);
-		}
-		it = others.iterator();
-		while (it.hasNext()) {
-			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
-		// class pool.
-		it = entries.iterator();
-		ClassPoolSet finalSort = new ClassPoolSet();
-		while(it.hasNext()) {
-		    finalSort.add(it.next());
-		}
-		it = finalSort.iterator();
-		entries = new ArrayList();
-		while(it.hasNext()) {
-		    ClassFileEntry entry = (ClassFileEntry) it.next();
-		    entries.add(entry);
-	        if (entry instanceof CPLong ||entry instanceof CPDouble)
-	            entries.add(entry); //these get 2 slots because of their size
-		}
-		
-		// Now that the indices have been re-sorted, need
-		// to re-resolve to update references. This should
-		// not add any new entries this time through.
+    /**
+     * 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 = entries.iterator();
+        while(it.hasNext()) {
+            ConstantPoolEntry entry = (ConstantPoolEntry)it.next();
+            if(entry.getDomain() == DOMAIN_CLASSREF) {
+                classesList.add(entry);
+            }
+        }
+        return classesList;
+    }
+
+    protected void sortClassPool(Segment segment) {
+        // Now that everything has been resolved, do one
+        // final sort of the class pool. This fixes up
+        // references to objects which need to be at the
+        // start of the class pool
+
+        // Since we resorted, need to initialize index cache
+        initializeIndexCache();
+
+        Iterator it = entries.iterator();
+        ArrayList startOfPool = new ArrayList();
+        ArrayList finalSort = new ArrayList();
+        while(it.hasNext()) {
+            ClassFileEntry nextEntry = (ClassFileEntry)it.next();
+            if(nextEntry.mustStartClassPool()) {
+                startOfPool.add(nextEntry);
+            } else {
+                finalSort.add(nextEntry);
+            }
+        }
+        entries = new ArrayList(entries.size());
+        Iterator itStart = startOfPool.iterator();
+        while(itStart.hasNext()) {
+            ClassFileEntry entry = (ClassFileEntry) itStart.next();
+            entries.add(entry);
+            if (entry instanceof CPLong ||entry instanceof CPDouble)
+                entries.add(entry); //these get 2 slots because of their size
+        }
+        it = finalSort.iterator();
+        while(it.hasNext()) {
+            ClassFileEntry entry = (ClassFileEntry) it.next();
+            entries.add(entry);
+            if (entry instanceof CPLong ||entry instanceof CPDouble)
+                entries.add(entry); //these get 2 slots because of their size
+        }
+
+        // Since we resorted, need to initialize index cache
+        initializeIndexCache();
+
+        // Now that the indices have been re-sorted, need
+        // to re-resolve to update references. This should
+        // not add any new entries this time through.
         it = entries.iterator();
         while(it.hasNext()) {
             ClassFileEntry entry = (ClassFileEntry)it.next();
@@ -161,24 +225,5 @@
             ClassFileEntry entry = (ClassFileEntry)it.next();
             entry.resolve(this);
         }
-	}
-
-	/**
-	 * 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=646264&r1=646263&r2=646264&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 Wed Apr  9 04:01:14 2008
@@ -54,4 +54,15 @@
 		doWrite(dos);
 	}
 
+    /**
+     * Answer true if the receiver must be at the beginning
+     * of the class pool (because it is the target of a
+     * single-byte ldc command). Otherwise answer false.
+     *
+     * @return boolean true if the receiver must be under
+     *   256; otherwise false.
+     */
+    public boolean mustStartClassPool() {
+        return false;
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java Wed Apr  9 04:01:14 2008
@@ -101,9 +101,18 @@
         ArrayList nestedEntries = new ArrayList();
         nestedEntries.add(getAttributeName());
         nestedEntries.addAll(byteCodes);
-        // TODO: Is this the right place to add code attribute
-        // attributes?
         nestedEntries.addAll(attributes);
+        // Don't forget to add the ExceptionTable catch_types
+        for (Iterator iter = exceptionTable.iterator(); iter.hasNext();) {
+            ExceptionTableEntry entry = (ExceptionTableEntry) iter.next();
+            CPClass catchType = entry.getCatchType();
+            // If the catch type is null, this is a finally
+            // block. If it's not null, we need to add the
+            // CPClass to the list of nested class file entries.
+            if(catchType != null) {
+                nestedEntries.add(catchType);
+            }
+        }
         ClassFileEntry[] nestedEntryArray = new ClassFileEntry[nestedEntries
                 .size()];
         nestedEntries.toArray(nestedEntryArray);

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java Wed Apr  9 04:01:14 2008
@@ -57,14 +57,9 @@
 	byte tag;
 
 	protected int domain = ClassConstantPool.DOMAIN_UNDEFINED;
-	public static int creationOrderCount = 100;
-	public String comparisonString() {
-	    return toString();
-	}
-	public int creationOrder = -1;
+
 	ConstantPoolEntry(byte tag) {
 		this.tag = tag;
-		this.creationOrder = creationOrderCount++;
 	}
 
 	public abstract boolean equals(Object obj);
@@ -89,4 +84,25 @@
 	}
 
 	protected abstract void writeBody(DataOutputStream dos) throws IOException;
+
+	private boolean mustStartClassPool = false;
+    /**
+     * Set whether the receiver must be at the start of the
+     * class pool. Anything which is the target of a single-
+     * byte ldc (bytecode 18) command must be at the start
+     * of the class pool.
+     *
+     * @param b boolean true if the receiver must be at
+     * the start of the class pool, otherwise false.
+     */
+    public void mustStartClassPool(boolean b) {
+        mustStartClassPool = b;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.bytecode.ClassFileEntry#mustStartClassPool()
+     */
+    public boolean mustStartClassPool() {
+        return mustStartClassPool;
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java Wed Apr  9 04:01:14 2008
@@ -32,6 +32,22 @@
     private int handlerPcRenumbered;
     private int catchTypeIndex;
 
+    /**
+     * Create a new ExceptionTableEntry. Exception tables are
+     * of two kinds: either a normal one (with a Throwable as
+     * the catch_type) or a finally clause (which has no
+     * catch_type). In the class file, the finally clause is
+     * represented as catch_type == 0.
+     *
+     * To create a finally clause with this method, pass in
+     * null for the catchType.
+     *
+     * @param startPC int
+     * @param endPC int
+     * @param handlerPC int
+     * @param catchType CPClass (if it's a normal catch) or null
+     *  (if it's a finally clause).
+     */
     public ExceptionTableEntry(int startPC, int endPC, int handlerPC, CPClass catchType) {
         this.startPC = startPC;
         this.endPC = endPC;
@@ -54,7 +70,17 @@
         handlerPcRenumbered = ((Integer)byteCodeOffsets.get(handlerPcIndex)).intValue();
     }
 
+    public CPClass getCatchType() {
+        return catchType;
+    }
+
     public void resolve(ClassConstantPool pool) {
+        if(catchType == null) {
+            // If the catch type is a finally clause
+            // the index is always 0.
+            catchTypeIndex = 0;
+            return;
+        }
         catchType.resolve(pool);
         catchTypeIndex = pool.indexOf(catchType);
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java Wed Apr  9 04:01:14 2008
@@ -21,7 +21,7 @@
 import java.util.Arrays;
 
 public class ExceptionsAttribute extends Attribute {
-    
+
     private static final CPUTF8 attributeName = new CPUTF8(
             "Exceptions", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
 
@@ -39,7 +39,7 @@
 
 	private transient int[] exceptionIndexes;
 
-	private CPClass[] exceptions;
+	private final CPClass[] exceptions;
 
 	public ExceptionsAttribute(CPClass[] exceptions) {
 		super(attributeName);
@@ -89,7 +89,7 @@
 	}
 
 	public String toString() {
-		return "Exceptions:" + exceptions;
+		return "Exceptions: " + exceptions;
 	}
 
 	protected void writeBody(DataOutputStream dos) throws IOException {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/InnerClassesAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/InnerClassesAttribute.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/InnerClassesAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/InnerClassesAttribute.java Wed Apr  9 04:01:14 2008
@@ -26,12 +26,12 @@
 
 
 public class InnerClassesAttribute extends Attribute {
-    
+
     private static final CPUTF8 attributeName = new CPUTF8(
             "InnerClasses", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
 
 
-    class InnerClassesEntry {
+    private static class InnerClassesEntry {
         CPClass inner_class_info;
         CPClass outer_class_info;
         CPUTF8 inner_class_name;
@@ -42,7 +42,7 @@
         int inner_class_access_flags = -1;
 
         public InnerClassesEntry(IcTuple icTuple) {
-            this(icTuple.C, icTuple.C2, icTuple.N, icTuple.F);
+            this(icTuple.getC(), icTuple.getC2(), icTuple.getN(), icTuple.getF());
         }
 
         public InnerClassesEntry(String innerString, String outerString, String nameString, int flags) {
@@ -93,8 +93,8 @@
 
     }
 
-    private List innerClasses = new ArrayList();
-    private List nestedClassFileEntries = new ArrayList();
+    private final List innerClasses = new ArrayList();
+    private final List nestedClassFileEntries = new ArrayList();
 
     public InnerClassesAttribute(String name) {
         super(attributeName);

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTableAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTableAttribute.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTableAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LocalVariableTableAttribute.java Wed Apr  9 04:01:14 2008
@@ -21,16 +21,18 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.harmony.pack200.Pack200Exception;
+
 public class LocalVariableTableAttribute extends BCIRenumberedAttribute {
 
     private int local_variable_table_length;
-    private int[] start_pcs;
-    private int[] lengths;
+    private final int[] start_pcs;
+    private final int[] lengths;
     private int[] name_indexes;
     private int[] descriptor_indexes;
-    private int[] indexes;
-    private CPUTF8[] names;
-    private CPUTF8[] descriptors;
+    private final int[] indexes;
+    private final CPUTF8[] names;
+    private final CPUTF8[] descriptors;
     private static final CPUTF8 attributeName = new CPUTF8(
             "LocalVariableTable", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
 
@@ -98,7 +100,7 @@
     /* (non-Javadoc)
      * @see org.apache.harmony.pack200.bytecode.BCIRenumberedAttribute#renumber(java.util.List)
      */
-    public void renumber(List byteCodeOffsets) {
+    public void renumber(List byteCodeOffsets) throws Pack200Exception {
         // Remember the unrenumbered start_pcs, since that's used later
         // to calculate end position.
         int[] unrenumbered_start_pcs = new int[start_pcs.length];
@@ -131,7 +133,7 @@
             // the encodedLength to it to get the stop index.
             int stopIndex = indexOfStartPC + encodedLength;
             if(stopIndex < 0) {
-                System.out.println(stopIndex);
+                throw new Pack200Exception("Error renumbering bytecode indexes");
             }
             // Length can either be an index into the byte code offsets, or one beyond the
             // end of the byte code offsets. Need to determine which this is.

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java Wed Apr  9 04:01:14 2008
@@ -48,6 +48,13 @@
 		return true;
 	}
 
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.bytecode.Attribute#isSourceFileAttribute()
+     */
+    public boolean isSourceFileAttribute() {
+        return true;
+    }
+
 	protected int getLength() {
 		return 2;
 	}

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java Wed Apr  9 04:01:14 2008
@@ -16,7 +16,10 @@
  */
 package org.apache.harmony.pack200.bytecode.forms;
 
+import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.SegmentConstantPool;
+import org.apache.harmony.pack200.bytecode.ByteCode;
+import org.apache.harmony.pack200.bytecode.ClassFileEntry;
 import org.apache.harmony.pack200.bytecode.OperandManager;
 
 /**
@@ -38,6 +41,26 @@
         this.widened = widened;
     }
 
+    protected void setNestedEntries(ByteCode byteCode, OperandManager operandManager, int offset) throws Pack200Exception {
+        // If the offset is not zero, proceed normally.
+        if(offset != 0) {
+            super.setNestedEntries(byteCode, operandManager, offset - 1);
+            return;
+        }
+        // If the offset is 0, ClassRefForms refer to
+        // the current class. Add that as the nested class.
+        // (This is true for all bc_classref forms in
+        // the spec except for multianewarray, which has
+        // its own form.)
+        SegmentConstantPool globalPool = operandManager.globalConstantPool();
+        ClassFileEntry[] nested = null;
+        // How do I get this class?
+        nested = new ClassFileEntry[] {
+                globalPool.getClassPoolEntry(operandManager.getCurrentClass())
+            };
+        byteCode.setNested(nested);
+        byteCode.setNestedPositions(new int[][] {{0,2}});
+    }
     public int getOperandType() {
         return TYPE_CLASSREF;
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/MultiANewArrayForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/MultiANewArrayForm.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/MultiANewArrayForm.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/MultiANewArrayForm.java Wed Apr  9 04:01:14 2008
@@ -23,7 +23,7 @@
  * This class implements the byte code form for the
  * multianewarray instruction. It has a class reference
  * and a byte operand.
- * 
+ *
  * MultiANewArrayForms (like other anewarray
  * forms) do not track the last new().
  */

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NarrowClassRefForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NarrowClassRefForm.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NarrowClassRefForm.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NarrowClassRefForm.java Wed Apr  9 04:01:14 2008
@@ -18,6 +18,7 @@
 
 import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.bytecode.ByteCode;
+import org.apache.harmony.pack200.bytecode.CPClass;
 import org.apache.harmony.pack200.bytecode.OperandManager;
 
 /**
@@ -40,6 +41,7 @@
         super.setNestedEntries(byteCode, operandManager, offset);
         if(!widened) {
             byteCode.setNestedPositions(new int[][] {{0,1}});
+            ((CPClass)byteCode.getNestedClassFileEntries()[0]).mustStartClassPool(true);
         }
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NewClassRefForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NewClassRefForm.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NewClassRefForm.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NewClassRefForm.java Wed Apr  9 04:01:14 2008
@@ -58,7 +58,9 @@
         } else {
             // Look up the class in the classpool
             try {
-                setNestedEntries(byteCode, operandManager, offset - 1);
+                // Parent takes care of subtracting one from offset
+                // to adjust for 1-based global pool
+                setNestedEntries(byteCode, operandManager, offset);
             } catch (Pack200Exception ex) {
                 throw new Error("Got a pack200 exception. What to do?");
             }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/SingleByteReferenceForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/SingleByteReferenceForm.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/SingleByteReferenceForm.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/SingleByteReferenceForm.java Wed Apr  9 04:01:14 2008
@@ -18,6 +18,7 @@
 
 import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.bytecode.ByteCode;
+import org.apache.harmony.pack200.bytecode.ConstantPoolEntry;
 import org.apache.harmony.pack200.bytecode.OperandManager;
 
 /**
@@ -45,6 +46,7 @@
             byteCode.setNestedPositions(new int[][] {{0,2}});
         } else {
             byteCode.setNestedPositions(new int[][] {{0,1}});
+            ((ConstantPoolEntry)byteCode.getNestedClassFileEntries()[0]).mustStartClassPool(true);
         }
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/StringRefForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/StringRefForm.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/StringRefForm.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/StringRefForm.java Wed Apr  9 04:01:14 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.harmony.pack200.bytecode.forms;
 
-import org.apache.harmony.pack200.CpBands;
 import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.SegmentConstantPool;
 import org.apache.harmony.pack200.bytecode.ByteCode;
@@ -68,6 +67,7 @@
             byteCode.setNestedPositions(new int[][]{{0, 2}});
         } else {
             byteCode.setNestedPositions(new int[][]{{0, 1}});
+            ((CPString)nested[0]).mustStartClassPool(true);
         }
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java Wed Apr  9 04:01:14 2008
@@ -24,9 +24,6 @@
 import java.util.jar.JarOutputStream;
 import java.util.jar.Pack200.Unpacker;
 
-import org.apache.harmony.pack200.Pack200Exception;
-import org.apache.harmony.pack200.Segment;
-
 /**
  * This class provides the binding between the standard Pack200 interface and
  * the internal interface for (un)packing. As this uses generics for the
@@ -47,8 +44,7 @@
 		completed(0);
 		try {
 			while (in.available() > 0) {
-				Segment s = Segment.parse(in);
-				s.writeJar(out);
+			    new Segment().unpack(in, out);
 				out.flush();
 			}
 		} catch (Pack200Exception e) {

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AbstractBandsTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AbstractBandsTestCase.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AbstractBandsTestCase.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AbstractBandsTestCase.java Wed Apr  9 04:01:14 2008
@@ -34,7 +34,11 @@
     protected int[] numMethods = {1};
 
     public class MockSegmentHeader extends SegmentHeader {
-        public int getClassCount() {
+        public MockSegmentHeader(Segment segment) {
+			super(segment);
+		}
+
+		public int getClassCount() {
             return numClasses;
         }
 
@@ -73,7 +77,7 @@
         }
 
         public SegmentHeader getSegmentHeader() {
-            return new MockSegmentHeader();
+            return new MockSegmentHeader(this);
         }
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java Wed Apr  9 04:01:14 2008
@@ -33,11 +33,13 @@
 
     InputStream in;
     JarOutputStream out;
+    File file;
 
     public void testJustResourcesGZip() throws Exception {
-       in = Archive.class
+        in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("Just", "ResourcesGz.jar")));
+        file = File.createTempFile("Just", "ResourcesGz.jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -46,7 +48,8 @@
     public void testWithSqlE1() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/sql-e1.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("sql-e1", ".jar")));
+        file = File.createTempFile("sql-e1", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -55,7 +58,8 @@
     public void testWithSql() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("sql", ".jar")));
+        file = File.createTempFile("sql", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -64,7 +68,8 @@
     public void testWithPack200E1() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/pack200-e1.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("pack", "200-e1.jar")));
+        file = File.createTempFile("p200-e1", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -73,7 +78,8 @@
     public void testWithPack200() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/pack200.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("pack", "200.jar")));
+        file = File.createTempFile("p200", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -82,7 +88,8 @@
     public void testWithJNDIE1() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/jndi-e1.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("jndi", "-e1.jar")));
+        file = File.createTempFile("jndi-e1", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -91,7 +98,8 @@
     public void testWithAnnotations() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/annotations.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("ann", "otations.jar")));
+        file = File.createTempFile("annotations", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -100,8 +108,8 @@
     public void testWithE0() throws Exception  {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/simple-E0.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile(
-                "simpleE0", ".jar")));
+        file = File.createTempFile("simple-e0", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -111,31 +119,29 @@
     public void testWithLargeClass() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/LargeClass.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile(
-                "largeclass", ".jar")));
+        file = File.createTempFile("largeClass", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
 
     protected void tearDown() throws Exception {
         super.tearDown();
-        try {
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        } finally {
+        if (in != null) {
             try {
-                if (out != null) {
-                    out.close();
-                }
+                in.close();
             } catch (IOException e) {
                 e.printStackTrace();
             }
         }
+        try {
+            if (out != null) {
+                out.close();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        file.delete();
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BHSDCodecTest.java Wed Apr  9 04:01:14 2008
@@ -17,6 +17,7 @@
 package org.apache.harmony.pack200.tests;
 
 import java.io.ByteArrayInputStream;
+import java.io.EOFException;
 import java.io.IOException;
 
 import junit.framework.TestCase;
@@ -36,15 +37,24 @@
 
             BHSDCodec codec = (BHSDCodec) CodecEncoding.getCodec(i, null, null);
 
-            // Test encode-decode with a selection of numbers within the range of the codec
-            long delta = (codec.largest() - codec.smallest()) / 4;
-            for (long j = codec.smallest(); j <= codec.largest() + 1; j += delta) {
-                byte[] encoded = codec.encode(j, 0);
-                long decoded = codec.decode(new ByteArrayInputStream(encoded),
-                        0);
-                if (j != decoded) {
-                    fail("Failed with codec: " + codec + " expected: " + j
-                            + ", got: " + decoded);
+            if(!codec.isDelta()) {
+                // Test encode-decode with a selection of numbers within the range of the codec
+                long largest = codec.largest();
+                long smallest = codec.isSigned() ? codec.smallest() : 0;
+                long difference = (largest - smallest) / 4;
+                for (long j = smallest; j <= largest; j += difference) {
+                    byte[] encoded = codec.encode(j, 0);
+                    long decoded = 0;
+                    try {
+                        decoded = codec.decode(new ByteArrayInputStream(encoded),
+                                0);
+                    } catch (EOFException e) {
+                        System.out.println(e);
+                    }
+                    if (j != decoded) {
+                        fail("Failed with codec: " + i + ", " + codec + " expected: " + j
+                                + ", got: " + decoded);
+                    }
                 }
             }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java Wed Apr  9 04:01:14 2008
@@ -19,7 +19,6 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 
 import junit.framework.TestCase;
 
@@ -34,14 +33,11 @@
 
     public class MockSegment extends Segment {
         public SegmentHeader getSegmentHeader() {
-            return new SegmentHeader();
+            return new SegmentHeader(this);
         }
     }
 
-    private BandSet bandSet = new BandSet(new MockSegment()) {
-
-        public void pack(OutputStream outputStream) {
-        }
+    private final BandSet bandSet = new BandSet(new MockSegment()) {
 
         public void unpack(InputStream inputStream) throws IOException, Pack200Exception {
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ClassVersionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ClassVersionTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ClassVersionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ClassVersionTest.java Wed Apr  9 04:01:14 2008
@@ -47,6 +47,7 @@
 		din.readShort(); // MINOR -- don't care
 		assertTrue("Class file has been compiled with Java 1.5 compatibility"
 				+ " instead of 1.4 or lower", din.readShort() < JAVA_15);
+		din.close();
 	}
 
 	public void testCorrectVersionOfAdapter() throws IOException {
@@ -61,6 +62,7 @@
 			din.readShort(); // MINOR -- don't care
 			assertTrue("Class file needs 1.5 compatibility",
 					din.readShort() >= JAVA_15);
+			din.close();
 		}
 	}
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ICTupleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ICTupleTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ICTupleTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ICTupleTest.java Wed Apr  9 04:01:14 2008
@@ -22,61 +22,33 @@
 public class ICTupleTest extends TestCase {
 
     public void testPredictedClassTupleParsing() {
-        IcTuple tuple = new IcTuple();
-        tuple.C = "orw/SimpleHelloWorld$SimpleHelloWorldInner";
-        tuple.C2 = null;
-        tuple.F = 0;
-        tuple.N = null;
+        IcTuple tuple = new IcTuple("orw/SimpleHelloWorld$SimpleHelloWorldInner", 0, null, null);
         assertEquals("SimpleHelloWorldInner", tuple.simpleClassName());
         assertEquals("orw/SimpleHelloWorld", tuple.outerClassString());
 
-        tuple = new IcTuple();
-        tuple.C = "java/util/AbstractList$2$Local";
-        tuple.C2 = null;
-        tuple.F = 0;
-        tuple.N = null;
+        tuple = new IcTuple("java/util/AbstractList$2$Local", 0, null, null);
         assertEquals("Local", tuple.simpleClassName());
         assertEquals("java/util/AbstractList$2", tuple.outerClassString());
 
-        tuple = new IcTuple();
-        tuple.C = "java/util/AbstractList#2#Local";
-        tuple.C2 = null;
-        tuple.F = 0;
-        tuple.N = null;
+        tuple = new IcTuple("java/util/AbstractList#2#Local", 0, null, null);
         assertEquals("Local", tuple.simpleClassName());
         assertEquals("java/util/AbstractList$2", tuple.outerClassString());
 
-        tuple = new IcTuple();
-        tuple.C = "java/util/AbstractList$1";
-        tuple.C2 = null;
-        tuple.F = 0;
-        tuple.N = null;
+        tuple = new IcTuple("java/util/AbstractList$1", 0, null, null);
         assertEquals("1", tuple.simpleClassName());
         assertEquals("java/util/AbstractList", tuple.outerClassString());
     }
 
     public void testExplicitClassTupleParsing() {
-        IcTuple tuple = new IcTuple();
-        tuple.C = "Foo$$2$Local";
-        tuple.C2 = null;
-        tuple.F = IcTuple.NESTED_CLASS_FLAG;
-        tuple.N = "$2$Local";
+        IcTuple tuple = new IcTuple("Foo$$2$Local", IcTuple.NESTED_CLASS_FLAG, null, "$2$Local");
         assertEquals("$2$Local", tuple.simpleClassName());
-        assertEquals(null, tuple.outerClassString());
+        assertEquals("Foo$$2", tuple.outerClassString());
 
-        tuple = new IcTuple();
-        tuple.C = "Red$Herring";
-        tuple.C2 = "Red$Herring";
-        tuple.F = IcTuple.NESTED_CLASS_FLAG;
-        tuple.N = null;
-        assertEquals(null, tuple.simpleClassName());
+        tuple = new IcTuple("Red$Herring", IcTuple.NESTED_CLASS_FLAG, "Red$Herring", null);
+        assertEquals("Herring", tuple.simpleClassName());
         assertEquals("Red$Herring", tuple.outerClassString());
 
-        tuple = new IcTuple();
-        tuple.C = "X$1$Q";
-        tuple.C2 = "X$1";
-        tuple.F = IcTuple.NESTED_CLASS_FLAG;
-        tuple.N = "Q";
+        tuple = new IcTuple("X$1$Q", IcTuple.NESTED_CLASS_FLAG, "X$1", "Q");
         assertEquals("Q", tuple.simpleClassName());
         assertEquals("X$1", tuple.outerClassString());
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentConstantPoolTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentConstantPoolTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentConstantPoolTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentConstantPoolTest.java Wed Apr  9 04:01:14 2008
@@ -39,6 +39,10 @@
         public int matchSpecificPoolEntryIndex(String[] classNameArray, String[] methodNameArray, String desiredClassName, String desiredMethodRegex, int desiredIndex) {
         	return super.matchSpecificPoolEntryIndex(classNameArray, methodNameArray, desiredClassName, desiredMethodRegex, desiredIndex);
         };
+
+        public boolean regexMatchesVisible(String regexString, String compareString) {
+            return SegmentConstantPool.regexMatches(regexString, compareString);
+        }
     }
 
 	String[] testClassArray = {"Object", "Object" , "java/lang/String", "java/lang/String", "Object", "Other" };
@@ -65,20 +69,27 @@
 	public void testMatchSpecificPoolEntryIndex_DoubleArray() throws Exception {
 		MockSegmentConstantPool mockInstance = new MockSegmentConstantPool();
 		// Elements should be found at the proper position.
-		assertEquals(0, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "Object", "<init>.*", 0));
-		assertEquals(1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "Object", "clone.*", 0));
-		assertEquals(2, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "java/lang/String", "equals.*", 0));
-		assertEquals(3, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "java/lang/String", "<init>.*", 0));
-		assertEquals(4, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "Object", "isNull.*", 0));
-		assertEquals(5, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "Other", "Other", 0));
+		assertEquals(0, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "Object", "^<init>.*", 0));
+		assertEquals(2, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "java/lang/String", ".*", 0));
+		assertEquals(3, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "java/lang/String", "^<init>.*", 0));
+		assertEquals(5, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "Other", ".*", 0));
 
 		// Elements that don't exist shouldn't be found
-		assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "NotThere", "NotThere", 0));
-		assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "Object", "NotThere", 0));
+		assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "NotThere", "^<init>.*", 0));
 
 		// Elements that exist but don't have the requisite number
 		// of hits shouldn't be found.
-		assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "java/lang/String", "<init>.*", 1));
+		assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "java/lang/String", "^<init>.*", 1));
 	}
 
+	public void testRegexReplacement() {
+	    MockSegmentConstantPool mockPool = new MockSegmentConstantPool();
+	    assertTrue(mockPool.regexMatchesVisible(".*", "anything"));
+        assertTrue(mockPool.regexMatchesVisible(".*", ""));
+        assertTrue(mockPool.regexMatchesVisible("^<init>.*", "<init>"));
+        assertTrue(mockPool.regexMatchesVisible("^<init>.*", "<init>stuff"));
+        assertFalse(mockPool.regexMatchesVisible("^<init>.*", "init>stuff"));
+        assertFalse(mockPool.regexMatchesVisible("^<init>.*", "<init"));
+        assertFalse(mockPool.regexMatchesVisible("^<init>.*", ""));
+	}
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java Wed Apr  9 04:01:14 2008
@@ -34,57 +34,64 @@
  */
 public class SegmentTest extends TestCase {
 
-    InputStream in;
-    JarOutputStream out;
+	InputStream in;
+	JarOutputStream out;
 
-    public void testHelloWorld() throws Exception {
-        in = Segment.class
-                .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorld.pack");
-        Segment segment = Segment.parse(in);
-        assertNotNull(segment);
-        File file = File.createTempFile("hello", "world.jar");
-        out = new JarOutputStream(new FileOutputStream(file));
-        segment.writeJar(out);
-        out.close();
-        out = null;
-        JarFile jarFile = new JarFile(file);
-        JarEntry entry = jarFile.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
-        assertNotNull(entry);
-        Process process = Runtime.getRuntime().exec("java -cp " + file.getName() + " org.apache.harmony.archive.tests.internal.pack200.HelloWorld", new String[] {}, file.getParentFile());
-        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
-        String line = reader.readLine();
-        assertEquals(line, "Hello world");
-    }
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		try {
+			if (in != null) {
+				in.close();
+			}
+		} finally {
+			if (out != null) {
+				out.close();
+			}
+		}
+	}
 
-    public void testJustResources() throws Exception {
-        in = Segment.class
-                .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack");
-        Segment segment = Segment.parse(in);
-        assertNotNull(segment);
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("just", "resources.jar")));
-        segment.writeJar(out);
-    }
+	public void testJustResources() throws Exception {
+		in = Segment.class
+				.getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack");
+		out = new JarOutputStream(new FileOutputStream(File.createTempFile(
+				"just", "resources.jar")));
+		Segment segment = new Segment();
+		segment.unpack(in, out);
+	}
 
-     public void testInterfaceOnly() throws Exception {
-        in = Segment.class
-                .getResourceAsStream("/org/apache/harmony/pack200/tests/InterfaceOnly.pack");
-        Segment segment = Segment.parse(in);
-        assertNotNull(segment);
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("Interface", "Only.jar")));
-        segment.writeJar(out);
-    }
+	public void testInterfaceOnly() throws Exception {
+		in = Segment.class
+				.getResourceAsStream("/org/apache/harmony/pack200/tests/InterfaceOnly.pack");
+		out = new JarOutputStream(new FileOutputStream(File.createTempFile(
+				"Interface", "Only.jar")));
+		Segment segment = new Segment();
+		segment.unpack(in, out);
+	}
 
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        try {
-            if (in != null) {
-                in.close();
-            }
-        } finally {
-            if (out != null) {
-                out.close();
-            }
-        }
-    }
+	public void testHelloWorld() throws Exception {
+		in = Segment.class
+				.getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorld.pack");
+		File file = File.createTempFile("hello", "world.jar");
+		out = new JarOutputStream(new FileOutputStream(file));
+		Segment segment = new Segment();
+		segment.unpack(in, out);
+		out.close();
+		out = null;
+		JarFile jarFile = new JarFile(file);
+		JarEntry entry = jarFile
+				.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
+		assertNotNull(entry);
+		Process process = Runtime
+				.getRuntime()
+				.exec(
+						"java -cp "
+								+ file.getName()
+								+ " org.apache.harmony.archive.tests.internal.pack200.HelloWorld",
+						new String[] {}, file.getParentFile());
+		BufferedReader reader = new BufferedReader(new InputStreamReader(
+				process.getInputStream()));
+		String line = reader.readLine();
+		assertEquals(line, "Hello world");
+	}
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ClassFileEntryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ClassFileEntryTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ClassFileEntryTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ClassFileEntryTest.java Wed Apr  9 04:01:14 2008
@@ -39,7 +39,7 @@
 	private void checkEquality(Object equal1, Object equal2, String toString, Object unequal) {
 		assertEquals(equal1,equal2);
 		assertEquals(equal1.hashCode(),equal2.hashCode());
-		assertTrue(equal1.toString().indexOf(toString)>=0); 
+		assertTrue(equal1.toString().indexOf(toString)>=0);
 		assertFalse(equal1.equals(unequal));
 		assertFalse(equal2.equals(unequal));
 		assertFalse(unequal.equals(equal1));

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java Wed Apr  9 04:01:14 2008
@@ -18,7 +18,8 @@
 
 import junit.framework.TestCase;
 
-import org.apache.harmony.pack200.CpBands;
+import org.apache.harmony.pack200.Segment;
+import org.apache.harmony.pack200.bytecode.CPClass;
 import org.apache.harmony.pack200.bytecode.CPMember;
 import org.apache.harmony.pack200.bytecode.CPUTF8;
 import org.apache.harmony.pack200.bytecode.ClassConstantPool;
@@ -48,7 +49,13 @@
 		pool.add(new CPUTF8("OtherThing", ClassConstantPool.DOMAIN_NORMALASCIIZ));
 		CPUTF8 u1 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
 		pool.add(u1);
-		pool.resolve();
+		pool.resolve(new Segment());
 		assertTrue(pool.indexOf(u1) > 0);
+	}
+
+	public void testAllClasses() {
+	    pool.add(new CPClass(new CPUTF8("RandomClass", ClassConstantPool.DOMAIN_NORMALASCIIZ)));
+        pool.add(new CPClass(new CPUTF8("RandomClass2", ClassConstantPool.DOMAIN_NORMALASCIIZ)));
+	    assertEquals(2, pool.allClasses().size());
 	}
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/build.xml Wed Apr  9 04:01:14 2008
@@ -121,17 +121,22 @@
         <!-- Build thread dll -->
         <make dir="${hy.portlib.src.main.native}/thread/${hy.os.family}" />
 
+        <antcall target="-build-copy-thread" />
+
+        <!-- Copy link exports file on z/OS -->
+        <copy todir="${hy.hdk}/lib" overwrite="yes">
+            <fileset dir="${hy.portlib.src.main.native}/thread/${hy.os.family}">
+                <include name="*${linklib.suffix}" if="is.zos" />
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="-build-copy-thread" unless="hy.thr.nodeploy">
         <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
             <fileset dir="${hy.portlib.src.main.native}/thread">
                 <include name="*${shlib.suffix}*" />
                 <include name="*${progdb.suffix}*" if="is.windows" />
                 <exclude name="*${manifest.suffix}"/>
-            </fileset>
-        </copy>
-        <!-- Copy link exports file on z/OS -->
-        <copy todir="${hy.hdk}/lib" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/thread/${hy.os.family}">
-                <include name="*${linklib.suffix}" if="is.zos" />
             </fileset>
         </copy>
     </target>

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/common/shared/iohelp.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/common/shared/iohelp.c?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/common/shared/iohelp.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/common/shared/iohelp.c Wed Apr  9 04:01:14 2008
@@ -52,7 +52,7 @@
   if ((pathIndex > path) && (length > (pathIndex - path))
       && (*(pathIndex + 1) == ':'))
     {
-      /* For Example '////c:/*' */
+      /* For Example '////c:/!*' (! added to avoid gcc warning) */
       int newlen = length - (pathIndex - path);
       memmove (path, pathIndex, newlen);
       path[newlen] = '\0';
@@ -61,7 +61,7 @@
     {
       if ((pathIndex - path > 3) && (length > (pathIndex - path)))
         {
-          /* For Example '////serverName/*' */
+          /* For Example '////serverName/!*' (! added to avoid gcc warning) */
           int newlen = length - (pathIndex - path) + 2;
           memmove (path, pathIndex - 2, newlen);
           path[newlen] = '\0';

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/hyerrorhelpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/hyerrorhelpers.c?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/hyerrorhelpers.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/hyerrorhelpers.c Wed Apr  9 04:01:14 2008
@@ -30,6 +30,7 @@
 #undef CDEV_CURRENT_FUNCTION
 
 #include <string.h>
+#include <stdio.h>
 #include "portpriv.h"
 #include "portnls.h"
 #include "hyportptb.h"

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/hyosdump.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/hyosdump.c?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/hyosdump.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/hyosdump.c Wed Apr  9 04:01:14 2008
@@ -315,7 +315,7 @@
     {
       pidStore[0] = '-';
       /* this env var is set to append a unique identifier to the dump file name */
-      itoa (GetCurrentProcessId (), &pidStore[1], 10);
+      _itoa (GetCurrentProcessId (), &pidStore[1], 10);
     }
   else
     {

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thread/windows/thrdsup.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thread/windows/thrdsup.h?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thread/windows/thrdsup.h (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thread/windows/thrdsup.h Wed Apr  9 04:01:14 2008
@@ -60,8 +60,9 @@
 /* THREAD_SELF */
 #define THREAD_SELF() (GetCurrentThread())
 /* THREAD_YIELD */
-
+#if !defined(_WIN32_WINNT)
 #define _WIN32_WINNT 0x0400
+#endif
 #define THREAD_YIELD() (f_yield())
 
 /* THREAD_CREATE */

Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml Wed Apr  9 04:01:14 2008
@@ -127,7 +127,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/prefs.jar"
-             manifest="${hy.prefs}/META-INF/MANIFEST.MF">
+             manifest="${hy.prefs}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 

Modified: harmony/enhanced/classlib/branches/java6/modules/print/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/print/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/print/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/print/build.xml Wed Apr  9 04:01:14 2008
@@ -133,7 +133,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/${hy.print.packaging.jarname}.jar"
-             manifest="${hy.print}/META-INF/MANIFEST.MF">
+             manifest="${hy.print}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <metainf prefix="META-INF/services"
                 dir="${hy.print.src.main.java}/org/apache/harmony/x/print"
                 includes="javax.print.StreamPrintServiceFactory"/>

Modified: harmony/enhanced/classlib/branches/java6/modules/regex/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/regex/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/regex/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/regex/build.xml Wed Apr  9 04:01:14 2008
@@ -100,7 +100,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/regex.jar"
-            manifest="${hy.regex}/META-INF/MANIFEST.MF">
+             manifest="${hy.regex}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 

Modified: harmony/enhanced/classlib/branches/java6/modules/rmi/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/rmi/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/rmi/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/rmi/build.xml Wed Apr  9 04:01:14 2008
@@ -101,7 +101,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/${hy.rmi.packaging.jarname}.jar"
-             manifest="${hy.rmi}/META-INF/MANIFEST.MF">
+             manifest="${hy.rmi}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 

Modified: harmony/enhanced/classlib/branches/java6/modules/security/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/build.xml Wed Apr  9 04:01:14 2008
@@ -159,7 +159,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/${hy.security.packaging.jarname}.jar"
-             manifest="${hy.security}/META-INF/MANIFEST.MF">
+             manifest="${hy.security}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Security.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Security.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Security.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Security.java Wed Apr  9 04:01:14 2008
@@ -361,7 +361,11 @@
         if (sm != null) {
             sm.checkSecurityAccess("getProperty." + key); //$NON-NLS-1$
         }
-        return secprops.getProperty(key);
+        String property = secprops.getProperty(key);
+        if (property != null) {
+            property = property.trim();
+        }
+        return property;
     }
 
 	/**



Mime
View raw message