harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r646264 [6/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/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetDecoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetDecoderTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetDecoderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetDecoderTest.java Wed Apr  9 04:01:14 2008
@@ -29,124 +29,133 @@
  */
 public class UTF16CharsetDecoderTest extends CharsetDecoderTest {
 
-	boolean bigEndian = true;
+    boolean bigEndian = true;
 
-	protected void setUp() throws Exception {
-		cs = Charset.forName("utf-16");
-		unibytes = new byte[] { 32, 0, 98, 0, 117, 0, 102, 0, 102, 0, 101, 0,
-				114, 0 };
-		bom = "\ufeff";
-
-		// unibytes = new byte[] {-1, -2, 0, 32, 0, 98, 0, 117, 0, 102, 0, 102,
-		// 0, 101, 0, 114};
-		super.setUp();
-	}
-
-	/*
-	 * @see CharsetDecoderTest#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-
-	byte[] getUnibytes() {
-		// FIXME: different here
-		// if don't specified BOM
-		// ICU default is LE
-		// JDK default is BE
-
-		// maybe start with 0xFEFF, which means big endian
-		// 0xFFFE, which means little endian
-		if (bigEndian) {
-			return new byte[] { -1, -2, 32, 0, 98, 0, 117, 0, 102, 0, 102, 0,
-					101, 0, 114, 0 };
-		} else {
-			unibytes = new byte[] { 0, 32, 0, 98, 0, 117, 0, 102, 0, 102, 0,
-					101, 0, 114 };
-			return new byte[] { -2, -1, 0, 32, 0, 98, 0, 117, 0, 102, 0, 102,
-					0, 101, 0, 114 };
-		}
-	}
-
-	public void testMultiStepDecode() throws CharacterCodingException {
-		if (!cs.name().equals("mock")) {
-			decoder.onMalformedInput(CodingErrorAction.REPORT);
-			decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
-			CharBuffer out = CharBuffer.allocate(10);
-			assertTrue(decoder.decode(
-					ByteBuffer.wrap(new byte[] { -1, -2, 32, 0, 98 }), out,
-					true).isMalformed());
-
-			decoder.flush(out);
-			decoder.reset();
-			out.clear();
-			assertSame(CoderResult.UNDERFLOW, decoder.decode(ByteBuffer
-					.wrap(new byte[] { -1, -2, 32, 0 }), out, false));
-			assertTrue(decoder.decode(ByteBuffer.wrap(new byte[] { 98 }), out,
-					true).isMalformed());
-
-			decoder.flush(out);
-			decoder.reset();
-			out.clear();
-			assertSame(CoderResult.UNDERFLOW, decoder.decode(ByteBuffer
-					.wrap(new byte[] { -1, -2, 32, 0, 98 }), out, false));
-			assertFalse(decoder
-					.decode(ByteBuffer.wrap(new byte[] {}), out, true)
-					.isMalformed());
-
-			decoder.flush(out);
-			decoder.reset();
-			out.clear();
-			assertFalse(decoder.decode(
-					ByteBuffer.wrap(new byte[] { -1, -2, 32, 0, 98, 0 }), out,
-					true).isError());
-
-			decoder.flush(out);
-			decoder.reset();
-			out.clear();
-			assertSame(CoderResult.UNDERFLOW, decoder.decode(ByteBuffer
-					.wrap(new byte[] { -1, -2, 32, 0, 98 }), out, false));
-			assertTrue(decoder.decode(ByteBuffer.wrap(new byte[] { 0 }), out,
-					true).isMalformed());
-
-		}
-	}
-
-	public void testLittleEndian() throws CharacterCodingException,
-			UnsupportedEncodingException {
-		bigEndian = false;
-		implTestDecodeByteBufferCharBufferboolean();
-		decoder.reset();
-		implTestDecodeByteBuffer();
-		bigEndian = true;
-	}
-
-	// FIXME: give up this tests
-	// public void testDefaultCharsPerByte() {
-	// // assertEquals(1, decoder.averageCharsPerByte());
-	// // assertEquals(1, decoder.maxCharsPerByte());
-	// assertEquals(decoder.averageCharsPerByte(), 0.5, 0.001);
-	// assertEquals(decoder.maxCharsPerByte(), 2, 0.001);
-	// }
-
-	ByteBuffer getUnmappedByteBuffer() throws UnsupportedEncodingException {
-		return null;
-	}
-
-	ByteBuffer getMalformByteBuffer() throws UnsupportedEncodingException {
-		return null;
-		// FIXME: different here, RI can parse 0xd8d8
-		// ByteBuffer buffer = ByteBuffer.allocate(100);
-		// buffer.put((byte) -1);
-		// buffer.put((byte) -2);
-		// buffer.put((byte) 0xdc);
-		// buffer.put((byte) 0xdc);
-		// buffer.put(unibytes);
-		// buffer.flip();
-		// return buffer;
-	}
-
-	ByteBuffer getExceptionByteArray() throws UnsupportedEncodingException {
-		return null;
-	}
+    protected void setUp() throws Exception {
+        cs = Charset.forName("utf-16");
+        bom = "\ufeff";
+        super.setUp();
+    }
+
+    /*
+     * @see CharsetDecoderTest#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    protected ByteBuffer getByteBuffer() {
+        // FIXME: different here
+        // if don't specified BOM
+        // ICU default is LE
+        // JDK default is BE
+
+        // maybe start with 0xFEFF, which means big endian
+        // 0xFFFE, which means little endian
+        byte[] b = (bigEndian) ? new byte[] { -1, -2, 32, 0, 98, 0, 117, 0,
+                102, 0, 102, 0, 101, 0, 114, 0 } : new byte[] { -2, -1, 0, 32,
+                0, 98, 0, 117, 0, 102, 0, 102, 0, 101, 0, 114 };
+        return ByteBuffer.wrap(b);
+    }
+
+    protected ByteBuffer getHeadlessByteBuffer() {
+        ByteBuffer b = getByteBuffer();
+        b.position(2);
+        byte[] bytes = new byte[b.remaining()];
+        b.get(bytes);
+        return ByteBuffer.wrap(bytes);
+    }
+
+    public void testMultiStepDecode() throws CharacterCodingException {
+        if (!cs.name().equals("mock")) {
+            decoder.onMalformedInput(CodingErrorAction.REPORT);
+            decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
+            CharBuffer out = CharBuffer.allocate(10);
+            assertTrue(decoder.decode(
+                    ByteBuffer.wrap(new byte[] { -1, -2, 32, 0, 98 }), out,
+                    true).isMalformed());
+
+            decoder.flush(out);
+            decoder.reset();
+            out.clear();
+            assertSame(CoderResult.UNDERFLOW, decoder.decode(ByteBuffer
+                    .wrap(new byte[] { -1, -2, 32, 0 }), out, false));
+            assertTrue(decoder.decode(ByteBuffer.wrap(new byte[] { 98 }), out,
+                    true).isMalformed());
+
+            decoder.flush(out);
+            decoder.reset();
+            out.clear();
+            assertSame(CoderResult.UNDERFLOW, decoder.decode(ByteBuffer
+                    .wrap(new byte[] { -1, -2, 32, 0, 98 }), out, false));
+            assertFalse(decoder.decode(ByteBuffer.wrap(new byte[] {}), out,
+                    true).isMalformed());
+
+            decoder.flush(out);
+            decoder.reset();
+            out.clear();
+            assertFalse(decoder.decode(
+                    ByteBuffer.wrap(new byte[] { -1, -2, 32, 0, 98, 0 }), out,
+                    true).isError());
+
+            decoder.flush(out);
+            decoder.reset();
+            out.clear();
+            assertSame(CoderResult.UNDERFLOW, decoder.decode(ByteBuffer
+                    .wrap(new byte[] { -1, -2, 32, 0, 98 }), out, false));
+            assertTrue(decoder.decode(ByteBuffer.wrap(new byte[] { 0 }), out,
+                    true).isMalformed());
+
+        }
+    }
+
+    public void testLittleEndianByteBufferCharBuffer()
+            throws CharacterCodingException, UnsupportedEncodingException {
+        bigEndian = false;
+        implTestDecodeByteBufferCharBuffer(getByteBuffer());
+        bigEndian = true;
+    }
+
+    public void testLittleEndianReadOnlyByteBufferCharBuffer()
+            throws CharacterCodingException, UnsupportedEncodingException {
+        bigEndian = false;
+        implTestDecodeByteBufferCharBuffer(getByteBuffer().asReadOnlyBuffer());
+        bigEndian = true;
+    }
+
+    public void testLittleEndian() throws CharacterCodingException,
+            UnsupportedEncodingException {
+        bigEndian = false;
+        implTestDecodeByteBuffer();
+        bigEndian = true;
+    }
+
+    // FIXME: give up this tests
+    // public void testDefaultCharsPerByte() {
+    // // assertEquals(1, decoder.averageCharsPerByte());
+    // // assertEquals(1, decoder.maxCharsPerByte());
+    // assertEquals(decoder.averageCharsPerByte(), 0.5, 0.001);
+    // assertEquals(decoder.maxCharsPerByte(), 2, 0.001);
+    // }
+
+    ByteBuffer getUnmappedByteBuffer() throws UnsupportedEncodingException {
+        return null;
+    }
+
+    ByteBuffer getMalformedByteBuffer() throws UnsupportedEncodingException {
+        return null;
+        // FIXME: different here, RI can parse 0xd8d8
+        // ByteBuffer buffer = ByteBuffer.allocate(100);
+        // buffer.put((byte) -1);
+        // buffer.put((byte) -2);
+        // buffer.put((byte) 0xdc);
+        // buffer.put((byte) 0xdc);
+        // buffer.put(unibytes);
+        // buffer.flip();
+        // return buffer;
+    }
+
+    ByteBuffer getExceptionByteArray() throws UnsupportedEncodingException {
+        return null;
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetDecoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetDecoderTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetDecoderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetDecoderTest.java Wed Apr  9 04:01:14 2008
@@ -25,50 +25,48 @@
  */
 public class UTF16LECharsetDecoderTest extends CharsetDecoderTest {
 
-	protected void setUp() throws Exception {
-		cs = Charset.forName("utf-16le");
-		unibytes = new byte[] { 32, 0, 98, 0, 117, 0, 102, 0, 102, 0, 101, 0,
-				114, 0 };
-		super.setUp();
-	}
-
-	/*
-	 * @see CharsetDecoderTest#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-
-	// // FIXME: give up this tests
-	// public void testDefaultCharsPerByte(){
-	// // assertEquals(1, decoder.averageCharsPerByte());
-	// // assertEquals(1, decoder.maxCharsPerByte());
-	// assertEquals(decoder.averageCharsPerByte(), 0.5, 0.001);
-	// assertEquals(decoder.maxCharsPerByte(), 2, 0.001);
-	// }
-
-	ByteBuffer getUnmappedByteBuffer() throws UnsupportedEncodingException {
-		// no unmap byte buffer
-		return null;
-	}
-
-	ByteBuffer getMalformByteBuffer() throws UnsupportedEncodingException {
-		// FIXME: different here, JDK can parse 0xd8d8
-		// ByteBuffer buffer = ByteBuffer.allocate(100);
-		// buffer.put((byte)0xd8);
-		// buffer.put((byte)0xd8);
-		// buffer.put(unibytes);
-		// buffer.flip();
-		// return buffer;
-		return null;
-	}
-
-	ByteBuffer getExceptionByteArray() throws UnsupportedEncodingException {
-		return null;
-	}
-
-	byte[] getUnibytes() {
-		return new byte[] { 32, 0, 98, 0, 117, 0, 102, 0, 102, 0, 101, 0, 114,
-				0 };
-	}
+    protected void setUp() throws Exception {
+        cs = Charset.forName("utf-16le");
+        super.setUp();
+    }
+
+    /*
+     * @see CharsetDecoderTest#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    // // FIXME: give up this tests
+    // public void testDefaultCharsPerByte(){
+    // // assertEquals(1, decoder.averageCharsPerByte());
+    // // assertEquals(1, decoder.maxCharsPerByte());
+    // assertEquals(decoder.averageCharsPerByte(), 0.5, 0.001);
+    // assertEquals(decoder.maxCharsPerByte(), 2, 0.001);
+    // }
+
+    ByteBuffer getUnmappedByteBuffer() throws UnsupportedEncodingException {
+        // no unmap byte buffer
+        return null;
+    }
+
+    ByteBuffer getMalformedByteBuffer() throws UnsupportedEncodingException {
+        // FIXME: different here, JDK can parse 0xd8d8
+        // ByteBuffer buffer = ByteBuffer.allocate(100);
+        // buffer.put((byte)0xd8);
+        // buffer.put((byte)0xd8);
+        // buffer.put(unibytes);
+        // buffer.flip();
+        // return buffer;
+        return null;
+    }
+
+    ByteBuffer getExceptionByteArray() throws UnsupportedEncodingException {
+        return null;
+    }
+
+    protected ByteBuffer getByteBuffer() {
+        return ByteBuffer.wrap(new byte[] { 32, 0, 98, 0, 117, 0, 102, 0, 102,
+                0, 101, 0, 114, 0 });
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetDecoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetDecoderTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetDecoderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetDecoderTest.java Wed Apr  9 04:01:14 2008
@@ -25,39 +25,52 @@
  */
 public class UTFCharsetDecoderTest extends CharsetDecoderTest {
 
-	protected void setUp() throws Exception {
-		cs = Charset.forName("utf-8");
-		super.setUp();
-	}
-
-	/*
-	 * @see CharsetDecoderTest#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-
-	// FIXME: give up this tests
-	// public void testDefaultCharsPerByte(){
-	// assertEquals(decoder.averageCharsPerByte(), 0.333, 0.001);
-	// assertEquals(decoder.maxCharsPerByte(), 2, 0.001);
-	// // assertEquals(1, decoder.averageCharsPerByte());
-	// // assertEquals(1, decoder.maxCharsPerByte());
-	// }
-
-	ByteBuffer getUnmappedByteBuffer() throws UnsupportedEncodingException {
-		return null;
-	}
-
-	ByteBuffer getMalformByteBuffer() throws UnsupportedEncodingException {
-		ByteBuffer buffer = ByteBuffer.allocate(20);
-		buffer.put((byte) 0xd8);
-		buffer.put(unibytes);
-		buffer.flip();
-		return buffer;
-	}
-
-	ByteBuffer getExceptionByteArray() throws UnsupportedEncodingException {
-		return null;
-	}
+    protected void setUp() throws Exception {
+        cs = Charset.forName("utf-8");
+        super.setUp();
+    }
+
+    /*
+     * @see CharsetDecoderTest#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    // FIXME: give up this tests
+    // public void testDefaultCharsPerByte(){
+    // assertEquals(decoder.averageCharsPerByte(), 0.333, 0.001);
+    // assertEquals(decoder.maxCharsPerByte(), 2, 0.001);
+    // // assertEquals(1, decoder.averageCharsPerByte());
+    // // assertEquals(1, decoder.maxCharsPerByte());
+    // }
+
+    ByteBuffer getUnmappedByteBuffer() throws UnsupportedEncodingException {
+        return null;
+    }
+
+    ByteBuffer getMalformedByteBuffer() throws UnsupportedEncodingException {
+        ByteBuffer buffer = ByteBuffer.allocate(getByteBuffer().remaining() + 1);
+        buffer.put((byte) 0xd8);
+        buffer.put(getByteBuffer());
+        buffer.flip();
+        return buffer;
+    }
+
+    ByteBuffer getExceptionByteArray() throws UnsupportedEncodingException {
+        return null;
+    }
+
+    protected String getString() {
+        return " buffer \u041c\u0430\u0441\u044e\u043b\u044f \u611b";
+    }
+
+    protected ByteBuffer getByteBuffer() {
+        return ByteBuffer.wrap(new byte[] { 32, 98, 117, 102, 102, 101, 114,
+                32, (byte) 0xd0, (byte) 0x9c, (byte) 0xd0, (byte) 0xb0,
+                (byte) 0xd1, (byte) 0x81, (byte) 0xd1, (byte) 0x8e,
+                (byte) 0xd0, (byte) 0xbb, (byte) 0xd1, (byte) 0x8f, 32,
+                (byte) 0xe6, (byte) 0x84, (byte) 0x9b });
+    }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/build.xml Wed Apr  9 04:01:14 2008
@@ -126,7 +126,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/pack200.jar"
-             manifest="${hy.pack200}/META-INF/MANIFEST.MF">
+             manifest="${hy.pack200}/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/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=646264&r1=646263&r2=646264&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 Wed Apr  9 04:01:14 2008
@@ -30,26 +30,20 @@
 import java.util.zip.GZIPInputStream;
 
 /**
- * The Archive class is the main entry point to unpack200. An archive is
- * constructed with either two file names, a pack file and an output file name
- * or two input streams corresponding to the input and the output streams. Then
+ * Archive is the main entry point to unpack200. An archive is constructed with
+ * either two file names, a pack file and an output file name or two input
+ * streams corresponding to the input and the output streams. Then
  * <code>unpack()</code> is called, to unpack the pack200 archive.
  */
 public class Archive {
 
-    private static final int LOG_LEVEL_VERBOSE = 2;
-
-    private static final int LOG_LEVEL_STANDARD = 1;
-
-    private static final int LOG_LEVEL_QUIET = 0;
-
     private InputStream inputStream;
 
-    private JarOutputStream outputStream;
+    private final JarOutputStream outputStream;
 
     private boolean removePackFile;
 
-    private int logLevel = LOG_LEVEL_STANDARD;
+    private int logLevel = Segment.LOG_LEVEL_STANDARD;
 
     private FileOutputStream logFile;
 
@@ -59,6 +53,8 @@
 
     private String inputFileName;
 
+	private String outputFileName;
+
     /**
      * Creates an Archive with the given input and output file names.
      * @param inputFile
@@ -69,6 +65,7 @@
     public Archive(String inputFile, String outputFile)
             throws FileNotFoundException, IOException {
         this.inputFileName = inputFile;
+        this.outputFileName = outputFile;
         inputStream = new FileInputStream(inputFile);
         outputStream = new JarOutputStream(new FileOutputStream(outputFile));
     }
@@ -135,29 +132,49 @@
                     outputStream.closeEntry();
                 }
             } else {
+            	int i = 0;
                 while (available(inputStream)) {
+                	i++;
                     Segment segment = new Segment();
                     segment.setLogLevel(logLevel);
                     segment.setLogStream(logFile != null ? (OutputStream) logFile
                             : (OutputStream) System.out);
+                    if (i == 1) {
+						segment.log(Segment.LOG_LEVEL_VERBOSE,
+								"Unpacking from " + inputFileName + " to "
+										+ outputFileName);
+					}
+                    segment.log(Segment.LOG_LEVEL_VERBOSE, "Reading segment " + i);
                     if (overrideDeflateHint) {
                         segment.overrideDeflateHint(deflateHint);
                     }
                     segment.unpack(inputStream, outputStream);
                     outputStream.flush();
+
+                    if(inputStream instanceof FileInputStream) {
+                    	inputFileName = ((FileInputStream)inputStream).getFD().toString();
+                    }
                 }
             }
         } finally {
             try {
                 inputStream.close();
-            } catch (Exception e2) {}
+            } catch (Exception e) {}
             try {
                 outputStream.close();
-            } catch (Exception e2) {}
+            } catch (Exception e) {}
+            if(logFile != null) {
+            	try {
+            		logFile.close();
+            	} catch (Exception e) {}
+            }
         }
         if (removePackFile) {
             File file = new File(inputFileName);
-            file.delete();
+            boolean deleted = file.delete();
+            if(!deleted) {
+            	throw new Pack200Exception("Failed to delete the input file.");
+            }
         }
     }
 
@@ -180,17 +197,17 @@
 
     public void setVerbose(boolean verbose) {
         if (verbose) {
-            logLevel = LOG_LEVEL_VERBOSE;
-        } else if (logLevel == LOG_LEVEL_VERBOSE) {
-            logLevel = LOG_LEVEL_STANDARD;
+            logLevel = Segment.LOG_LEVEL_VERBOSE;
+        } else if (logLevel == Segment.LOG_LEVEL_VERBOSE) {
+            logLevel = Segment.LOG_LEVEL_STANDARD;
         }
     }
 
     public void setQuiet(boolean quiet) {
         if (quiet) {
-            logLevel = LOG_LEVEL_QUIET;
-        } else if (logLevel == LOG_LEVEL_QUIET) {
-            logLevel = LOG_LEVEL_QUIET;
+            logLevel = Segment.LOG_LEVEL_QUIET;
+        } else if (logLevel == Segment.LOG_LEVEL_QUIET) {
+            logLevel = Segment.LOG_LEVEL_QUIET;
         }
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java Wed Apr  9 04:01:14 2008
@@ -20,7 +20,8 @@
 import java.io.InputStream;
 
 /**
- *
+ * Attribute definition bands are the set of bands used to define extra
+ * attributes transmitted in the archive.
  */
 public class AttrDefinitionBands extends BandSet {
 
@@ -32,7 +33,7 @@
 
     private AttributeLayoutMap attributeDefinitionMap;
 
-    private String[] cpUTF8;
+    private final String[] cpUTF8;
 
     public AttrDefinitionBands(Segment segment) {
         super(segment);

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java Wed Apr  9 04:01:14 2008
@@ -16,7 +16,10 @@
  */
 package org.apache.harmony.pack200;
 
-
+/**
+ * AttributeLayout defines a layout that describes how an attribute will be
+ * transmitted.
+ */
 public class AttributeLayout implements IMatcher {
 
 	public static final String ACC_ABSTRACT = "ACC_ABSTRACT"; //$NON-NLS-1$
@@ -89,16 +92,16 @@
 	}
 
 
-    private int context;
+    private final int context;
 
-    private int index;
+    private final int index;
 
 	private final String layout;
 
 	private long mask;
 
-    private String name;
-    private boolean isDefault;
+    private final String name;
+    private final boolean isDefault;
     private int backwardsCallCount;
 
 

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayoutMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayoutMap.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayoutMap.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayoutMap.java Wed Apr  9 04:01:14 2008
@@ -16,8 +16,11 @@
  */
 package org.apache.harmony.pack200;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -27,169 +30,169 @@
  */
 public class AttributeLayoutMap {
 
-	// Create all the default AttributeLayouts here
-	private static AttributeLayout[] getDefaultAttributeLayouts()
-			throws Pack200Exception {
-		return new AttributeLayout[] {
-				new AttributeLayout(AttributeLayout.ACC_PUBLIC,
-						AttributeLayout.CONTEXT_CLASS, "", 0),
-				new AttributeLayout(AttributeLayout.ACC_PUBLIC,
-						AttributeLayout.CONTEXT_FIELD, "", 0),
-				new AttributeLayout(AttributeLayout.ACC_PUBLIC,
-						AttributeLayout.CONTEXT_METHOD, "", 0),
-				new AttributeLayout(AttributeLayout.ACC_PRIVATE,
-						AttributeLayout.CONTEXT_CLASS, "", 1),
-				new AttributeLayout(AttributeLayout.ACC_PRIVATE,
-						AttributeLayout.CONTEXT_FIELD, "", 1),
-				new AttributeLayout(AttributeLayout.ACC_PRIVATE,
-						AttributeLayout.CONTEXT_METHOD, "", 1),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_LINE_NUMBER_TABLE,
-						AttributeLayout.CONTEXT_CODE, "NH[PHH]", 1),
-
-				new AttributeLayout(AttributeLayout.ACC_PROTECTED,
-						AttributeLayout.CONTEXT_CLASS, "", 2),
-				new AttributeLayout(AttributeLayout.ACC_PROTECTED,
-						AttributeLayout.CONTEXT_FIELD, "", 2),
-				new AttributeLayout(AttributeLayout.ACC_PROTECTED,
-						AttributeLayout.CONTEXT_METHOD, "", 2),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_LOCAL_VARIABLE_TABLE,
-						AttributeLayout.CONTEXT_CODE, "NH[PHOHRUHRSHH]", 2),
-
-				new AttributeLayout(AttributeLayout.ACC_STATIC,
-						AttributeLayout.CONTEXT_CLASS, "", 3),
-				new AttributeLayout(AttributeLayout.ACC_STATIC,
-						AttributeLayout.CONTEXT_FIELD, "", 3),
-				new AttributeLayout(AttributeLayout.ACC_STATIC,
-						AttributeLayout.CONTEXT_METHOD, "", 3),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_LOCAL_VARIABLE_TYPE_TABLE,
-						AttributeLayout.CONTEXT_CODE, "NH[PHOHRUHRSHH]", 3),
-
-				new AttributeLayout(AttributeLayout.ACC_FINAL,
-						AttributeLayout.CONTEXT_CLASS, "", 4),
-				new AttributeLayout(AttributeLayout.ACC_FINAL,
-						AttributeLayout.CONTEXT_FIELD, "", 4),
-				new AttributeLayout(AttributeLayout.ACC_FINAL,
-						AttributeLayout.CONTEXT_METHOD, "", 4),
-				new AttributeLayout(AttributeLayout.ACC_SYNCHRONIZED,
-						AttributeLayout.CONTEXT_CLASS, "", 5),
-				new AttributeLayout(AttributeLayout.ACC_SYNCHRONIZED,
-						AttributeLayout.CONTEXT_FIELD, "", 5),
-				new AttributeLayout(AttributeLayout.ACC_SYNCHRONIZED,
-						AttributeLayout.CONTEXT_METHOD, "", 5),
-				new AttributeLayout(AttributeLayout.ACC_VOLATILE,
-						AttributeLayout.CONTEXT_CLASS, "", 6),
-				new AttributeLayout(AttributeLayout.ACC_VOLATILE,
-						AttributeLayout.CONTEXT_FIELD, "", 6),
-				new AttributeLayout(AttributeLayout.ACC_VOLATILE,
-						AttributeLayout.CONTEXT_METHOD, "", 6),
-				new AttributeLayout(AttributeLayout.ACC_TRANSIENT,
-						AttributeLayout.CONTEXT_CLASS, "", 7),
-				new AttributeLayout(AttributeLayout.ACC_TRANSIENT,
-						AttributeLayout.CONTEXT_FIELD, "", 7),
-				new AttributeLayout(AttributeLayout.ACC_TRANSIENT,
-						AttributeLayout.CONTEXT_METHOD, "", 7),
-				new AttributeLayout(AttributeLayout.ACC_NATIVE,
-						AttributeLayout.CONTEXT_CLASS, "", 8),
-				new AttributeLayout(AttributeLayout.ACC_NATIVE,
-						AttributeLayout.CONTEXT_FIELD, "", 8),
-				new AttributeLayout(AttributeLayout.ACC_NATIVE,
-						AttributeLayout.CONTEXT_METHOD, "", 8),
-				new AttributeLayout(AttributeLayout.ACC_INTERFACE,
-						AttributeLayout.CONTEXT_CLASS, "", 9),
-				new AttributeLayout(AttributeLayout.ACC_INTERFACE,
-						AttributeLayout.CONTEXT_FIELD, "", 9),
-				new AttributeLayout(AttributeLayout.ACC_INTERFACE,
-						AttributeLayout.CONTEXT_METHOD, "", 9),
-				new AttributeLayout(AttributeLayout.ACC_ABSTRACT,
-						AttributeLayout.CONTEXT_CLASS, "", 10),
-				new AttributeLayout(AttributeLayout.ACC_ABSTRACT,
-						AttributeLayout.CONTEXT_FIELD, "", 10),
-				new AttributeLayout(AttributeLayout.ACC_ABSTRACT,
-						AttributeLayout.CONTEXT_METHOD, "", 10),
-				new AttributeLayout(AttributeLayout.ACC_STRICT,
-						AttributeLayout.CONTEXT_CLASS, "", 11),
-				new AttributeLayout(AttributeLayout.ACC_STRICT,
-						AttributeLayout.CONTEXT_FIELD, "", 11),
-				new AttributeLayout(AttributeLayout.ACC_STRICT,
-						AttributeLayout.CONTEXT_METHOD, "", 11),
-				new AttributeLayout(AttributeLayout.ACC_SYNTHETIC,
-						AttributeLayout.CONTEXT_CLASS, "", 12),
-				new AttributeLayout(AttributeLayout.ACC_SYNTHETIC,
-						AttributeLayout.CONTEXT_FIELD, "", 12),
-				new AttributeLayout(AttributeLayout.ACC_SYNTHETIC,
-						AttributeLayout.CONTEXT_METHOD, "", 12),
-				new AttributeLayout(AttributeLayout.ACC_ANNOTATION,
-						AttributeLayout.CONTEXT_CLASS, "", 13),
-				new AttributeLayout(AttributeLayout.ACC_ANNOTATION,
-						AttributeLayout.CONTEXT_FIELD, "", 13),
-				new AttributeLayout(AttributeLayout.ACC_ANNOTATION,
-						AttributeLayout.CONTEXT_METHOD, "", 13),
-				new AttributeLayout(AttributeLayout.ACC_ENUM,
-						AttributeLayout.CONTEXT_CLASS, "", 14),
-				new AttributeLayout(AttributeLayout.ACC_ENUM,
-						AttributeLayout.CONTEXT_FIELD, "", 14),
-				new AttributeLayout(AttributeLayout.ACC_ENUM,
-						AttributeLayout.CONTEXT_METHOD, "", 14),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_SOURCE_FILE,
-						AttributeLayout.CONTEXT_CLASS, "RUNH", 17),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_CONSTANT_VALUE,
-						AttributeLayout.CONTEXT_FIELD, "KQH", 17),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_CODE,
-						AttributeLayout.CONTEXT_METHOD, "", 17),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_ENCLOSING_METHOD,
-						AttributeLayout.CONTEXT_CLASS, "RCHRDNH", 18),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_EXCEPTIONS,
-						AttributeLayout.CONTEXT_METHOD, "NH[RCH]", 18),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_SIGNATURE,
-						AttributeLayout.CONTEXT_CLASS, "RSH", 19),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_SIGNATURE,
-						AttributeLayout.CONTEXT_FIELD, "RSH", 19),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_SIGNATURE,
-						AttributeLayout.CONTEXT_METHOD, "RSH", 19),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_DEPRECATED,
-						AttributeLayout.CONTEXT_CLASS, "", 20),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_DEPRECATED,
-						AttributeLayout.CONTEXT_FIELD, "", 20),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_DEPRECATED,
-						AttributeLayout.CONTEXT_METHOD, "", 20),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
-						AttributeLayout.CONTEXT_CLASS, "*", 21),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
-						AttributeLayout.CONTEXT_FIELD, "*", 21),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
-						AttributeLayout.CONTEXT_METHOD, "*", 21),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
-						AttributeLayout.CONTEXT_CLASS, "*", 22),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
-						AttributeLayout.CONTEXT_FIELD, "*", 22),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
-						AttributeLayout.CONTEXT_METHOD, "*", 22),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_INNER_CLASSES,
-						AttributeLayout.CONTEXT_CLASS, "", 23),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS,
-						AttributeLayout.CONTEXT_METHOD, "*", 23),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_CLASS_FILE_VERSION,
-						AttributeLayout.CONTEXT_CLASS, "*", 24),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS,
-						AttributeLayout.CONTEXT_METHOD, "*", 24),
-				new AttributeLayout(
-						AttributeLayout.ATTRIBUTE_ANNOTATION_DEFAULT,
-						AttributeLayout.CONTEXT_METHOD, "*", 25) };
-	}
+    // Create all the default AttributeLayouts here
+    private static AttributeLayout[] getDefaultAttributeLayouts()
+            throws Pack200Exception {
+        return new AttributeLayout[] {
+                new AttributeLayout(AttributeLayout.ACC_PUBLIC,
+                        AttributeLayout.CONTEXT_CLASS, "", 0),
+                new AttributeLayout(AttributeLayout.ACC_PUBLIC,
+                        AttributeLayout.CONTEXT_FIELD, "", 0),
+                new AttributeLayout(AttributeLayout.ACC_PUBLIC,
+                        AttributeLayout.CONTEXT_METHOD, "", 0),
+                new AttributeLayout(AttributeLayout.ACC_PRIVATE,
+                        AttributeLayout.CONTEXT_CLASS, "", 1),
+                new AttributeLayout(AttributeLayout.ACC_PRIVATE,
+                        AttributeLayout.CONTEXT_FIELD, "", 1),
+                new AttributeLayout(AttributeLayout.ACC_PRIVATE,
+                        AttributeLayout.CONTEXT_METHOD, "", 1),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_LINE_NUMBER_TABLE,
+                        AttributeLayout.CONTEXT_CODE, "NH[PHH]", 1),
+
+                new AttributeLayout(AttributeLayout.ACC_PROTECTED,
+                        AttributeLayout.CONTEXT_CLASS, "", 2),
+                new AttributeLayout(AttributeLayout.ACC_PROTECTED,
+                        AttributeLayout.CONTEXT_FIELD, "", 2),
+                new AttributeLayout(AttributeLayout.ACC_PROTECTED,
+                        AttributeLayout.CONTEXT_METHOD, "", 2),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_LOCAL_VARIABLE_TABLE,
+                        AttributeLayout.CONTEXT_CODE, "NH[PHOHRUHRSHH]", 2),
+
+                new AttributeLayout(AttributeLayout.ACC_STATIC,
+                        AttributeLayout.CONTEXT_CLASS, "", 3),
+                new AttributeLayout(AttributeLayout.ACC_STATIC,
+                        AttributeLayout.CONTEXT_FIELD, "", 3),
+                new AttributeLayout(AttributeLayout.ACC_STATIC,
+                        AttributeLayout.CONTEXT_METHOD, "", 3),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_LOCAL_VARIABLE_TYPE_TABLE,
+                        AttributeLayout.CONTEXT_CODE, "NH[PHOHRUHRSHH]", 3),
+
+                new AttributeLayout(AttributeLayout.ACC_FINAL,
+                        AttributeLayout.CONTEXT_CLASS, "", 4),
+                new AttributeLayout(AttributeLayout.ACC_FINAL,
+                        AttributeLayout.CONTEXT_FIELD, "", 4),
+                new AttributeLayout(AttributeLayout.ACC_FINAL,
+                        AttributeLayout.CONTEXT_METHOD, "", 4),
+                new AttributeLayout(AttributeLayout.ACC_SYNCHRONIZED,
+                        AttributeLayout.CONTEXT_CLASS, "", 5),
+                new AttributeLayout(AttributeLayout.ACC_SYNCHRONIZED,
+                        AttributeLayout.CONTEXT_FIELD, "", 5),
+                new AttributeLayout(AttributeLayout.ACC_SYNCHRONIZED,
+                        AttributeLayout.CONTEXT_METHOD, "", 5),
+                new AttributeLayout(AttributeLayout.ACC_VOLATILE,
+                        AttributeLayout.CONTEXT_CLASS, "", 6),
+                new AttributeLayout(AttributeLayout.ACC_VOLATILE,
+                        AttributeLayout.CONTEXT_FIELD, "", 6),
+                new AttributeLayout(AttributeLayout.ACC_VOLATILE,
+                        AttributeLayout.CONTEXT_METHOD, "", 6),
+                new AttributeLayout(AttributeLayout.ACC_TRANSIENT,
+                        AttributeLayout.CONTEXT_CLASS, "", 7),
+                new AttributeLayout(AttributeLayout.ACC_TRANSIENT,
+                        AttributeLayout.CONTEXT_FIELD, "", 7),
+                new AttributeLayout(AttributeLayout.ACC_TRANSIENT,
+                        AttributeLayout.CONTEXT_METHOD, "", 7),
+                new AttributeLayout(AttributeLayout.ACC_NATIVE,
+                        AttributeLayout.CONTEXT_CLASS, "", 8),
+                new AttributeLayout(AttributeLayout.ACC_NATIVE,
+                        AttributeLayout.CONTEXT_FIELD, "", 8),
+                new AttributeLayout(AttributeLayout.ACC_NATIVE,
+                        AttributeLayout.CONTEXT_METHOD, "", 8),
+                new AttributeLayout(AttributeLayout.ACC_INTERFACE,
+                        AttributeLayout.CONTEXT_CLASS, "", 9),
+                new AttributeLayout(AttributeLayout.ACC_INTERFACE,
+                        AttributeLayout.CONTEXT_FIELD, "", 9),
+                new AttributeLayout(AttributeLayout.ACC_INTERFACE,
+                        AttributeLayout.CONTEXT_METHOD, "", 9),
+                new AttributeLayout(AttributeLayout.ACC_ABSTRACT,
+                        AttributeLayout.CONTEXT_CLASS, "", 10),
+                new AttributeLayout(AttributeLayout.ACC_ABSTRACT,
+                        AttributeLayout.CONTEXT_FIELD, "", 10),
+                new AttributeLayout(AttributeLayout.ACC_ABSTRACT,
+                        AttributeLayout.CONTEXT_METHOD, "", 10),
+                new AttributeLayout(AttributeLayout.ACC_STRICT,
+                        AttributeLayout.CONTEXT_CLASS, "", 11),
+                new AttributeLayout(AttributeLayout.ACC_STRICT,
+                        AttributeLayout.CONTEXT_FIELD, "", 11),
+                new AttributeLayout(AttributeLayout.ACC_STRICT,
+                        AttributeLayout.CONTEXT_METHOD, "", 11),
+                new AttributeLayout(AttributeLayout.ACC_SYNTHETIC,
+                        AttributeLayout.CONTEXT_CLASS, "", 12),
+                new AttributeLayout(AttributeLayout.ACC_SYNTHETIC,
+                        AttributeLayout.CONTEXT_FIELD, "", 12),
+                new AttributeLayout(AttributeLayout.ACC_SYNTHETIC,
+                        AttributeLayout.CONTEXT_METHOD, "", 12),
+                new AttributeLayout(AttributeLayout.ACC_ANNOTATION,
+                        AttributeLayout.CONTEXT_CLASS, "", 13),
+                new AttributeLayout(AttributeLayout.ACC_ANNOTATION,
+                        AttributeLayout.CONTEXT_FIELD, "", 13),
+                new AttributeLayout(AttributeLayout.ACC_ANNOTATION,
+                        AttributeLayout.CONTEXT_METHOD, "", 13),
+                new AttributeLayout(AttributeLayout.ACC_ENUM,
+                        AttributeLayout.CONTEXT_CLASS, "", 14),
+                new AttributeLayout(AttributeLayout.ACC_ENUM,
+                        AttributeLayout.CONTEXT_FIELD, "", 14),
+                new AttributeLayout(AttributeLayout.ACC_ENUM,
+                        AttributeLayout.CONTEXT_METHOD, "", 14),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_SOURCE_FILE,
+                        AttributeLayout.CONTEXT_CLASS, "RUNH", 17),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_CONSTANT_VALUE,
+                        AttributeLayout.CONTEXT_FIELD, "KQH", 17),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_CODE,
+                        AttributeLayout.CONTEXT_METHOD, "", 17),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_ENCLOSING_METHOD,
+                        AttributeLayout.CONTEXT_CLASS, "RCHRDNH", 18),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_EXCEPTIONS,
+                        AttributeLayout.CONTEXT_METHOD, "NH[RCH]", 18),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_SIGNATURE,
+                        AttributeLayout.CONTEXT_CLASS, "RSH", 19),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_SIGNATURE,
+                        AttributeLayout.CONTEXT_FIELD, "RSH", 19),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_SIGNATURE,
+                        AttributeLayout.CONTEXT_METHOD, "RSH", 19),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_DEPRECATED,
+                        AttributeLayout.CONTEXT_CLASS, "", 20),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_DEPRECATED,
+                        AttributeLayout.CONTEXT_FIELD, "", 20),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_DEPRECATED,
+                        AttributeLayout.CONTEXT_METHOD, "", 20),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
+                        AttributeLayout.CONTEXT_CLASS, "*", 21),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
+                        AttributeLayout.CONTEXT_FIELD, "*", 21),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
+                        AttributeLayout.CONTEXT_METHOD, "*", 21),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
+                        AttributeLayout.CONTEXT_CLASS, "*", 22),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
+                        AttributeLayout.CONTEXT_FIELD, "*", 22),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
+                        AttributeLayout.CONTEXT_METHOD, "*", 22),
+                new AttributeLayout(AttributeLayout.ATTRIBUTE_INNER_CLASSES,
+                        AttributeLayout.CONTEXT_CLASS, "", 23),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS,
+                        AttributeLayout.CONTEXT_METHOD, "*", 23),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_CLASS_FILE_VERSION,
+                        AttributeLayout.CONTEXT_CLASS, "", 24),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS,
+                        AttributeLayout.CONTEXT_METHOD, "*", 24),
+                new AttributeLayout(
+                        AttributeLayout.ATTRIBUTE_ANNOTATION_DEFAULT,
+                        AttributeLayout.CONTEXT_METHOD, "*", 25) };
+    }
 
