harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qi...@apache.org
Subject svn commit: r756095 [2/3] - in /harmony/enhanced/classlib/branches/java6: depends/build/ depends/files/ depends/oss/ make/ make/freebsd.x86/ make/macosx.ppc32/ modules/archive/src/main/native/archive/shared/ modules/auth/ modules/auth/src/main/native/a...
Date Thu, 19 Mar 2009 17:10:53 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c Thu Mar 19 17:10:51 2009
@@ -378,3 +378,47 @@
 
   return (jint) nbytes;
 }
+
+
+/**
+ * A helper method, call selectRead with a small timeout until read is ready or an error occurs.
+ *
+ * @param	env						pointer to the JNI library
+ * @param	hysocketP				socket pointer
+ * @param	timeout				timeout value
+ */
+
+I_32
+pollSelectRead (JNIEnv * env, jobject fileDescriptor, jint timeout,
+                BOOLEAN poll)
+{
+
+  I_32 result;
+  hysocket_t hysocketP;
+  PORT_ACCESS_FROM_ENV (env);
+
+  hysocketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
+  if (!hysock_socketIsValid (hysocketP))
+    {
+      throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_BADSOCKET);
+      return (jint) - 1;
+    }
+
+  if (0 == timeout)
+    {
+      result = hysock_select_read (hysocketP, 0, 0, FALSE);
+    }
+  else
+    {
+      result =
+        hysock_select_read (hysocketP, timeout / 1000,
+                            (timeout % 1000) * 1000, FALSE);
+    }
+  if (HYPORT_ERROR_SOCKET_TIMEOUT == result)
+    throwJavaIoInterruptedIOException (env, result);
+  else if (0 > result)
+    throwJavaNetSocketException (env, result);
+
+  return result;
+}
+

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/IntegerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/IntegerTest.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/IntegerTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/IntegerTest.java Thu Mar 19 17:10:51 2009
@@ -509,6 +509,15 @@
                 -Integer.MAX_VALUE));
         assertEquals("Returned incorrect octal string", "-2147483648", Integer.toString(
                 Integer.MIN_VALUE));
+        
+        // Test for HARMONY-6068
+        assertEquals("Returned incorrect octal String", "-1000", Integer.toString(-1000));
+        assertEquals("Returned incorrect octal String", "1000", Integer.toString(1000));
+        assertEquals("Returned incorrect octal String", "0", Integer.toString(0));
+        assertEquals("Returned incorrect octal String", "708", Integer.toString(708));
+        assertEquals("Returned incorrect octal String", "-100", Integer.toString(-100));
+        assertEquals("Returned incorrect octal String", "-1000000008", Integer.toString(-1000000008));
+        assertEquals("Returned incorrect octal String", "2000000008", Integer.toString(2000000008));
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java Thu Mar 19 17:10:51 2009
@@ -93,8 +93,8 @@
                 }
 
                 socket.setSoTimeout(5000);
-                socket.accept();
-
+                Socket client = socket.accept();
+                client.close();
                 socket.close();
             } catch (IOException e) {
                 e.printStackTrace();

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URITest.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URITest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URITest.java Thu Mar 19 17:10:51 2009
@@ -1612,6 +1612,17 @@
                 "file:///~/first"), b.relativize(a));
     }
 
+    // Regression test for HARMONY-6075
+    public void test_relativize3() throws Exception {
+        URI uri = new URI("file", null, "/test/location", null);
+
+        URI base = new URI("file", null, "/test", null);
+
+        URI relative = base.relativize(uri);
+        assertEquals("location", relative.getSchemeSpecificPart());
+        assertNull(relative.getScheme());
+    }
+
     /**
      * @tests java.net.URI#relativize(java.net.URI)
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArraysTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArraysTest.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArraysTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArraysTest.java Thu Mar 19 17:10:51 2009
@@ -1297,8 +1297,7 @@
 	/**
 	 * @tests java.util.Arrays#sort(java.lang.Object[], java.util.Comparator)
 	 */
-    @SuppressWarnings("unchecked")
-    public void test_sort$Ljava_lang_ObjectLjava_util_Comparator() {
+	public void test_sort$Ljava_lang_ObjectLjava_util_Comparator() {
 		// Test for method void java.util.Arrays.sort(java.lang.Object [],
 		// java.util.Comparator)
 		ReversedIntegerComparator comp = new ReversedIntegerComparator();
@@ -1308,53 +1307,51 @@
 					comp
 							.compare(objectArray[counter],
 									objectArray[counter + 1]) <= 0);
-        
-        // Test the sort functionailty with an Integer array
-        int[] original = { 190, 180, 170, 160, 150, 140, 120, 320, 110, 310,
-                100, 300, 290, 280, 270, 260, 250, 240, 230, 210, 200 };
-        Integer[] sorted = { 100, 110, 120, 140, 150, 160, 170, 180, 190, 200,
-                210, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320 };
-
-        Integer[] elements = new Integer[original.length];
-        for (int i=0; i < original.length; i++){
-            elements[i] = new Integer(original[i]);
-        }
-        
-        Comparator normalComparator = new Comparator(){
-            public int compare(Object o1, Object o2) {
-                Integer e1 = (Integer)o1;
-                Integer e2 = (Integer)o2;
-                if (e1 > e2){
-                    return 1;
-                }else if(e1 < e2){
-                    return -1;
-                }else{
-                    return 0;
-                }
+	}
+
+    // Regression HARMONY-6076
+    public void test_sort$Ljava_lang_ObjectLjava_util_Comparator_stable() {
+        Element[] array = new Element[11];
+        array[0] = new Element(122);
+        array[1] = new Element(146);
+        array[2] = new Element(178);
+        array[3] = new Element(208);
+        array[4] = new Element(117);
+        array[5] = new Element(146);
+        array[6] = new Element(173);
+        array[7] = new Element(203);
+        array[8] = new Element(56);
+        array[9] = new Element(208);
+        array[10] = new Element(96);
+
+        Comparator<Element> comparator = new Comparator<Element>() {
+            public int compare(Element object1, Element object2) {
+                return object1.value - object2.value;
             }
         };
-        Arrays.sort(elements, normalComparator);
-        // After sorting, elements should be the same as sorted array.
-        for(int i = 0; i < original.length; i++){
-            assertEquals(sorted[i],elements[i]);
-        }
 
-        for (int i=0; i < original.length; i++){
-            elements[i] = new Integer(original[i]);
-        }
-        Comparator comparator = new Comparator(){
-            public int compare(Object o1, Object o2) {
-                Integer e1 = (Integer)o1;
-                Integer e2 = (Integer)o2;
-                return e1 > e2 ? 1 : 0;
+        Arrays.sort(array, comparator);
+
+        for (int i = 1; i < array.length; i++) {
+            assertTrue(comparator.compare(array[i - 1], array[i]) <= 0);
+            if (comparator.compare(array[i - 1], array[i]) == 0) {
+                assertTrue(array[i - 1].index < array[i].index);
             }
-        };
-        Arrays.sort(elements, comparator);
-        // After sorting, elements should be the same as sorted array.
-        for(int i = 0; i < original.length; i++){
-            assertEquals(sorted[i],elements[i]);
         }
-	}
+    }
+
+    public static class Element {
+        public int value;
+
+        public int index;
+
+        private static int count = 0;
+
+        public Element(int value) {
+            this.value = value;
+            index = count++;
+        }
+    }
 
 	/**
 	 * @tests java.util.Arrays#sort(short[])

Modified: harmony/enhanced/classlib/branches/java6/modules/misc/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/misc/build.xml?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/misc/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/misc/build.xml Thu Mar 19 17:10:51 2009
@@ -121,7 +121,8 @@
         </jar>
     </target>
 
-    <target name="build-native" >
+    <target name="build-native" depends="build-native-all" />
+    <target name="build-native-all" >
         <make dir="${hy.misc.src.main.native}/accessors/${hy.os.family}" />
 
         <!-- Copy the built shared libs over to the jre/bin dir -->

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/build.xml?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/build.xml Thu Mar 19 17:10:51 2009
@@ -69,7 +69,8 @@
             depends="build, compile-tests, prepare-exclude, run-tests" />
 
     <!-- Build natives.-->
-    <target name="build-native">
+    <target name="build-native" depends="build-native-all" />
+    <target name="build-native-all" >
         <make dir="${hy.nio.src.main.native}/nio/${hy.os.family}" />
 
         <!-- Copy the built shared libs over to the jre/bin dir -->

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml Thu Mar 19 17:10:51 2009
@@ -44,7 +44,8 @@
     <target name="build" depends="compile-java, copy-resources, build-jar" />
 
     <!-- Build natives.-->
-    <target name="build-native">
+    <target name="build-native" depends="build-native-all" />
+    <target name="build-native-all" >
 
         <make dir="${hy.nio_char.src.main.native}/niochar/${hy.os.family}" />
 

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java Thu Mar 19 17:10:51 2009
@@ -43,6 +43,7 @@
     private JarFile jarFile;
     private long segmentLimit = 1000000;
     private long currentSegmentSize;
+    private boolean stripDebug;
 
     public Archive(JarInputStream inputStream, OutputStream outputStream,
             boolean gzip) throws IOException {
@@ -63,6 +64,10 @@
         segmentLimit = limit;
     }
 
+    public void stripDebugAttributes() {
+        stripDebug = true;
+    }
+
     public void pack() throws Pack200Exception, IOException {
         List classes = new ArrayList();
         List files = new ArrayList();
@@ -71,33 +76,33 @@
         if (manifest != null) {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             manifest.write(baos);
+            // TODO: Need to add this in some cases, but I'm not sure which at the moment
+//            files.add(new File("META-INF", new byte[0], 0));
             files.add(new File("META-INF/MANIFEST.MF", baos.toByteArray(), 0));
         }
         if (inputStream != null) {
-            while (inputStream.available() > 0) {
-                JarEntry jarEntry = inputStream.getNextJarEntry();
-                if (jarEntry != null) {
-                    boolean added = addJarEntry(jarEntry,
-                            new BufferedInputStream(inputStream), classes,
-                            files);
-                    if (!added) { // not added because segment has reached
-                        // maximum size
-                        new Segment().pack(classes, files, outputStream);
+            JarEntry jarEntry = inputStream.getNextJarEntry();
+            while (jarEntry != null) {
+                boolean added = addJarEntry(jarEntry,
+                        new BufferedInputStream(inputStream), classes,
+                        files);
+                if (!added) { // not added because segment has reached
+                    // maximum size
+                    if(classes.size() > 0 || files.size() > 0) {
+                        new Segment().pack(classes, files, outputStream, stripDebug);
                         classes = new ArrayList();
                         files = new ArrayList();
                         currentSegmentSize = 0;
-                        if (!addJarEntry(jarEntry, new BufferedInputStream(
-                                inputStream), classes, files)) {
-                            throw new Pack200Exception(
-                                    "Segment limit is too small for the files you are trying to pack");
-                        }
-                    } else if (segmentLimit == 0) {
-                        // create a new segment for each class
-                        new Segment().pack(classes, files, outputStream);
-                        classes = new ArrayList();
-                        files = new ArrayList();
+                        addJarEntry(jarEntry, new BufferedInputStream(inputStream), classes, files);
+                        currentSegmentSize = 0; // ignore the size of the first entry for compatibility with the RI
                     }
+                } else if (segmentLimit == 0 && estimateSize(jarEntry) > 0) {
+                    // create a new segment for each class unless size = 0
+                    new Segment().pack(classes, files, outputStream, stripDebug);
+                    classes = new ArrayList();
+                    files = new ArrayList();
                 }
+                jarEntry = inputStream.getNextJarEntry();
             }
         } else {
             Enumeration jarEntries = jarFile.entries();
@@ -107,24 +112,23 @@
                         jarFile.getInputStream(jarEntry)), classes, files);
                 if (!added) { // not added because segment has reached maximum
                     // size
-                    new Segment().pack(classes, files, outputStream);
+                    new Segment().pack(classes, files, outputStream, stripDebug);
                     classes = new ArrayList();
                     files = new ArrayList();
                     currentSegmentSize = 0;
-                    if (!addJarEntry(jarEntry, new BufferedInputStream(jarFile
-                            .getInputStream(jarEntry)), classes, files)) {
-                        throw new Pack200Exception("Segment limit is too small");
-                    }
-                } else if (segmentLimit == 0) {
-                    // create a new segment for each class
-                    new Segment().pack(classes, files, outputStream);
+                    addJarEntry(jarEntry, new BufferedInputStream(jarFile
+                            .getInputStream(jarEntry)), classes, files);
+                    currentSegmentSize = 0; // ignore the size of the first entry for compatibility with the RI
+                } else if (segmentLimit == 0 && estimateSize(jarEntry) > 0) {
+                    // create a new segment for each class unless size = 0
+                    new Segment().pack(classes, files, outputStream, stripDebug);
                     classes = new ArrayList();
                     files = new ArrayList();
                 }
             }
         }
         if(classes.size() > 0 || files.size() > 0) {
-            new Segment().pack(classes, files, outputStream);
+            new Segment().pack(classes, files, outputStream, stripDebug);
         }
         outputStream.close();
     }
@@ -134,17 +138,19 @@
         String name = jarEntry.getName();
         long size = jarEntry.getSize();
         if (size > Integer.MAX_VALUE) {
-            throw new RuntimeException("Large Class!");
+            throw new RuntimeException("Large Class!"); // TODO: Should probably allow this
+        } else if (size < 0) {
+            throw new RuntimeException("Error: size for " + name + " is " + size);
         }
         if(segmentLimit != -1 && segmentLimit != 0) {
             // -1 is a special case where only one segment is created and
-            // 0 is a special case where one segment is created for each file
-            int packedSize = name.endsWith(".class") ? estimatePackedSize(size)
-                    : (int) size;
-            if (packedSize + currentSegmentSize > segmentLimit) {
-                return false;
+            // 0 is a special case where one segment is created for each file except for files in "META-INF"
+
+            long packedSize = estimateSize(jarEntry);
+            if (packedSize + currentSegmentSize > segmentLimit && currentSegmentSize > 0) {
+                return false; // don't add this JarEntry to the current segment
             } else {
-                currentSegmentSize += packedSize;
+                currentSegmentSize += packedSize; // do add this JarEntry
             }
         }
         byte[] bytes = new byte[(int) size];
@@ -161,8 +167,18 @@
         return true;
     }
 
-    private int estimatePackedSize(long size) {
-        return (int) size; // TODO: try to match the RI as closely as possible
+    private long estimateSize(JarEntry jarEntry) {
+        // The heuristic used here is for compatibility with the RI and should not be changed
+        String name = jarEntry.getName();
+        if(name.startsWith("META-INF") || name.startsWith("/META-INF")) {
+            return 0;
+        } else {
+            long fileSize = jarEntry.getSize();
+            if(fileSize < 0) {
+                fileSize = 0;
+            }
+            return name.length() + fileSize + 5;
+        }
     }
 
     static class File {
@@ -188,6 +204,10 @@
         public long getModtime() {
             return modtime;
         }
+
+        public String toString() {
+            return name;
+        }
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java Thu Mar 19 17:10:51 2009
@@ -30,8 +30,6 @@
  */
 public class BcBands extends BandSet {
 
-    private static final Integer MULTIANEWARRAY = new Integer(197);
-    private static final Integer ALOAD_0 = new Integer(42);
     private final CpBands cpBands;
     private final Segment segment;
 
@@ -40,12 +38,12 @@
         this.segment = segment;
     }
 
-    private final List bcCodes = new ArrayList();
-    private final List bcCaseCount = new ArrayList();
-    private final List bcCaseValue = new ArrayList();
-    private final List bcByte = new ArrayList();
-    private final List bcShort = new ArrayList();
-    private final List bcLocal = new ArrayList();
+    private final IntList bcCodes = new IntList();
+    private final IntList bcCaseCount = new IntList();
+    private final IntList bcCaseValue = new IntList();
+    private final IntList bcByte = new IntList();
+    private final IntList bcShort = new IntList();
+    private final IntList bcLocal = new IntList();
     private final List bcLabel = new ArrayList();
     private final List bcIntref = new ArrayList();
     private final List bcFloatRef = new ArrayList();
@@ -64,18 +62,21 @@
 
     private String currentClass;
     private String superClass;
-    private static final Integer WIDE = new Integer(196);
-    private static final Integer INVOKEINTERFACE = new Integer(185);
-    private static final Integer TABLESWITCH = new Integer(170);
-    private static final Integer IINC = new Integer(132);
-    private static final Integer LOOKUPSWITCH = new Integer(171);
-    private static final Integer endMarker = new Integer(255);
 
-    private final List bciRenumbering = new ArrayList();
+    private static final int MULTIANEWARRAY = 197;
+    private static final int ALOAD_0 = 42;
+    private static final int WIDE = 196;
+    private static final int INVOKEINTERFACE = 185;
+    private static final int TABLESWITCH = 170;
+    private static final int IINC = 132;
+    private static final int LOOKUPSWITCH = 171;
+    private static final int endMarker = 255;
+
+    private final IntList bciRenumbering = new IntList();
     private final Map labelsToOffsets = new HashMap();
     private int byteCodeOffset;
     private int renumberedOffset;
-    private final List bcLabelRelativeOffsets = new ArrayList();
+    private final IntList bcLabelRelativeOffsets = new IntList();
 
     public void setCurrentClass(String name) {
         currentClass = name;
@@ -91,14 +92,14 @@
     }
 
     public void pack(OutputStream out) throws IOException, Pack200Exception {
-        out.write(encodeBandInt("bcCodes", listToArray(bcCodes), Codec.BYTE1));
-        out.write(encodeBandInt("bcCaseCount", listToArray(bcCaseCount),
+        out.write(encodeBandInt("bcCodes", bcCodes.toArray(), Codec.BYTE1));
+        out.write(encodeBandInt("bcCaseCount", bcCaseCount.toArray(),
                 Codec.UNSIGNED5));
-        out.write(encodeBandInt("bcCaseValue", listToArray(bcCaseValue),
+        out.write(encodeBandInt("bcCaseValue", bcCaseValue.toArray(),
                 Codec.DELTA5));
-        out.write(encodeBandInt("bcByte", listToArray(bcByte), Codec.BYTE1));
-        out.write(encodeBandInt("bcShort", listToArray(bcShort), Codec.DELTA5));
-        out.write(encodeBandInt("bcLocal", listToArray(bcLocal),
+        out.write(encodeBandInt("bcByte", bcByte.toArray(), Codec.BYTE1));
+        out.write(encodeBandInt("bcShort", bcShort.toArray(), Codec.DELTA5));
+        out.write(encodeBandInt("bcLocal", bcLocal.toArray(),
                 Codec.UNSIGNED5));
         out
                 .write(encodeBandInt("bcLabel", listToArray(bcLabel),
@@ -149,9 +150,9 @@
 
     public void visitEnd() {
         for (int i = 0; i < bciRenumbering.size(); i++) {
-            if (bciRenumbering.get(i) == null) {
+            if (bciRenumbering.get(i) == -1) {
                 bciRenumbering.remove(i);
-                bciRenumbering.add(i, new Integer(++renumberedOffset));
+                bciRenumbering.add(i, ++renumberedOffset);
             }
         }
         if (renumberedOffset != 0) {
@@ -165,8 +166,8 @@
                 } else if (label instanceof Label) {
                     bcLabel.remove(i);
                     Integer offset = (Integer) labelsToOffsets.get(label);
-                    Integer relativeOffset = (Integer) bcLabelRelativeOffsets.get(i);
-                    bcLabel.add(i, new Integer(((Integer)bciRenumbering.get(offset.intValue())).intValue() - ((Integer)bciRenumbering.get(relativeOffset.intValue())).intValue()));
+                    int relativeOffset = bcLabelRelativeOffsets.get(i);
+                    bcLabel.add(i, new Integer(bciRenumbering.get(offset.intValue()) - bciRenumbering.get(relativeOffset)));
                 }
             }
             bcCodes.add(endMarker);
@@ -189,7 +190,7 @@
         updateRenumbering();
         boolean aload_0 = false;
         if (bcCodes.size() > 0
-                && ((Integer) bcCodes.get(bcCodes.size() - 1)).equals(ALOAD_0)) {
+                && (bcCodes.get(bcCodes.size() - 1)) == ALOAD_0) {
             bcCodes.remove(bcCodes.size() - 1);
             aload_0 = true;
         }
@@ -213,18 +214,18 @@
             bcFieldRef.add(cpField);
         }
         aload_0 = false;
-        bcCodes.add(new Integer(opcode));
+        bcCodes.add(opcode);
     }
 
     private void updateRenumbering() {
         if(bciRenumbering.isEmpty()) {
-            bciRenumbering.add(new Integer(0));
+            bciRenumbering.add(0);
         }
         renumberedOffset ++;
         for (int i = bciRenumbering.size(); i < byteCodeOffset; i++) {
-            bciRenumbering.add(null);
+            bciRenumbering.add(-1);
         }
-        bciRenumbering.add(new Integer(renumberedOffset));
+        bciRenumbering.add(renumberedOffset);
     }
 
     public void visitIincInsn(int var, int increment) {
@@ -232,13 +233,13 @@
             byteCodeOffset += 6;
             bcCodes.add(WIDE);
             bcCodes.add(IINC);
-            bcLocal.add(new Integer(var));
-            bcShort.add(new Integer(increment));
+            bcLocal.add(var);
+            bcShort.add(increment);
         } else {
             byteCodeOffset += 3;
             bcCodes.add(IINC);
-            bcLocal.add(new Integer(var));
-            bcByte.add(new Integer(increment & 0xFF));
+            bcLocal.add(var);
+            bcByte.add(increment & 0xFF);
         }
         updateRenumbering();
     }
@@ -248,7 +249,7 @@
             throw new RuntimeException(
                     "Non-standard bytecode instructions not supported");
         } else {
-            bcCodes.add(new Integer(opcode));
+            bcCodes.add(opcode);
             byteCodeOffset++;
             updateRenumbering();
         }
@@ -257,23 +258,23 @@
     public void visitIntInsn(int opcode, int operand) {
         switch (opcode) {
         case 17: // sipush
-            bcCodes.add(new Integer(opcode));
-            bcShort.add(new Integer(operand));
+            bcCodes.add(opcode);
+            bcShort.add(operand);
             byteCodeOffset += 3;
             break;
         case 16: // bipush
         case 188: // newarray
-            bcCodes.add(new Integer(opcode));
-            bcByte.add(new Integer(operand & 0xFF));
+            bcCodes.add(opcode);
+            bcByte.add(operand & 0xFF);
             byteCodeOffset += 2;
         }
         updateRenumbering();
     }
 
     public void visitJumpInsn(int opcode, Label label) {
-        bcCodes.add(new Integer(opcode));
+        bcCodes.add(opcode);
         bcLabel.add(label);
-        bcLabelRelativeOffsets.add(new Integer(byteCodeOffset));
+        bcLabelRelativeOffsets.add(byteCodeOffset);
         byteCodeOffset += 3;
         updateRenumbering();
     }
@@ -284,22 +285,22 @@
                 || constant instanceof CPDouble) {
             byteCodeOffset += 3;
             if (constant instanceof CPInt) {
-                bcCodes.add(new Integer(237)); // ildc_w
+                bcCodes.add(237); // ildc_w
                 bcIntref.add(constant);
             } else if (constant instanceof CPFloat) {
-                bcCodes.add(new Integer(238)); // fldc
+                bcCodes.add(238); // fldc
                 bcFloatRef.add(constant);
             } else if (constant instanceof CPLong) {
-                bcCodes.add(new Integer(20)); // lldc2_w
+                bcCodes.add(20); // lldc2_w
                 bcLongRef.add(constant);
             } else if (constant instanceof CPDouble) {
-                bcCodes.add(new Integer(239)); // dldc2_w
+                bcCodes.add(239); // dldc2_w
                 bcDoubleRef.add(constant);
             } else if (constant instanceof CPString) {
-                bcCodes.add(new Integer(19)); // aldc
+                bcCodes.add(19); // aldc
                 bcStringRef.add(constant);
             } else if (constant instanceof CPClass) {
-                bcCodes.add(new Integer(236)); // cldc
+                bcCodes.add(236); // cldc
                 bcClassRef.add(constant);
             } else {
                 throw new RuntimeException("Constant should not be null");
@@ -307,16 +308,16 @@
         } else {
             byteCodeOffset += 2;
             if (constant instanceof CPInt) {
-                bcCodes.add(new Integer(234)); // ildc
+                bcCodes.add(234); // ildc
                 bcIntref.add(constant);
             } else if (constant instanceof CPFloat) {
-                bcCodes.add(new Integer(235)); // fldc
+                bcCodes.add(235); // fldc
                 bcFloatRef.add(constant);
             } else if (constant instanceof CPString) {
-                bcCodes.add(new Integer(18)); // aldc
+                bcCodes.add(18); // aldc
                 bcStringRef.add(constant);
             } else if (constant instanceof CPClass) {
-                bcCodes.add(new Integer(233)); // cldc
+                bcCodes.add(233); // cldc
                 bcClassRef.add(constant);
             }
         }
@@ -326,12 +327,12 @@
     public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
         bcCodes.add(LOOKUPSWITCH);
         bcLabel.add(dflt);
-        bcLabelRelativeOffsets.add(new Integer(byteCodeOffset));
-        bcCaseCount.add(new Integer(keys.length));
+        bcLabelRelativeOffsets.add(byteCodeOffset);
+        bcCaseCount.add(keys.length);
         for (int i = 0; i < labels.length; i++) {
-            bcCaseValue.add(new Integer(keys[i]));
+            bcCaseValue.add(keys[i]);
             bcLabel.add(labels[i]);
-            bcLabelRelativeOffsets.add(new Integer(byteCodeOffset));
+            bcLabelRelativeOffsets.add(byteCodeOffset);
         }
         int padding = (byteCodeOffset + 1) % 4 == 0 ? 0 : 4 - ((byteCodeOffset + 1) % 4);
         byteCodeOffset += padding + 8 + 8 * keys.length;
@@ -348,8 +349,8 @@
         case 184: // invokestatic
             boolean aload_0 = false;
             if (bcCodes.size() > 0
-                    && ((Integer) bcCodes.get(bcCodes.size() - 1))
-                            .equals(ALOAD_0)) {
+                    && (bcCodes.get(bcCodes.size() - 1))
+                             == (ALOAD_0)) {
                 bcCodes.remove(bcCodes.size() - 1);
                 aload_0 = true;
                 opcode += 7;
@@ -381,7 +382,7 @@
                 }
                 bcMethodRef.add(cpBands.getCPMethod(owner, name, desc));
             }
-            bcCodes.add(new Integer(opcode));
+            bcCodes.add(opcode);
             break;
         case 185: // invokeinterface
             CPMethodOrField cpIMethod = cpBands.getCPIMethod(owner, name, desc);
@@ -396,20 +397,20 @@
         updateRenumbering();
         bcCodes.add(MULTIANEWARRAY);
         bcClassRef.add(cpBands.getCPClass(desc));
-        bcByte.add(new Integer(dimensions & 0xFF));
+        bcByte.add(dimensions & 0xFF);
     }
 
     public void visitTableSwitchInsn(int min, int max, Label dflt,
             Label[] labels) {
         bcCodes.add(TABLESWITCH);
         bcLabel.add(dflt);
-        bcLabelRelativeOffsets.add(new Integer(byteCodeOffset));
-        bcCaseValue.add(new Integer(min));
+        bcLabelRelativeOffsets.add(byteCodeOffset);
+        bcCaseValue.add(min);
         int count = labels.length;
-        bcCaseCount.add(new Integer(count));
+        bcCaseCount.add(count);
         for (int i = 0; i < count; i++) {
             bcLabel.add(labels[i]);
-            bcLabelRelativeOffsets.add(new Integer(byteCodeOffset));
+            bcLabelRelativeOffsets.add(byteCodeOffset);
         }
         int padding = (byteCodeOffset + 1) % 4 == 0 ? 0 : 4 - ((byteCodeOffset + 1) % 4);
         byteCodeOffset+= (padding + 12 + 4 * labels.length);
@@ -420,7 +421,7 @@
         // NEW, ANEWARRAY, CHECKCAST or INSTANCEOF
         byteCodeOffset += 3;
         updateRenumbering();
-        bcCodes.add(new Integer(opcode));
+        bcCodes.add(opcode);
         bcClassRef.add(cpBands.getCPClass(type));
     }
 
@@ -429,35 +430,35 @@
         if (var > Byte.MAX_VALUE) {
             byteCodeOffset += 4;
             bcCodes.add(WIDE);
-            bcCodes.add(new Integer(opcode));
-            bcLocal.add(new Integer(var));
+            bcCodes.add(opcode);
+            bcLocal.add(var);
         } else {
             if(var > 3 || opcode == 169 /* RET */) {
                 byteCodeOffset += 2;
-                bcCodes.add(new Integer(opcode));
-                bcLocal.add(new Integer(var));
+                bcCodes.add(opcode);
+                bcLocal.add(var);
             } else {
                 byteCodeOffset +=1;
                 switch(opcode) {
                 case 21: // ILOAD
                 case 54: // ISTORE
-                    bcCodes.add(new Integer(opcode + 5 + var));
+                    bcCodes.add(opcode + 5 + var);
                     break;
                 case 22: // LLOAD
                 case 55: // LSTORE
-                    bcCodes.add(new Integer(opcode + 8 + var));
+                    bcCodes.add(opcode + 8 + var);
                     break;
                 case 23: // FLOAD
                 case 56: // FSTORE
-                    bcCodes.add(new Integer(opcode + 11 + var));
+                    bcCodes.add(opcode + 11 + var);
                     break;
                 case 24: // DLOAD
                 case 57: // DSTORE
-                    bcCodes.add(new Integer(opcode + 14 + var));
+                    bcCodes.add(opcode + 14 + var);
                     break;
                 case 25: // A_LOAD
                 case 58: // A_STORE
-                    bcCodes.add(new Integer(opcode + 17 + var));
+                    bcCodes.add(opcode + 17 + var);
                     break;
                 }
             }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java Thu Mar 19 17:10:51 2009
@@ -33,7 +33,6 @@
 
 public class ClassBands extends BandSet {
 
-    private static final Integer ZERO = new Integer(0);
     private final SegmentHeader header;
     private final CpBands cpBands;
     private final AttributeDefinitionBands attrBands;
@@ -52,8 +51,8 @@
     private final List classEnclosingMethodDesc = new ArrayList();
     private final List classSignature = new ArrayList();
 
-    private final List classFileVersionMinor = new ArrayList();
-    private final List classFileVersionMajor = new ArrayList();
+    private final IntList classFileVersionMinor = new IntList();
+    private final IntList classFileVersionMajor = new IntList();
 
     private final int[] class_field_count;
     private final CPNameAndType[][] field_descr;
@@ -67,33 +66,33 @@
     private final long[][] method_flags;
     private int[] method_attr_calls;
     private final List methodSignature = new ArrayList();
-    private final List methodExceptionNumber = new ArrayList();
+    private final IntList methodExceptionNumber = new IntList();
     private final List methodExceptionClasses = new ArrayList();
 
     private int[] codeHeaders;
-    private final List codeMaxStack = new ArrayList();
-    private final List codeMaxLocals = new ArrayList();
-    private final List codeHandlerCount = new ArrayList();
+    private final IntList codeMaxStack = new IntList();
+    private final IntList codeMaxLocals = new IntList();
+    private final IntList codeHandlerCount = new IntList();
     private final List codeHandlerStartP = new ArrayList();
     private final List codeHandlerEndPO = new ArrayList();
     private final List codeHandlerCatchPO = new ArrayList();
     private final List codeHandlerClass = new ArrayList();
     private final List codeFlags = new ArrayList();
-    private final List codeLineNumberTableN = new ArrayList();
+    private final IntList codeLineNumberTableN = new IntList();
     private final List codeLineNumberTableBciP = new ArrayList();
-    private final List codeLineNumberTableLine = new ArrayList();
-    private final List codeLocalVariableTableN = new ArrayList();
+    private final IntList codeLineNumberTableLine = new IntList();
+    private final IntList codeLocalVariableTableN = new IntList();
     private final List codeLocalVariableTableBciP = new ArrayList();
     private final List codeLocalVariableTableSpanO = new ArrayList();
     private final List codeLocalVariableTableNameRU = new ArrayList();
     private final List codeLocalVariableTableTypeRS = new ArrayList();
-    private final List codeLocalVariableTableSlot = new ArrayList();
-    private final List codeLocalVariableTypeTableN = new ArrayList();
+    private final IntList codeLocalVariableTableSlot = new IntList();
+    private final IntList codeLocalVariableTypeTableN = new IntList();
     private final List codeLocalVariableTypeTableBciP = new ArrayList();
     private final List codeLocalVariableTypeTableSpanO = new ArrayList();
     private final List codeLocalVariableTypeTableNameRU = new ArrayList();
     private final List codeLocalVariableTypeTableTypeRS = new ArrayList();
-    private final List codeLocalVariableTypeTableSlot = new ArrayList();
+    private final IntList codeLocalVariableTypeTableSlot = new IntList();
 
     private final MetadataBandGroup class_RVA_bands;
     private final MetadataBandGroup class_RIA_bands;
@@ -184,7 +183,7 @@
     public void currentClassReferencesInnerClass(CPClass inner) {
         if(!(index >= class_this.length)) {
             CPClass currentClass = class_this[index];
-            if(currentClass != null && !currentClass.equals(inner) && !isInnerClassOf(currentClass, inner)) {
+            if(currentClass != null && !currentClass.equals(inner) && !isInnerClassOf(currentClass.toString(), inner)) {
                 Set referencedInnerClasses = (Set)classReferencesInnerClass.get(currentClass);
                 if(referencedInnerClasses == null) {
                     referencedInnerClasses = new HashSet();
@@ -195,15 +194,22 @@
         }
     }
 
-    private boolean isInnerClassOf(CPClass possibleInner, CPClass possibleOuter) {
-        String currentClassName = possibleInner.toString();
-        if(possibleInner.isInnerClass()) {
-            String superClassName = currentClassName.substring(0, currentClassName.lastIndexOf('$'));
-            return superClassName.equals(possibleOuter.toString());
+    private boolean isInnerClassOf(String possibleInner, CPClass possibleOuter) {
+        if(isInnerClass(possibleInner)) {
+            String superClassName = possibleInner.substring(0, possibleInner.lastIndexOf('$'));
+            if(superClassName.equals(possibleOuter.toString())) {
+                return true;
+            } else { // do this recursively
+                return isInnerClassOf(superClassName, possibleOuter);
+            }
         }
         return false;
     }
 
+    private boolean isInnerClass(String possibleInner) {
+        return possibleInner.indexOf('$') != -1;
+    }
+
     public void addField(int flags, String name, String desc, String signature,
             Object value) {
         flags = flags & 0xFFFF;
@@ -235,19 +241,17 @@
             int major = major_versions[i];
             if (major != defaultMajorVersion) {
                 class_flags[i] |= 1 << 24;
-                classFileVersionMajor.add(new Integer(major));
-                classFileVersionMinor.add(ZERO);
+                classFileVersionMajor.add(major);
+                classFileVersionMinor.add(0);
             }
         }
         // Calculate code headers
-        codeHeaders = new int[codeFlags.size()];
+        codeHeaders = new int[codeHandlerCount.size()];
         int removed = 0;
         for (int i = 0; i < codeHeaders.length; i++) {
-            int numHandlers = ((Integer) codeHandlerCount.get(i - removed))
-                    .intValue();
-            int maxLocals = ((Integer) codeMaxLocals.get(i - removed))
-                    .intValue();
-            int maxStack = ((Integer) codeMaxStack.get(i - removed)).intValue();
+            int numHandlers = codeHandlerCount.get(i - removed);
+            int maxLocals = codeMaxLocals.get(i - removed);
+            int maxStack = codeMaxStack.get(i - removed);
             if (numHandlers == 0) {
                 int header = maxLocals * 12 + maxStack + 1;
                 if (header < 145 && maxStack < 12) {
@@ -271,11 +275,13 @@
                 codeMaxLocals.remove(i - removed);
                 codeMaxStack.remove(i - removed);
                 removed++;
+            } else if (!segment.getSegmentHeader().have_all_code_flags()) {
+                codeFlags.add(new Long(0));
             }
         }
 
         // Compute any required IcLocals
-        List innerClassesN = new ArrayList();
+        IntList innerClassesN = new IntList();
         List icLocal = new ArrayList();
         for (int i = 0; i < class_this.length; i++) {
             CPClass cpClass = class_this[i];
@@ -293,19 +299,19 @@
                         .hasNext();) {
                     CPClass inner = (CPClass) iterator2.next();
                     IcTuple icTuple = segment.getIcBands().getIcTuple(inner);
-                    if(icTuple != null) {
+                    if(icTuple != null && ! icTuple.isAnonymous()) {
                         // should transmit an icLocal entry
                         icLocal.add(icTuple);
                         innerN++;
                     }
                 }
                 if(innerN != 0) {
-                    innerClassesN.add(new Integer(innerN));
+                    innerClassesN.add(innerN);
                     class_flags[i] |= (1 << 23);
                 }
             }
         }
-        class_InnerClasses_N = listToArray(innerClassesN);
+        class_InnerClasses_N = innerClassesN.toArray();
         class_InnerClasses_RC = new CPClass[icLocal.size()];
         class_InnerClasses_F = new int[icLocal.size()];
         classInnerClassesOuterRCN = new ArrayList();
@@ -326,39 +332,39 @@
             }
         }
         // Calculate any backwards calls from metadata bands
-        List classAttrCalls = new ArrayList();
-        List fieldAttrCalls = new ArrayList();
-        List methodAttrCalls = new ArrayList();
+        IntList classAttrCalls = new IntList();
+        IntList fieldAttrCalls = new IntList();
+        IntList methodAttrCalls = new IntList();
         if(class_RVA_bands.hasContent()) {
-            classAttrCalls.add(new Integer(class_RVA_bands.numBackwardsCalls()));
+            classAttrCalls.add(class_RVA_bands.numBackwardsCalls());
         }
         if(class_RIA_bands.hasContent()) {
-            classAttrCalls.add(new Integer(class_RIA_bands.numBackwardsCalls()));
+            classAttrCalls.add(class_RIA_bands.numBackwardsCalls());
         }
         if(field_RVA_bands.hasContent()) {
-            fieldAttrCalls.add(new Integer(field_RVA_bands.numBackwardsCalls()));
+            fieldAttrCalls.add(field_RVA_bands.numBackwardsCalls());
         }
         if(field_RIA_bands.hasContent()) {
-            fieldAttrCalls.add(new Integer(field_RIA_bands.numBackwardsCalls()));
+            fieldAttrCalls.add(field_RIA_bands.numBackwardsCalls());
         }
         if(method_RVA_bands.hasContent()) {
-            methodAttrCalls.add(new Integer(method_RVA_bands.numBackwardsCalls()));
+            methodAttrCalls.add(method_RVA_bands.numBackwardsCalls());
         }
         if(method_RIA_bands.hasContent()) {
-            methodAttrCalls.add(new Integer(method_RIA_bands.numBackwardsCalls()));
+            methodAttrCalls.add(method_RIA_bands.numBackwardsCalls());
         }
         if(method_RVPA_bands.hasContent()) {
-            methodAttrCalls.add(new Integer(method_RVPA_bands.numBackwardsCalls()));
+            methodAttrCalls.add(method_RVPA_bands.numBackwardsCalls());
         }
         if(method_RIPA_bands.hasContent()) {
-            methodAttrCalls.add(new Integer(method_RIPA_bands.numBackwardsCalls()));
+            methodAttrCalls.add(method_RIPA_bands.numBackwardsCalls());
         }
         if(method_AD_bands.hasContent()) {
-            methodAttrCalls.add(new Integer(method_AD_bands.numBackwardsCalls()));
+            methodAttrCalls.add(method_AD_bands.numBackwardsCalls());
         }
-        class_attr_calls = listToArray(classAttrCalls);
-        field_attr_calls = listToArray(fieldAttrCalls);
-        method_attr_calls = listToArray(methodAttrCalls);
+        class_attr_calls = classAttrCalls.toArray();
+        field_attr_calls = fieldAttrCalls.toArray();
+        method_attr_calls = methodAttrCalls.toArray();
     }
 
     public void pack(OutputStream out) throws IOException, Pack200Exception {
@@ -447,7 +453,7 @@
 //        *method_attr_indexes :UNSIGNED5 [SUM(*method_attr_count)]
         out.write(encodeBandInt("method_attr_calls", method_attr_calls, Codec.UNSIGNED5));
         out.write(encodeBandInt("methodExceptionNumber",
-                listToArray(methodExceptionNumber), Codec.UNSIGNED5));
+                methodExceptionNumber.toArray(), Codec.UNSIGNED5));
         out.write(encodeBandInt("methodExceptionClasses",
                 cpEntryListToArray(methodExceptionClasses), Codec.UNSIGNED5));
         out.write(encodeBandInt("methodSignature",
@@ -484,9 +490,9 @@
         out.write(encodeBandInt("class_InnerClasses_outer_RCN", cpEntryOrNullListToArray(classInnerClassesOuterRCN), Codec.UNSIGNED5));
         out.write(encodeBandInt("class_InnerClasses_name_RUN", cpEntryOrNullListToArray(classInnerClassesNameRUN), Codec.UNSIGNED5));
         out.write(encodeBandInt("classFileVersionMinor",
-                listToArray(classFileVersionMinor), Codec.UNSIGNED5));
+                classFileVersionMinor.toArray(), Codec.UNSIGNED5));
         out.write(encodeBandInt("classFileVersionMajor",
-                listToArray(classFileVersionMajor), Codec.UNSIGNED5));
+                classFileVersionMajor.toArray(), Codec.UNSIGNED5));
     }
 
     private int[] getInts(CPClass[] cpClasses) {
@@ -500,12 +506,12 @@
     private void writeCodeBands(OutputStream out) throws IOException,
             Pack200Exception {
         out.write(encodeBandInt("codeHeaders", codeHeaders, Codec.BYTE1));
-        out.write(encodeBandInt("codeMaxStack", listToArray(codeMaxStack),
+        out.write(encodeBandInt("codeMaxStack", codeMaxStack.toArray(),
                 Codec.UNSIGNED5));
-        out.write(encodeBandInt("codeMaxLocals", listToArray(codeMaxLocals),
+        out.write(encodeBandInt("codeMaxLocals", codeMaxLocals.toArray(),
                 Codec.UNSIGNED5));
         out.write(encodeBandInt("codeHandlerCount",
-                listToArray(codeHandlerCount), Codec.UNSIGNED5));
+                codeHandlerCount.toArray(), Codec.UNSIGNED5));
         out.write(encodeBandInt("codeHandlerStartP",
                 listToArray(codeHandlerStartP), Codec.BCI5));
         out.write(encodeBandInt("codeHandlerEndPO",
@@ -526,13 +532,13 @@
         // *code_attr_indexes :UNSIGNED5 [SUM(*code_attr_count)]
         // *code_attr_calls :UNSIGNED5 [...]
         out.write(encodeBandInt("code_LineNumberTable_N",
-                listToArray(codeLineNumberTableN), Codec.UNSIGNED5));
+                codeLineNumberTableN.toArray(), Codec.UNSIGNED5));
         out.write(encodeBandInt("code_LineNumberTable_bci_P",
                 listToArray(codeLineNumberTableBciP), Codec.BCI5));
         out.write(encodeBandInt("code_LineNumberTable_line",
-                listToArray(codeLineNumberTableLine), Codec.UNSIGNED5));
+                codeLineNumberTableLine.toArray(), Codec.UNSIGNED5));
         out.write(encodeBandInt("code_LocalVariableTable_N",
-                listToArray(codeLocalVariableTableN), Codec.UNSIGNED5));
+                codeLocalVariableTableN.toArray(), Codec.UNSIGNED5));
         out.write(encodeBandInt("code_LocalVariableTable_bci_P",
                 listToArray(codeLocalVariableTableBciP), Codec.BCI5));
         out.write(encodeBandInt("code_LocalVariableTable_span_O",
@@ -544,9 +550,9 @@
                 cpEntryListToArray(codeLocalVariableTableTypeRS),
                 Codec.UNSIGNED5));
         out.write(encodeBandInt("code_LocalVariableTable_slot",
-                listToArray(codeLocalVariableTableSlot), Codec.UNSIGNED5));
+                codeLocalVariableTableSlot.toArray(), Codec.UNSIGNED5));
         out.write(encodeBandInt("code_LocalVariableTypeTable_N",
-                listToArray(codeLocalVariableTypeTableN), Codec.UNSIGNED5));
+                codeLocalVariableTypeTableN.toArray(), Codec.UNSIGNED5));
         out.write(encodeBandInt("code_LocalVariableTypeTable_bci_P",
                 listToArray(codeLocalVariableTypeTableBciP), Codec.BCI5));
         out.write(encodeBandInt("code_LocalVariableTypeTable_span_O",
@@ -558,7 +564,7 @@
                 cpEntryListToArray(codeLocalVariableTypeTableTypeRS),
                 Codec.UNSIGNED5));
         out.write(encodeBandInt("code_LocalVariableTypeTable_slot",
-                listToArray(codeLocalVariableTypeTableSlot), Codec.UNSIGNED5));
+                codeLocalVariableTypeTableSlot.toArray(), Codec.UNSIGNED5));
 
     }
 