-	private final Map classLayouts = new HashMap();
+    private final Map classLayouts = new HashMap();
     private final Map fieldLayouts = new HashMap();
     private final Map methodLayouts = new HashMap();
     private final Map codeLayouts = new HashMap();
@@ -200,16 +203,16 @@
 
     private final Map layoutsToBands = new HashMap();
 
-	public AttributeLayoutMap() throws Pack200Exception {
-		AttributeLayout[] defaultAttributeLayouts = getDefaultAttributeLayouts();
-		for (int i = 0; i < defaultAttributeLayouts.length; i++) {
-			add(defaultAttributeLayouts[i]);
-		}
-	}
+    public AttributeLayoutMap() throws Pack200Exception {
+        AttributeLayout[] defaultAttributeLayouts = getDefaultAttributeLayouts();
+        for (int i = 0; i < defaultAttributeLayouts.length; i++) {
+            add(defaultAttributeLayouts[i]);
+        }
+    }
 
-	public void add(AttributeLayout layout) {
+    public void add(AttributeLayout layout) {
         layouts[layout.getContext()].put(new Integer(layout.getIndex()), layout);
-	}
+    }
 
 
 
@@ -218,9 +221,9 @@
         layoutsToBands.put(layout, newBands);
     }
 
-	public AttributeLayout getAttributeLayout(String name, int context)
-			throws Pack200Exception {
-	    Map map = layouts[context];
+    public AttributeLayout getAttributeLayout(String name, int context)
+            throws Pack200Exception {
+        Map map = layouts[context];
         for (Iterator iter = map.values().iterator(); iter.hasNext();) {
             AttributeLayout layout = (AttributeLayout) iter.next();
             if(layout.getName().equals(name)) {
@@ -228,7 +231,7 @@
             }
         }
         return null;
-	}
+    }
 
     public AttributeLayout getAttributeLayout(int index, int context)
             throws Pack200Exception {
@@ -245,23 +248,26 @@
     public void checkMap() throws Pack200Exception {
         for (int i = 0; i < layouts.length; i++) {
             Map map = layouts[i];
-            for (Iterator iter = map.values().iterator(); iter.hasNext();) {
-                AttributeLayout layout1 = (AttributeLayout) iter.next();
-                for (Iterator iter2 = map.values().iterator(); iter2.hasNext();) {
-                    AttributeLayout layout2 = (AttributeLayout) iter2.next();
-                    if(layout1 != layout2) {
-                        if (layout1.getName().equals(layout2.getName())
-                                && layout1.getLayout().equals(
-                                        layout2.getLayout())) {
-                            throw new Pack200Exception(
-                                    "Same layout/name combination: "
-                                            + layout1.getLayout()
-                                            + "/"
-                                            + layout1.getName()
-                                            + " exists twice for context: "
-                                            + AttributeLayout.contextNames[layout1
-                                                    .getContext()]);
-                        }
+            Collection c = map.values();
+            if(!(c instanceof List)) {
+                c = new ArrayList(c);
+            }
+            List l = (List)c;
+            for (int j = 0; j < l.size(); j++) {
+                AttributeLayout layout1 = (AttributeLayout) l.get(j);
+                for (int j2 = j + 1; j2 < l.size(); j2++) {
+                    AttributeLayout layout2 = (AttributeLayout) l.get(j2);
+                    if (layout1.getName().equals(layout2.getName())
+                            && layout1.getLayout().equals(
+                                    layout2.getLayout())) {
+                        throw new Pack200Exception(
+                                "Same layout/name combination: "
+                                        + layout1.getLayout()
+                                        + "/"
+                                        + layout1.getName()
+                                        + " exists twice for context: "
+                                        + AttributeLayout.contextNames[layout1
+                                                .getContext()]);
                     }
                 }
             }
@@ -272,4 +278,4 @@
         return (NewAttributeBands) layoutsToBands.get(layout);
     }
 
-}
+}
\ No newline at end of file

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java Wed Apr  9 04:01:14 2008
@@ -23,8 +23,59 @@
 import java.util.List;
 
 /**
- * TODO Comment -- quite a lot can be nicked from Codec, since this was created
- * from it
+ * A BHSD codec is a means of encoding integer values as a sequence of bytes or
+ * vice versa using a specified "BHSD" encoding mechanism. It uses a variable-length encoding and a modified sign representation
+ * such that small numbers are represented as a single byte, whilst larger
+ * numbers take more bytes to encode. The number may be signed or unsigned; if
+ * it is unsigned, it can be weighted towards positive numbers or equally
+ * distributed using a one's complement. The Codec also supports delta coding,
+ * where a sequence of numbers is represented as a series of first-order
+ * differences. So a delta encoding of the integers [1..10] would be represented
+ * as a sequence of 10x1s. This allows the absolute value of a coded integer to
+ * fall outside of the 'small number' range, whilst still being encoded as a
+ * single byte.
+ *
+ * A BHSD codec is configured with four parameters:
+ * <dl>
+ * <dt>B</dt>
+ * <dd>The maximum number of bytes that each value is encoded as. B must be a
+ * value between [1..5]. For a pass-through coding (where each byte is encoded
+ * as itself, aka {@link #BYTE1}, B is 1 (each byte takes a maximum of 1 byte).</dd>
+ * <dt>H</dt>
+ * <dd>The radix of the integer. Values are defined as a sequence of values,
+ * where value <code>n</code> is multiplied by <code>H^<sup>n</sup></code>.
+ * So the number 1234 may be represented as the sequence 4 3 2 1 with a radix
+ * (H) of 10. Note that other permutations are also possible; 43 2 1 will also
+ * encode 1234. The co-parameter L is defined as 256-H. This is important
+ * because only the last value in a sequence may be &lt; L; all prior values
+ * must be &gt; L.</dd>
+ * <dt>S</dt>
+ * <dd>Whether the codec represents signed values (or not). This may have 3
+ * values; 0 (unsigned), 1 (signed, one's complement) or 2 (signed, two's
+ * complement)</dd>
+ * <dt>D</dt>
+ * <dd>Whether the codec represents a delta encoding. This may be 0 (no delta)
+ * or 1 (delta encoding). A delta encoding of 1 indicates that values are
+ * cumulative; a sequence of <code>1 1 1 1 1</code> will represent the
+ * sequence <code>1 2 3 4 5</code>. For this reason, the codec supports two
+ * variants of decode; one {@link #decode(InputStream, long) with} and one
+ * {@link #decode(InputStream) without} a <code>last</code> parameter. If the
+ * codec is a non-delta encoding, then the value is ignored if passed. If the
+ * codec is a delta encoding, it is a run-time error to call the value without
+ * the extra parameter, and the previous value should be returned. (It was
+ * designed this way to support multi-threaded access without requiring a new
+ * instance of the Codec to be cloned for each use.)
+ * <dt>
+ * </dl>
+ *
+ * Codecs are notated as (B,H,S,D) and either D or S,D may be omitted if zero.
+ * Thus {@link #BYTE1} is denoted (1,256,0,0) or (1,256). The
+ * {@link #toString()} method prints out the condensed form of the encoding.
+ * Often, the last character in the name ({@link #BYTE1}, {@link #UNSIGNED5})
+ * gives a clue as to the B value. Those that start with U ({@link #UDELTA5},
+ * {@link #UNSIGNED5}) are unsigned; otherwise, in most cases, they are signed.
+ * The presence of the word Delta ({@link #DELTA5}, {@link #UDELTA5})
+ * indicates a delta encoding is used.
  *
  */
 public final class BHSDCodec extends Codec {
@@ -32,30 +83,34 @@
 	/**
 	 * The maximum number of bytes in each coding word
 	 */
-	private int b;
+	private final int b;
 
 	/**
 	 * Whether delta encoding is used (0=false,1=true)
 	 */
-	private int d;
+	private final int d;
 
 	/**
 	 * The radix of the encoding
 	 */
-	private int h;
+	private final int h;
 
 	/**
 	 * The co-parameter of h; h-256
 	 */
-	private int l;
+	private final int l;
 
 	/**
 	 * Represents signed numbers or not (0=unsigned,1/2=signed)
 	 */
-	private int s;
+	private final int s;
 
     private long cardinality;
 
+    private final long smallest;
+
+    private final long largest;
+
 	/**
 	 * Constructs an unsigned, non-delta Codec with the given B and H values.
 	 *
@@ -123,6 +178,8 @@
         } else {
             cardinality = (long) ((long)(l * (1-Math.pow(h, b))/(1-h)) + Math.pow(h,b));
         }
+        smallest = calculateSmallest();
+        largest = calculateLargest();
 	}
 
 	/**
@@ -157,38 +214,38 @@
             n++;
 		} while (n < b & isHigh(x));
 
-// TODO: Decide whether to use this algorithm instead (neater, possibly quicker but less easy to understand)
-//        if (isSigned()) {
-//            int u = ((1 << s) - 1);
-//            if ((z & u) == u) {
-//                z = z >>> s ^ -1L;
-//            } else {
-//                z = z - (z >>> s);
-//            }
-//        }
-        if(isSigned()) {
-            long u = z;
-            long twoPowS = (long)Math.pow(2, s);
-            double twoPowSMinusOne = twoPowS-1;
-            if(u % twoPowS < twoPowSMinusOne) {
-                if(cardinality < Math.pow(2, 32)) {
-                    z = (long) (u - (Math.floor(u/ twoPowS)));
-                } else {
-                    z = cast32((long) (u - (Math.floor(u/ twoPowS))));
-                }
+        if (isSigned()) {
+            int u = ((1 << s) - 1);
+            if ((z & u) == u) {
+                z = z >>> s ^ -1L;
             } else {
-                z = (long) (-Math.floor(u/ twoPowS) - 1);
+                z = z - (z >>> s);
             }
         }
+// This algorithm does the same thing, but is probably slower.  Leaving in for now for readability
+//        if(isSigned()) {
+//            long u = z;
+//            long twoPowS = (long)Math.pow(2, s);
+//            double twoPowSMinusOne = twoPowS-1;
+//            if(u % twoPowS < twoPowSMinusOne) {
+//                if(cardinality < Math.pow(2, 32)) {
+//                    z = (long) (u - (Math.floor(u/ twoPowS)));
+//                } else {
+//                    z = cast32((long) (u - (Math.floor(u/ twoPowS))));
+//                }
+//            } else {
+//                z = (long) (-Math.floor(u/ twoPowS) - 1);
+//            }
+//        }
 	    if (isDelta())
 	        z += last;
 		return z;
 	}
 
-	private long cast32(long u) {
-        u = (long) ((long) ((u + Math.pow(2, 31)) % Math.pow(2, 32)) - Math.pow(2, 31));
-        return u;
-    }
+//	private long cast32(long u) {
+//        u = (long) ((long) ((u + Math.pow(2, 31)) % Math.pow(2, 32)) - Math.pow(2, 31));
+//        return u;
+//    }
 
     private boolean isHigh(long x) {
         return x>=l;
@@ -202,7 +259,7 @@
 	 * @return <code>true</code> if the encoding can encode this value
 	 */
 	public boolean encodes(long value) {
-		return (value >= smallest() && value <= largest());
+		return (value >= smallest && value <= largest);
 	}
 
     public byte[] encode(long value, long last) throws Pack200Exception {
@@ -270,10 +327,17 @@
 	 *
 	 * @return the largest value that this codec can represent.
 	 */
-	public long largest() {
+    public long largest() {
+        return largest;
+    }
+
+	private long calculateLargest() {
 		long result;
 		// TODO This can probably be optimized into a better mathematical statement
-		if (s == 0) {
+        if(d == 1) {
+            BHSDCodec bh0 = new BHSDCodec(b, h);
+            return bh0.largest();
+        } else if (s == 0) {
 			result = cardinality() - 1;
 		} else if (s == 1) {
 			result = cardinality() / 2 - 1;
@@ -285,18 +349,30 @@
 		return Math.min((s == 0 ? ((long) Integer.MAX_VALUE) << 1
 				: Integer.MAX_VALUE) - 1, result);
 	}
+
 	/**
 	 * Returns the smallest value that this codec can represent.
 	 *
 	 * @return the smallest value that this codec can represent.
 	 */
-	public long smallest() {
+    public long smallest() {
+        return smallest;
+    }
+
+	private long calculateSmallest() {
 		long result;
-		if (isSigned()) {
-			result = -cardinality() / (1 << s);
-		} else {
-			result = 0;
-		}
+         if (d == 1) {
+            BHSDCodec bh0 = new BHSDCodec(b, h);
+            return bh0.smallest();
+        } else if (isSigned()) {
+            result = -cardinality() / (1 << s);
+        } else {
+            if (cardinality > Integer.MAX_VALUE) {
+                result = Integer.MIN_VALUE;
+            } else {
+                result = 0;
+            }
+        }
 		return Math.max(Integer.MIN_VALUE, result);
 	}
 	/**

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java Wed Apr  9 04:01:14 2008
@@ -34,6 +34,9 @@
 import org.apache.harmony.pack200.bytecode.CPUTF8;
 import org.apache.harmony.pack200.bytecode.ClassConstantPool;
 
+/**
+ * Abstract superclass for a set of bands
+ */
 public abstract class BandSet {
 
     public abstract void unpack(InputStream inputStream) throws IOException, Pack200Exception;
@@ -55,8 +58,8 @@
      *            purposes)
      * @param in
      *            the InputStream to decode from
-     * @param defaultCodec
-     *            the default codec for this band
+     * @param codec
+     *            the default Codec for this band
      * @param count
      *            the number of elements to read
      * @return an array of decoded <code>int</code> values
@@ -70,32 +73,6 @@
     public int[] decodeBandInt(String name, InputStream in,
             BHSDCodec codec, int count) throws IOException,
             Pack200Exception {
-        return decodeBandInt(name, in, codec, count, true);
-    }
-
-    /**
-     * Decode a band and return an array of <code>int</code> values
-     *
-     * @param name
-     *            the name of the band (primarily for logging/debugging
-     *            purposes)
-     * @param in
-     *            the InputStream to decode from
-     * @param defaultCodec
-     *            the default codec for this band
-     * @param count
-     *            the number of elements to read
-     * @return an array of decoded <code>int</code> values
-     * @throws IOException
-     *             if there is a problem reading from the underlying input
-     *             stream
-     * @throws Pack200Exception
-     *             if there is a problem decoding the value or that the value is
-     *             invalid
-     */
-    public int[] decodeBandInt(String name, InputStream in,
-            BHSDCodec codec, int count, boolean negativesAllowed) throws IOException,
-            Pack200Exception {
         int[] band;
         Codec codecUsed = codec;
         if (codec.getB() == 1 || count == 0) {
@@ -121,11 +98,34 @@
             // First element should not be discarded
             band = codec.decodeInts(count - 1, in, first);
         }
-        if(!negativesAllowed && codec != codecUsed) {
-            if(codecUsed instanceof BHSDCodec && ((BHSDCodec)codecUsed).isSigned()) {
-                for (int i = 0; i < band.length; i++) {
-                    while(band[i] < 0) {
-                        band[i] += ((BHSDCodec)codecUsed).cardinality();
+        if(codecUsed instanceof BHSDCodec && ((BHSDCodec)codecUsed).isDelta()) {
+            BHSDCodec bhsd = (BHSDCodec)codecUsed;
+            long cardinality = bhsd.cardinality();
+            for (int i = 0; i < band.length; i++) {
+                while (band[i] > bhsd.largest()) {
+                    band[i] -= cardinality;
+                }
+                while (band[i] < bhsd.smallest()) {
+                    band[i] += cardinality;
+                }
+            }
+        } else if (codecUsed instanceof PopulationCodec) {
+            PopulationCodec popCodec = (PopulationCodec) codecUsed;
+            long[] favoured = (long[]) popCodec.getFavoured().clone();
+            Arrays.sort(favoured);
+            for (int i = 0; i < band.length; i++) {
+                boolean favouredValue = Arrays.binarySearch(favoured,
+                        band[i]) > -1;
+                Codec theCodec = favouredValue ? popCodec
+                        .getFavouredCodec() : popCodec.getUnvafouredCodec();
+                if (theCodec instanceof BHSDCodec && ((BHSDCodec) theCodec).isDelta()) {
+                    BHSDCodec bhsd = (BHSDCodec)theCodec;
+                    long cardinality = bhsd.cardinality();
+                    while (band[i] > bhsd.largest()) {
+                        band[i] -= cardinality;
+                    }
+                    while (band[i] < bhsd.smallest()) {
+                        band[i] += cardinality;
                     }
                 }
             }
@@ -157,40 +157,12 @@
     public int[][] decodeBandInt(String name, InputStream in,
             BHSDCodec defaultCodec, int[] counts)
             throws IOException, Pack200Exception {
-        return decodeBandInt(name, in, defaultCodec, counts, true);
-    }
-
-    // TODO: Use this version for all bands that shouldn't have negatives.
-    /**
-     * Decode a band and return an array of <code>int[]</code> values
-     *
-     * @param name
-     *            the name of the band (primarily for logging/debugging
-     *            purposes)
-     * @param in
-     *            the InputStream to decode from
-     * @param defaultCodec
-     *            the default codec for this band
-     * @param counts
-     *            the numbers of elements to read for each int array within the
-     *            array to be returned
-     * @return an array of decoded <code>int[]</code> values
-     * @throws IOException
-     *             if there is a problem reading from the underlying input
-     *             stream
-     * @throws Pack200Exception
-     *             if there is a problem decoding the value or that the value is
-     *             invalid
-     */
-    public int[][] decodeBandInt(String name, InputStream in,
-            BHSDCodec defaultCodec, int[] counts, boolean negativesAllowed)
-            throws IOException, Pack200Exception {
         int[][] result = new int[counts.length][];
         int totalCount = 0;
         for (int i = 0; i < counts.length; i++) {
             totalCount += counts[i];
         }
-        int[] twoDResult = decodeBandInt(name, in, defaultCodec, totalCount, negativesAllowed);
+        int[] twoDResult = decodeBandInt(name, in, defaultCodec, totalCount);
         int index = 0;
         for (int i = 0; i < result.length; i++) {
             result[i] = new int[counts[i]];
@@ -227,6 +199,8 @@
         if (codec.getB() == 1 || count == 0) {
             return codec.decode(count, in);
         }
+        Codec codecUsed = codec;
+        long[] band;
         long[] getFirst = codec.decode(1, in);
         if (getFirst.length == 0) {
             return getFirst;
@@ -234,19 +208,53 @@
         long first = getFirst[0];
         if (codec.isSigned() && first >= -256 && first <= -1) {
             // Non-default codec should be used
-            Codec nonDefaultCodec = CodecEncoding.getCodec((int) (-1 - first),
+            codecUsed = CodecEncoding.getCodec((int) (-1 - first),
                     header.getBandHeadersInputStream(), codec);
-            return nonDefaultCodec.decode(count, in);
+            band = codecUsed.decode(count, in);
         } else if (!codec.isSigned() && first >= codec.getL()
                 && first <= codec.getL() + 255) {
             // Non-default codec should be used
-            Codec nonDefaultCodec = CodecEncoding.getCodec((int) first
+            codecUsed = CodecEncoding.getCodec((int) first
                     - codec.getL(), header.getBandHeadersInputStream(), codec);
-            return nonDefaultCodec.decode(count, in);
+            band = codecUsed.decode(count, in);
         } else {
             // First element should not be discarded
-            return codec.decode(count - 1, in, first);
+            band = codec.decode(count - 1, in, first);
+        }
+
+        if(codecUsed instanceof BHSDCodec && ((BHSDCodec)codecUsed).isDelta()) {
+            BHSDCodec bhsd = (BHSDCodec)codecUsed;
+            long cardinality = bhsd.cardinality();
+            for (int i = 0; i < band.length; i++) {
+                while (band[i] > bhsd.largest()) {
+                    band[i] -= cardinality;
+                }
+                while (band[i] < bhsd.smallest()) {
+                    band[i] += cardinality;
+                }
+            }
+        } else if (codecUsed instanceof PopulationCodec) {
+            PopulationCodec popCodec = (PopulationCodec) codecUsed;
+            long[] favoured = (long[]) popCodec.getFavoured().clone();
+            Arrays.sort(favoured);
+            for (int i = 0; i < band.length; i++) {
+                boolean favouredValue = Arrays.binarySearch(favoured,
+                        band[i]) > -1;
+                Codec theCodec = favouredValue ? popCodec
+                        .getFavouredCodec() : popCodec.getUnvafouredCodec();
+                if (theCodec instanceof BHSDCodec && ((BHSDCodec) theCodec).isDelta()) {
+                    BHSDCodec bhsd = (BHSDCodec)theCodec;
+                    long cardinality = bhsd.cardinality();
+                    while (band[i] > bhsd.largest()) {
+                        band[i] -= cardinality;
+                    }
+                    while (band[i] < bhsd.smallest()) {
+                        band[i] += cardinality;
+                    }
+                }
+            }
         }
+        return band;
     }
 
     public byte[] encodeBandLong(long[] data, BHSDCodec codec) throws IOException, Pack200Exception {
@@ -289,10 +297,10 @@
             result[i] = new long[counts[i]];
             sum += counts[i];
         }
-        long[] hi = null;
+        int[] hi = null;
         int[] lo;
         if(hiCodec != null) {
-            hi = decodeBandLong(name, in, hiCodec, sum);
+            hi = decodeBandInt(name, in, hiCodec, sum);
             lo = decodeBandInt(name, in, loCodec, sum);
         } else {
             lo = decodeBandInt(name, in, loCodec, sum);
@@ -302,16 +310,13 @@
         for (int i = 0; i < result.length; i++) {
             for (int j = 0; j < result[i].length; j++) {
                 if(hi != null) {
-                    result[i][j] = (hi[index] << 32) | lo[index];
+                    result[i][j] = ((long)hi[index] << 32) | (lo[index] & 4294967295L);
                 } else {
                     result[i][j] = lo[index];
                 }
                 index++;
             }
         }
-
-        // TODO Remove debugging code
-        debug("Parsed *" + name + " (" + result.length + ")");
         return result;
     }
 
@@ -327,18 +332,17 @@
      * @param in
      *            the input stream to read from
      * @param codec
-     *            the codec to use for decoding
+     *            the BHSDCodec to use for decoding
      * @param count
      *            the number of references to decode
      * @param reference
-     *            the array of values to use for the indexes; often
-     *            {@link #cpUTF8}
+     *            the array of values to use for the references
      *
      * @throws IOException
      *             if a problem occurs during reading from the underlying stream
      * @throws Pack200Exception
      *             if a problem occurs with an unexpected value or unsupported
-     *             codec
+     *             Codec
      */
     public String[] parseReferences(String name, InputStream in,
             BHSDCodec codec, int count, String[] reference) throws IOException,
@@ -360,18 +364,17 @@
      * @param in
      *            the input stream to read from
      * @param codec
-     *            the codec to use for decoding
-     * @param count
-     *            the number of references to decode
+     *            the BHSDCodec to use for decoding
+     * @param counts
+     *            the numbers of references to decode for each array entry
      * @param reference
-     *            the array of values to use for the indexes; often
-     *            {@link #cpUTF8}
+     *            the array of values to use for the references
      *
      * @throws IOException
      *             if a problem occurs during reading from the underlying stream
      * @throws Pack200Exception
      *             if a problem occurs with an unexpected value or unsupported
-     *             codec
+     *             Codec
      */
     public String[][] parseReferences(String name, InputStream in,
             BHSDCodec codec, int counts[], String[] reference)
@@ -388,7 +391,7 @@
         }
         // TODO Merge the decode and parsing of a multiple structure into one
         String[] result1 = new String[sum];
-        int[] indices = decodeBandInt(name, in, codec, sum, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, sum);
         for (int i1 = 0; i1 < sum; i1++) {
             int index = indices[i1];
             if (index < 0 || index >= reference.length)
@@ -408,89 +411,9 @@
         return result;
     }
 
-    private int[] decodeBandInt(String name, InputStream in, BHSDCodec codec, int count, int maxValue) throws IOException, Pack200Exception {
-        int[] band;
-        Codec codecUsed = codec;
-        if (codec.getB() == 1 || count == 0) {
-            band = codec.decodeInts(count, in);
-        } else {
-            int[] getFirst = codec.decodeInts(1, in);
-            if (getFirst.length == 0) {
-                return new int[0];
-            }
-            int first = getFirst[0];
-            if (codec.isSigned() && first >= -256 && first <= -1) {
-                // Non-default codec should be used
-                codecUsed = CodecEncoding.getCodec((-1 - first),
-                        header.getBandHeadersInputStream(), codec);
-                band = codecUsed.decodeInts(count, in);
-            } else if (!codec.isSigned() && first >= codec.getL()
-                    && first <= codec.getL() + 255) {
-                // Non-default codec should be used
-                codecUsed = CodecEncoding.getCodec(first
-                        - codec.getL(), header.getBandHeadersInputStream(), codec);
-                band = codecUsed.decodeInts(count, in);
-            } else {
-                // First element should not be discarded
-                band = codec.decodeInts(count - 1, in, first);
-            }
-        }
-
-
-        /*
-         * Note - this is not in the spec, but seems to be used as an
-         * optimization by the RI for bands where the minimum and maximum values
-         * are known (ie reference bands). It will not hurt any implementation
-         * that is following the spec because all the values decoded will be
-         * inside the range anyway.
-         */
-        if (codecUsed instanceof BHSDCodec) {
-            for (int i = 0; i < band.length; i++) {
-                while (band[i] < 0) {
-                    band[i] += ((BHSDCodec) codecUsed).cardinality();
-                }
-                while (band[i] > maxValue) {
-                    band[i] -= ((BHSDCodec) codecUsed).cardinality();
-                }
-            }
-        } else if (codecUsed instanceof PopulationCodec) {
-            PopulationCodec popCodec = (PopulationCodec)codecUsed;
-            long[] favoured = (long[]) popCodec.getFavoured().clone();
-            Arrays.sort(favoured);
-            for (int i = 0; i < band.length; i++) {
-                if(band[i] < 0 || band[i] > maxValue) {
-                    boolean favouredValue = Arrays.binarySearch(favoured, band[i]) > -1;
-                    Codec theCodec = favouredValue ? popCodec.getFavouredCodec(): popCodec.getUnvafouredCodec();
-                    if(theCodec instanceof BHSDCodec) {
-                        while (band[i] < 0) {
-                            band[i] +=  ((BHSDCodec) theCodec).cardinality();
-                        }
-                        while (band[i] > maxValue) {
-                            band[i] -= ((BHSDCodec) theCodec).cardinality();
-                        }
-                    }
-                }
-            }
-        }
-        return band;
-    }
-
-    /**
-     * This is a local debugging message to aid the developer in writing this
-     * class. It will be removed before going into production. If the property
-     * 'debug.pack200' is set, this will generate messages to stderr; otherwise,
-     * it will be silent.
-     *
-     * @param message
-     * @deprecated this should be removed from production code
-     */
-    protected void debug(String message) {
-        segment.debug(message);
-    }
-
     public CPInteger[] parseCPIntReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
         int[] reference = segment.getCpBands().getCpInt();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPInteger[] result = new CPInteger[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -504,7 +427,7 @@
 
     public CPDouble[] parseCPDoubleReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
         double[] reference = segment.getCpBands().getCpDouble();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPDouble[] result = new CPDouble[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -518,7 +441,7 @@
 
     public CPFloat[] parseCPFloatReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
         float[] reference = segment.getCpBands().getCpFloat();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPFloat[] result = new CPFloat[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -532,7 +455,7 @@
 
     public CPLong[] parseCPLongReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
         long[] reference = segment.getCpBands().getCpLong();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPLong[] result = new CPLong[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -546,7 +469,7 @@
 
     public CPUTF8[] parseCPUTF8References(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
         String[] reference = segment.getCpBands().getCpUTF8();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPUTF8[] result = new CPUTF8[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -568,7 +491,7 @@
             sum += counts[i];
         }
         CPUTF8[] result1 = new CPUTF8[sum];
-        int[] indices = decodeBandInt(name, in, codec, sum, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, sum);
         for (int i1 = 0; i1 < sum; i1++) {
             int index = indices[i1];
             if (index < 0 || index >= reference.length)
@@ -589,7 +512,7 @@
 
     public CPString[] parseCPStringReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
         String[] reference = segment.getCpBands().getCpString();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPString[] result = new CPString[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -605,7 +528,7 @@
         CpBands cpBands = segment.getCpBands();
         String[] reference = cpBands.getCpIMethodClass();
         String[] descriptors = cpBands.getCpIMethodDescriptor();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPInterfaceMethodRef[] result = new CPInterfaceMethodRef[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -624,7 +547,7 @@
         CpBands cpBands = segment.getCpBands();
         String[] reference = cpBands.getCpMethodClass();
         String[] descriptors = cpBands.getCpMethodDescriptor();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPMethodRef[] result = new CPMethodRef[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -642,7 +565,7 @@
         CpBands cpBands = segment.getCpBands();
         String[] reference = cpBands.getCpFieldClass();
         String[] descriptors = cpBands.getCpFieldDescriptor();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPFieldRef[] result = new CPFieldRef[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -659,7 +582,7 @@
     public CPNameAndType[] parseCPDescriptorReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
         CpBands cpBands = segment.getCpBands();
         String[] reference = cpBands.getCpDescriptor();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPNameAndType[] result = new CPNameAndType[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -673,7 +596,7 @@
 
     public CPUTF8[] parseCPSignatureReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
         String[] reference = segment.getCpBands().getCpSignature();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPUTF8[] result = new CPUTF8[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];
@@ -687,7 +610,7 @@
 
     public CPClass[] parseCPClassReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception {
         String[] reference = segment.getCpBands().getCpClass();
-        int[] indices = decodeBandInt(name, in, codec, count, reference.length - 1);
+        int[] indices = decodeBandInt(name, in, codec, count);
         CPClass[] result = new CPClass[indices.length];
         for (int i1 = 0; i1 < count; i1++) {
             int index = indices[i1];

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=646264&r1=646263&r2=646264&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 Wed Apr  9 04:01:14 2008
@@ -31,7 +31,7 @@
 import org.apache.harmony.pack200.bytecode.OperandManager;
 
 /**
- * Pack200 Bytecode bands
+ * Bytecode bands
  */
 public class BcBands extends BandSet {
 
@@ -66,7 +66,7 @@
     private int[][] bcEscByte;
 
     /**
-     * @param header
+     * @param segment
      */
     public BcBands(Segment segment) {
         super(segment);
@@ -262,7 +262,7 @@
                                     || nextInstruction == 169) {
                                 bcLocalCount ++;
                             } else {
-                                debug("Found unhandled " + ByteCode.getByteCode(nextInstruction));
+                            	segment.log(Segment.LOG_LEVEL_VERBOSE, "Found unhandled " + ByteCode.getByteCode(nextInstruction));
                             }
                             i++;
                             break;
@@ -277,13 +277,11 @@
                        case 254: // byte_escape
                            bcEscCount++;
                            break;
-                       default: // unhandled specifically at this stage
+                       default:
                            if(endsWithLoad(codePacked) || endsWithStore(codePacked)) {
                                bcLocalCount++;
                            } else if (startsWithIf(codePacked)) {
                                bcLabelCount++;
-                           } else {
-                               debug("Found unhandled " + codePacked + " " + ByteCode.getByteCode(codePacked));
                            }
                        }
                    }
@@ -291,7 +289,6 @@
             }
         }
         // other bytecode bands
-        debug("Parsed *bc_codes (" + bcParsed + ")");
         bcCaseCount = decodeBandInt("bc_case_count", in, Codec.UNSIGNED5, bcCaseCountCount);
         int bcCaseValueCount = 0;
         for (int i = 0; i < bcCaseCount.length; i++) {
@@ -377,7 +374,8 @@
                     int maxLocal = codeMaxNALocals[i];
                     if (!staticModifier.matches(methodFlag))
                         maxLocal++; // one for 'this' parameter
-                    maxLocal += SegmentUtils.countArgs(methodDescr[c][m]);
+                    // I believe this has to take wide arguments into account
+                    maxLocal += SegmentUtils.countInvokeInterfaceArgs(methodDescr[c][m]);
                     operandManager.setCurrentClass(segment.getClassBands()
                             .getClassThis()[c]);
                     operandManager.setSuperClass(segment.getClassBands()
@@ -386,7 +384,13 @@
                     if(handlerCount != null) {
                         for (int j = 0; j < handlerCount[i]; j++) {
                             String handlerClass = handlerClassTypes[i][j];
-                            CPClass cpHandlerClass = segment.getCpBands().cpClassValue(handlerClass);
+                            CPClass cpHandlerClass = null;
+                            if(handlerClass != null) {
+                                // The handlerClass will be null if the
+                                // catch is a finally (that is, the
+                                // exception table catch_type should be 0
+                                cpHandlerClass = segment.getCpBands().cpClassValue(handlerClass);
+                            }
                             ExceptionTableEntry entry = new ExceptionTableEntry(
                                     handlerStartPCs[i][j], handlerEndPCs[i][j],
                                     handlerCatchPCs[i][j], cpHandlerClass);



Mime
View raw message