@@ -572,7 +578,7 @@
             flags |= (1 << 19);
         }
         if (exceptions != null) {
-            methodExceptionNumber.add(new Integer(exceptions.length));
+            methodExceptionNumber.add(exceptions.length);
             for (int i = 0; i < exceptions.length; i++) {
                 methodExceptionClasses.add(cpBands.getCPClass(exceptions[i]));
             }
@@ -590,6 +596,18 @@
         }
     }
 
+    public void endOfMethod() {
+        if(codeFlags.size() > 0) {
+            long latestCodeFlag = ((Long)codeFlags.get(codeFlags.size() - 1)).longValue();
+            int latestLocalVariableTableN = codeLocalVariableTableN.get(codeLocalVariableTableN.size() - 1);
+            if(latestCodeFlag == (1 << 2) && latestLocalVariableTableN == 0) {
+                codeLocalVariableTableN.remove(codeLocalVariableTableN.size() - 1);
+                codeFlags.remove(codeFlags.size() - 1);
+                codeFlags.add(new Integer(0));
+            }
+        }
+    }
+
     protected static int countArgs(String descriptor) {
         int bra = descriptor.indexOf('(');
         int ket = descriptor.indexOf(')');
@@ -691,24 +709,26 @@
                 .remove(tempMethodFlags.size() - 1);
         Long newFlag = new Long(latestFlag.intValue() | (1 << 17));
         tempMethodFlags.add(newFlag);
-        codeMaxStack.add(new Integer(maxStack));
+        codeMaxStack.add(maxStack);
         if ((newFlag.longValue() & (1 << 3)) == 0) { // not static
             maxLocals--; // minus 'this' local
         }
         maxLocals -= numMethodArgs;
-        codeMaxLocals.add(new Integer(maxLocals));
+        codeMaxLocals.add(maxLocals);
     }
 
-    public void addCode() {
-        codeHandlerCount.add(ZERO);
-        codeFlags.add(new Long((1 << 2))); // TODO: What if there's no debug information?
-        codeLocalVariableTableN.add(new Integer(0));
+    public void addCode(boolean stripDebug) {
+        codeHandlerCount.add(0);
+        if(!stripDebug) {
+            codeFlags.add(new Long((1 << 2))); // TODO: What if there's no debug information?
+            codeLocalVariableTableN.add(0);
+        }
     }
 
     public void addHandler(Label start, Label end, Label handler, String type) {
-        Integer handlers = (Integer) codeHandlerCount.remove(codeHandlerCount
+        int handlers = codeHandlerCount.remove(codeHandlerCount
                 .size() - 1);
-        codeHandlerCount.add(new Integer(handlers.intValue() + 1));
+        codeHandlerCount.add(handlers + 1);
         codeHandlerStartP.add(start);
         codeHandlerEndPO.add(end);
         codeHandlerCatchPO.add(handler);
@@ -720,13 +740,12 @@
         if ((latestCodeFlag.intValue() & (1 << 1)) == 0) {
             codeFlags.remove(codeFlags.size() - 1);
             codeFlags.add(new Long(latestCodeFlag.intValue() | (1 << 1)));
-            codeLineNumberTableN.add(new Integer(1));
+            codeLineNumberTableN.add(1);
         } else {
-            Integer numLines = (Integer) codeLineNumberTableN
-                    .remove(codeLineNumberTableN.size() - 1);
-            codeLineNumberTableN.add(new Integer(numLines.intValue() + 1));
+            codeLineNumberTableN
+                    .increment(codeLineNumberTableN.size() - 1);
         }
-        codeLineNumberTableLine.add(new Integer(line));
+        codeLineNumberTableLine.add(line);
         codeLineNumberTableBciP.add(start);
         // TODO: bci renumbering
     }
@@ -738,32 +757,29 @@
             if ((latestCodeFlag.intValue() & (1 << 3)) == 0) {
                 codeFlags.remove(codeFlags.size() - 1);
                 codeFlags.add(new Long(latestCodeFlag.intValue() | (1 << 3)));
-                codeLocalVariableTypeTableN.add(new Integer(1));
+                codeLocalVariableTypeTableN.add(1);
             } else {
-                Integer numLocals = (Integer) codeLocalVariableTypeTableN
-                        .remove(codeLocalVariableTypeTableN.size() - 1);
-                codeLocalVariableTypeTableN.add(new Integer(numLocals
-                        .intValue() + 1));
+                codeLocalVariableTypeTableN
+                        .increment(codeLocalVariableTypeTableN.size() - 1);
             }
             codeLocalVariableTypeTableBciP.add(start);
             codeLocalVariableTypeTableSpanO.add(end);
             codeLocalVariableTypeTableNameRU.add(cpBands.getCPUtf8(name));
             codeLocalVariableTypeTableTypeRS.add(cpBands
                     .getCPSignature(signature));
-            codeLocalVariableTypeTableSlot.add(new Integer(indx));
+            codeLocalVariableTypeTableSlot.add(indx);
         }
         // LocalVariableTable attribute
-        Integer numLocals = (Integer) codeLocalVariableTableN
-                .remove(codeLocalVariableTableN.size() - 1);
-        codeLocalVariableTableN.add(new Integer(numLocals.intValue() + 1));
+        codeLocalVariableTableN
+                .increment(codeLocalVariableTableN.size() - 1);
         codeLocalVariableTableBciP.add(start);
         codeLocalVariableTableSpanO.add(end);
         codeLocalVariableTableNameRU.add(cpBands.getCPUtf8(name));
         codeLocalVariableTableTypeRS.add(cpBands.getCPSignature(desc));
-        codeLocalVariableTableSlot.add(new Integer(indx));
+        codeLocalVariableTableSlot.add(indx);
     }
 
-    public void doBciRenumbering(List bciRenumbering, Map labelsToOffsets) {
+    public void doBciRenumbering(IntList bciRenumbering, Map labelsToOffsets) {
         renumberBci(codeLineNumberTableBciP, bciRenumbering, labelsToOffsets);
         renumberBci(codeLocalVariableTableBciP, bciRenumbering, labelsToOffsets);
         renumberOffsetBci(codeLocalVariableTableBciP,
@@ -780,7 +796,7 @@
                 bciRenumbering, labelsToOffsets);
     }
 
-    private void renumberBci(List list, List bciRenumbering, Map labelsToOffsets) {
+    private void renumberBci(List list, IntList bciRenumbering, Map labelsToOffsets) {
         for (int i = list.size() - 1; i >= 0; i--) {
             Object label = list.get(i);
             if (label instanceof Integer) {
@@ -788,13 +804,13 @@
             } else if (label instanceof Label) {
                 list.remove(i);
                 Integer bytecodeIndex = (Integer) labelsToOffsets.get(label);
-                list.add(i, bciRenumbering.get(bytecodeIndex.intValue()));
+                list.add(i, new Integer(bciRenumbering.get(bytecodeIndex.intValue())));
             }
         }
     }
 
     private void renumberOffsetBci(List relative, List list,
-            List bciRenumbering, Map labelsToOffsets) {
+            IntList bciRenumbering, Map labelsToOffsets) {
         for (int i = list.size() - 1; i >= 0; i--) {
             Object label = list.get(i);
             if (label instanceof Integer) {
@@ -802,8 +818,8 @@
             } else if (label instanceof Label) {
                 list.remove(i);
                 Integer bytecodeIndex = (Integer) labelsToOffsets.get(label);
-                Integer renumberedOffset = new Integer(((Integer) bciRenumbering
-                        .get(bytecodeIndex.intValue())).intValue()
+                Integer renumberedOffset = new Integer(bciRenumbering
+                        .get(bytecodeIndex.intValue())
                         - ((Integer) relative.get(i)).intValue());
                 list.add(i, renumberedOffset);
             }
@@ -811,7 +827,7 @@
     }
 
     private void renumberDoubleOffsetBci(List relative, List firstOffset, List list,
-            List bciRenumbering, Map labelsToOffsets) {
+            IntList bciRenumbering, Map labelsToOffsets) {
         // TODO: There's probably a nicer way of doing this...
         for (int i = list.size() - 1; i >= 0; i--) {
             Object label = list.get(i);
@@ -820,8 +836,8 @@
             } else if (label instanceof Label) {
                 list.remove(i);
                 Integer bytecodeIndex = (Integer) labelsToOffsets.get(label);
-                Integer renumberedOffset = new Integer(((Integer) bciRenumbering
-                        .get(bytecodeIndex.intValue())).intValue()
+                Integer renumberedOffset = new Integer(bciRenumbering
+                        .get(bytecodeIndex.intValue())
                         - ((Integer) relative.get(i)).intValue() - ((Integer) firstOffset.get(i)).intValue());
                 list.add(i, renumberedOffset);
             }

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=756095&r1=756094&r2=756095&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 Mar 19 17:10:51 2009
@@ -156,6 +156,12 @@
             return C.compareTo(((IcTuple)arg0).C);
         }
 
+        public boolean isAnonymous() {
+            String className = C.toString();
+            String innerName = className.substring(className.lastIndexOf('$') + 1);
+            return Character.isDigit(innerName.charAt(0));
+        }
+
     }
 
     public IcTuple getIcTuple(CPClass inner) {

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=756095&r1=756094&r2=756095&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 Mar 19 17:10:51 2009
@@ -43,11 +43,14 @@
     private final SegmentFieldVisitor fieldVisitor = new SegmentFieldVisitor();
     private final SegmentMethodVisitor methodVisitor = new SegmentMethodVisitor();
     private Pack200ClassReader currentClassReader;
+    private boolean stripDebug;
 
-    public void pack(List classes, List files, OutputStream out)
+    public void pack(List classes, List files, OutputStream out, boolean stripDebug)
             throws IOException, Pack200Exception {
+        this.stripDebug = stripDebug;
         segmentHeader = new SegmentHeader();
         segmentHeader.setFile_count(files.size());
+        segmentHeader.setHave_all_code_flags(!stripDebug);
         cpBands = new CpBands(this);
         attributeDefinitionBands = new AttributeDefinitionBands(this);
         icBands = new IcBands(segmentHeader, cpBands);
@@ -93,7 +96,9 @@
     }
 
     public void visitSource(String source, String debug) {
-        classBands.addSourceFile(source);
+        if(!stripDebug) {
+            classBands.addSourceFile(source);
+        }
     }
 
     public void visitOuterClass(String owner, String name, String desc) {
@@ -150,7 +155,7 @@
         }
 
         public void visitCode() {
-            classBands.addCode();
+            classBands.addCode(stripDebug);
         }
 
         public void visitFrame(int arg0, int arg1, Object[] arg2, int arg3,
@@ -164,13 +169,17 @@
         }
 
         public void visitLineNumber(int line, Label start) {
-            classBands.addLineNumber(line, start);
+            if(!stripDebug) {
+                classBands.addLineNumber(line, start);
+            }
         }
 
         public void visitLocalVariable(String name, String desc,
                 String signature, Label start, Label end, int index) {
-            classBands.addLocalVariable(name, desc, signature, start, end,
-                    index);
+            if(!stripDebug) {
+                classBands.addLocalVariable(name, desc, signature, start, end,
+                        index);
+            }
         }
 
         public void visitMaxs(int maxStack, int maxLocals) {
@@ -189,6 +198,7 @@
         }
 
         public void visitEnd() {
+            classBands.endOfMethod();
             bcBands.visitEnd();
         }
 
@@ -422,8 +432,6 @@
         }
 
         public void visitEnd() {
-            // TODO Auto-generated method stub
-
         }
     }
 

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=756095&r1=756094&r2=756095&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 Mar 19 17:10:51 2009
@@ -369,4 +369,8 @@
         return have_file_options;
     }
 
+    public boolean have_all_code_flags() {
+        return have_all_code_flags;
+    }
+
 }
\ No newline at end of file

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java Thu Mar 19 17:10:51 2009
@@ -207,39 +207,6 @@
                 Codec.UNSIGNED5, signatureCount);
         int signatureIndex = 0;
 
-        int backwardsCallsUsed = parseFieldMetadataBands(in, fieldAttrCalls);
-
-        // Parse non-predefined attribute bands
-        int backwardsCallIndex = backwardsCallsUsed;
-        int limit = options.hasFieldFlagsHi() ? 62 : 31;
-        AttributeLayout[] otherLayouts = new AttributeLayout[limit + 1];
-        int[] counts = new int[limit + 1];
-        List[] otherAttributes = new List[limit + 1];
-        for (int i = 0; i < limit; i++) {
-            AttributeLayout layout = attrMap.getAttributeLayout(i,
-                    AttributeLayout.CONTEXT_FIELD);
-            if (layout != null && !(layout.isDefaultLayout())) {
-                otherLayouts[i] = layout;
-                counts[i] = SegmentUtils.countMatches(fieldFlags, layout);
-            }
-        }
-        for (int i = 0; i < counts.length; i++) {
-            if (counts[i] > 0) {
-                NewAttributeBands bands = attrMap
-                        .getAttributeBands(otherLayouts[i]);
-                otherAttributes[i] = bands.parseAttributes(in, counts[i]);
-                int numBackwardsCallables = otherLayouts[i]
-                        .numBackwardsCallables();
-                if (numBackwardsCallables > 0) {
-                    int[] backwardsCalls = new int[numBackwardsCallables];
-                    System.arraycopy(fieldAttrCalls, backwardsCallIndex,
-                            backwardsCalls, 0, numBackwardsCallables);
-                    bands.setBackwardsCalls(backwardsCalls);
-                    backwardsCallIndex += numBackwardsCallables;
-                }
-            }
-        }
-
         AttributeLayout deprecatedLayout = attrMap.getAttributeLayout(
                 AttributeLayout.ATTRIBUTE_DEPRECATED,
                 AttributeLayout.CONTEXT_FIELD);
@@ -276,12 +243,56 @@
                     fieldAttributes[i][j].add(new SignatureAttribute(value));
                     signatureIndex++;
                 }
-                // Non-predefined attributes
+            }
+        }
+
+        int backwardsCallsUsed = parseFieldMetadataBands(in, fieldAttrCalls);
+
+        // Parse non-predefined attribute bands
+        int backwardsCallIndex = backwardsCallsUsed;
+        int limit = options.hasFieldFlagsHi() ? 62 : 31;
+        AttributeLayout[] otherLayouts = new AttributeLayout[limit + 1];
+        int[] counts = new int[limit + 1];
+        List[] otherAttributes = new List[limit + 1];
+        for (int i = 0; i < limit; i++) {
+            AttributeLayout layout = attrMap.getAttributeLayout(i,
+                    AttributeLayout.CONTEXT_FIELD);
+            if (layout != null && !(layout.isDefaultLayout())) {
+                otherLayouts[i] = layout;
+                counts[i] = SegmentUtils.countMatches(fieldFlags, layout);
+            }
+        }
+        for (int i = 0; i < counts.length; i++) {
+            if (counts[i] > 0) {
+                NewAttributeBands bands = attrMap
+                        .getAttributeBands(otherLayouts[i]);
+                otherAttributes[i] = bands.parseAttributes(in, counts[i]);
+                int numBackwardsCallables = otherLayouts[i]
+                        .numBackwardsCallables();
+                if (numBackwardsCallables > 0) {
+                    int[] backwardsCalls = new int[numBackwardsCallables];
+                    System.arraycopy(fieldAttrCalls, backwardsCallIndex,
+                            backwardsCalls, 0, numBackwardsCallables);
+                    bands.setBackwardsCalls(backwardsCalls);
+                    backwardsCallIndex += numBackwardsCallables;
+                }
+            }
+        }
+
+        // Non-predefined attributes
+        for (int i = 0; i < classCount; i++) {
+            for (int j = 0; j < fieldFlags[i].length; j++) {
+                long flag = fieldFlags[i][j];
+                int othersAddedAtStart = 0;
                 for (int k = 0; k < otherLayouts.length; k++) {
                     if (otherLayouts[k] != null
                             && otherLayouts[k].matches(flag)) {
                         // Add the next attribute
-                        fieldAttributes[i][j].add(otherAttributes[k].get(0));
+                        if(otherLayouts[k].getIndex()<15) {
+                            fieldAttributes[i][j].add(othersAddedAtStart++, otherAttributes[k].get(0));
+                        } else {
+                            fieldAttributes[i][j].add(otherAttributes[k].get(0));
+                        }
                         otherAttributes[k].remove(0);
                     }
                 }
@@ -340,40 +351,6 @@
         long[] methodSignatureRS = decodeBandLong("method_signature_RS", in,
                 Codec.UNSIGNED5, count1);
 
-        // Parse method metadata bands
-        int backwardsCallsUsed = parseMethodMetadataBands(in, methodAttrCalls);
-
-        // Parse non-predefined attribute bands
-        int backwardsCallIndex = backwardsCallsUsed;
-        int limit = options.hasMethodFlagsHi() ? 62 : 31;
-        AttributeLayout[] otherLayouts = new AttributeLayout[limit + 1];
-        int[] counts = new int[limit + 1];
-        List[] otherAttributes = new List[limit + 1];
-        for (int i = 0; i < limit; i++) {
-            AttributeLayout layout = attrMap.getAttributeLayout(i,
-                    AttributeLayout.CONTEXT_METHOD);
-            if (layout != null && !(layout.isDefaultLayout())) {
-                otherLayouts[i] = layout;
-                counts[i] = SegmentUtils.countMatches(methodFlags, layout);
-            }
-        }
-        for (int i = 0; i < counts.length; i++) {
-            if (counts[i] > 0) {
-                NewAttributeBands bands = attrMap
-                        .getAttributeBands(otherLayouts[i]);
-                otherAttributes[i] = bands.parseAttributes(in, counts[i]);
-                int numBackwardsCallables = otherLayouts[i]
-                        .numBackwardsCallables();
-                if (numBackwardsCallables > 0) {
-                    int[] backwardsCalls = new int[numBackwardsCallables];
-                    System.arraycopy(methodAttrCalls, backwardsCallIndex,
-                            backwardsCalls, 0, numBackwardsCallables);
-                    bands.setBackwardsCalls(backwardsCalls);
-                    backwardsCallIndex += numBackwardsCallables;
-                }
-            }
-        }
-
         AttributeLayout deprecatedLayout = attrMap.getAttributeLayout(
                 AttributeLayout.ATTRIBUTE_DEPRECATED,
                 AttributeLayout.CONTEXT_METHOD);
@@ -384,16 +361,6 @@
         for (int i = 0; i < methodAttributes.length; i++) {
             for (int j = 0; j < methodAttributes[i].length; j++) {
                 long flag = methodFlags[i][j];
-             // Non-predefined attributes
-                for (int k = 0; k < otherLayouts.length; k++) {
-                    if (otherLayouts[k] != null
-                            && otherLayouts[k].matches(flag)
-                            && otherLayouts[k].getIndex() < 15) {
-                        // Add the next attribute
-                        methodAttributes[i][j].add(otherAttributes[k].get(0));
-                        otherAttributes[k].remove(0);
-                    }
-                }
                 if (methodExceptionsLayout.matches(flag)) {
                     int n = numExceptions[methodExceptionsIndex];
                     int[] exceptions = methodExceptionsRS[methodExceptionsIndex];
@@ -425,13 +392,57 @@
                 if (deprecatedLayout.matches(flag)) {
                     methodAttributes[i][j].add(new DeprecatedAttribute());
                 }
-                // Non-predefined attributes
+            }
+        }
+
+        // Parse method metadata bands
+        int backwardsCallsUsed = parseMethodMetadataBands(in, methodAttrCalls);
+
+        // Parse non-predefined attribute bands
+        int backwardsCallIndex = backwardsCallsUsed;
+        int limit = options.hasMethodFlagsHi() ? 62 : 31;
+        AttributeLayout[] otherLayouts = new AttributeLayout[limit + 1];
+        int[] counts = new int[limit + 1];
+        List[] otherAttributes = new List[limit + 1];
+        for (int i = 0; i < limit; i++) {
+            AttributeLayout layout = attrMap.getAttributeLayout(i,
+                    AttributeLayout.CONTEXT_METHOD);
+            if (layout != null && !(layout.isDefaultLayout())) {
+                otherLayouts[i] = layout;
+                counts[i] = SegmentUtils.countMatches(methodFlags, layout);
+            }
+        }
+        for (int i = 0; i < counts.length; i++) {
+            if (counts[i] > 0) {
+                NewAttributeBands bands = attrMap
+                        .getAttributeBands(otherLayouts[i]);
+                otherAttributes[i] = bands.parseAttributes(in, counts[i]);
+                int numBackwardsCallables = otherLayouts[i]
+                        .numBackwardsCallables();
+                if (numBackwardsCallables > 0) {
+                    int[] backwardsCalls = new int[numBackwardsCallables];
+                    System.arraycopy(methodAttrCalls, backwardsCallIndex,
+                            backwardsCalls, 0, numBackwardsCallables);
+                    bands.setBackwardsCalls(backwardsCalls);
+                    backwardsCallIndex += numBackwardsCallables;
+                }
+            }
+        }
+
+        // Non-predefined attributes
+        for (int i = 0; i < methodAttributes.length; i++) {
+            for (int j = 0; j < methodAttributes[i].length; j++) {
+                long flag = methodFlags[i][j];
+                int othersAddedAtStart = 0;
                 for (int k = 0; k < otherLayouts.length; k++) {
                     if (otherLayouts[k] != null
-                            && otherLayouts[k].matches(flag)
-                            && otherLayouts[k].getIndex() >= 15) {
+                            && otherLayouts[k].matches(flag)) {
                         // Add the next attribute
-                        methodAttributes[i][j].add(otherAttributes[k].get(0));
+                        if(otherLayouts[k].getIndex() < 15) {
+                            methodAttributes[i][j].add(othersAddedAtStart++, otherAttributes[k].get(0));
+                        } else {
+                            methodAttributes[i][j].add(otherAttributes[k].get(0));
+                        }
                         otherAttributes[k].remove(0);
                     }
                 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcTuple.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcTuple.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcTuple.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/IcTuple.java Thu Mar 19 17:10:51 2009
@@ -271,7 +271,7 @@
 
     public String toString() {
         StringBuffer result = new StringBuffer();
-        result.append(this.getClass().getName());
+        result.append("IcTuple ");
         result.append('(');
         result.append(simpleClassName());
         result.append(" in ");

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java Thu Mar 19 17:10:51 2009
@@ -31,6 +31,7 @@
 import java.util.TimeZone;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
+import java.util.zip.CRC32;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.ZipEntry;
 
@@ -528,7 +529,6 @@
         long[] fileSize = fileBands.getFileSize();
         byte[][] fileBits = fileBands.getFileBits();
 
-        // out.setLevel(JarEntry.DEFLATED)
         // now write the files out
         int classNum = 0;
         int numberOfFiles = header.getNumberOfFiles();
@@ -546,23 +546,32 @@
             boolean deflate = fileDeflate[i];
 
             JarEntry entry = new JarEntry(name);
-            if (deflate)
+            if (deflate) {
                 entry.setMethod(ZipEntry.DEFLATED);
+            } else {
+                entry.setMethod(ZipEntry.STORED);
+                CRC32 crc = new CRC32();
+                if(fileIsClass[i]) {
+                    crc.update(classFilesContents[classNum]);
+                    entry.setSize(classFilesContents[classNum].length);
+                } else {
+                    crc.update(fileBits[i]);
+                    entry.setSize(fileSize[i]);
+                }
+                entry.setCrc(crc.getValue());
+            }
             // On Windows at least, need to correct for timezone
             entry.setTime(modtime - TimeZone.getDefault().getRawOffset());
             out.putNextEntry(entry);
 
+            // write to output stream
             if (fileIsClass[i]) {
-                // write to dos
                 entry.setSize(classFilesContents[classNum].length);
                 out.write(classFilesContents[classNum]);
                 classNum++;
             } else {
-                long size = fileSize[i];
-                entry.setSize(size);
-
-                byte[] data = fileBits[i];
-                out.write(data);
+                entry.setSize(fileSize[i]);
+                out.write(fileBits[i]);
             }
         }
     }

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=756095&r1=756094&r2=756095&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 Thu Mar 19 17:10:51 2009
@@ -112,8 +112,11 @@
         JarFile jarFile = new JarFile(file2);
         file2.deleteOnExit();
 
-        JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
-                "/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
+        File compareFile = new File(Archive.class.getResource(
+                "/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI());
+        JarFile jarFile2 = new JarFile(compareFile);
+
+        assertEquals(jarFile2.size(), jarFile.size());
 
         compareFiles(jarFile, jarFile2);
     }
@@ -141,6 +144,97 @@
         compareFiles(jarFile, jarFile2);
     }
 
+    public void testSegmentLimits() throws IOException, Pack200Exception {
+
+        in = new JarInputStream(
+                Archive.class
+                        .getResourceAsStream("/org/apache/harmony/pack200/tests/hw.jar"));
+        file = File.createTempFile("helloworld", ".pack.gz");
+        out = new FileOutputStream(file);
+        Archive archive = new Archive(in, out, true);
+        archive.setSegmentLimit(0);
+        archive.pack();
+        in.close();
+        out.close();
+
+        in = new JarInputStream(
+                Archive.class
+                        .getResourceAsStream("/org/apache/harmony/pack200/tests/hw.jar"));
+        file = File.createTempFile("helloworld", ".pack.gz");
+        out = new FileOutputStream(file);
+        archive = new Archive(in, out, true);
+        archive.setSegmentLimit(-1);
+        archive.pack();
+        in.close();
+        out.close();
+
+        in = new JarInputStream(
+                Archive.class
+                        .getResourceAsStream("/org/apache/harmony/pack200/tests/hw.jar"));
+        file = File.createTempFile("helloworld", ".pack.gz");
+        out = new FileOutputStream(file);
+        archive = new Archive(in, out, true);
+        archive.setSegmentLimit(5000);
+        archive.pack();
+        in.close();
+        out.close();
+    }
+
+    public void testStripDebug() throws IOException, Pack200Exception, URISyntaxException {
+        in = new JarInputStream(Archive.class
+                .getResourceAsStream("/org/apache/harmony/pack200/tests/sqlUnpacked.jar"));
+        file = File.createTempFile("sql", ".pack");
+        out = new FileOutputStream(file);
+        Archive archive = new Archive(in, out, false);
+        archive.stripDebugAttributes();
+        archive.pack();
+        in.close();
+        out.close();
+
+        // now unpack
+        InputStream in2 = new FileInputStream(file);
+        File file2 = File.createTempFile("sqloutNoDebug", ".jar");
+        JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+        org.apache.harmony.unpack200.Archive u2archive = new org.apache.harmony.unpack200.Archive(in2, out2);
+        u2archive.unpack();
+
+        File compareFile = new File(Archive.class.getResource(
+                "/org/apache/harmony/pack200/tests/sqlUnpackedNoDebug.jar").toURI());
+        JarFile jarFile = new JarFile(file2);
+        assertTrue(file2.length() < 250000);
+        file2.deleteOnExit();
+
+        JarFile jarFile2 = new JarFile(compareFile);
+
+        compareFiles(jarFile, jarFile2);
+    }
+
+    public void testAnnotations() throws IOException, Pack200Exception,
+            URISyntaxException {
+        in = new JarInputStream(
+                Archive.class
+                        .getResourceAsStream("/org/apache/harmony/pack200/tests/annotationsUnpacked.jar"));
+        file = File.createTempFile("annotations", ".pack");
+        out = new FileOutputStream(file);
+        new Archive(in, out, false).pack();
+        in.close();
+        out.close();
+
+        // now unpack
+        InputStream in2 = new FileInputStream(file);
+        File file2 = File.createTempFile("annotationsout", ".jar");
+        JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+        org.apache.harmony.unpack200.Archive archive = new org.apache.harmony.unpack200.Archive(
+                in2, out2);
+        archive.unpack();
+        JarFile jarFile = new JarFile(file2);
+        file2.deleteOnExit();
+        JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
+                "/org/apache/harmony/pack200/tests/annotationsUnpacked.jar").toURI()));
+
+        compareFiles(jarFile, jarFile2);
+    }
+
     private void compareFiles(JarFile jarFile, JarFile jarFile2)
             throws IOException {
         Enumeration entries = jarFile.entries();

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java?rev=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java Thu Mar 19 17:10:51 2009
@@ -71,8 +71,16 @@
         JarFile jarFile = new JarFile(file);
         file.deleteOnExit();
 
-        JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
-                "/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
+        File compareFile = new File(Archive.class.getResource(
+                "/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI());
+
+        JarFile jarFile2 = new JarFile(compareFile);
+
+        long differenceInJarSizes = Math.abs(compareFile.length()
+                - file.length());
+
+        assertTrue("Expected jar files to be a similar size, difference was "
+                + differenceInJarSizes + " bytes", differenceInJarSizes < 100);
 
         Enumeration entries = jarFile.entries();
         Enumeration entries2 = jarFile2.entries();

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=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml Thu Mar 19 17:10:51 2009
@@ -59,7 +59,8 @@
 
     <!-- Build natives. Currently there are only windows natives for
      prefs, so we check if we are on a windows platform -->
-    <target name="build-native" if="is.windows">
+    <target name="build-native" depends="build-native-all" />
+    <target name="build-native-all" if="is.windows">
         <make dir="${hy.prefs.src.main.native}/prefs/${hy.os.family}" />
 
         <!-- Copy the built shared libs over to the jre/bin dir -->

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=756095&r1=756094&r2=756095&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/print/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/print/build.xml Thu Mar 19 17:10:51 2009
@@ -102,7 +102,8 @@
         </javac>
     </target>
     
-    <target name="build-native" if="is.windows">
+    <target name="build-native" depends="build-native-all" />
+    <target name="build-native-all" if="is.windows">
         <make dir="${hy.print.src.main.native}/print/${hy.os.family}" />
         <!-- Copy the built shared libs over to the jre/bin dir -->
         <copy todir="${hy.jdk}/jre/bin" overwrite="yes">



Mime
View raw message