harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r572907 [3/5] - in /harmony/enhanced/classlib/branches/java6: depends/files/ modules/awt/src/main/java/common/java/awt/ modules/awt/src/main/java/common/java/awt/geom/ modules/awt/src/main/java/common/org/apache/harmony/awt/gl/ modules/awt/...
Date Wed, 05 Sep 2007 09:14:06 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PrintStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PrintStream.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PrintStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PrintStream.java Wed Sep  5 02:14:01 2007
@@ -18,6 +18,7 @@
 package java.io;
 
 import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
 import java.security.AccessController;
 import java.util.Formatter;
 import java.util.IllegalFormatException;
@@ -118,7 +119,11 @@
             throw new NullPointerException();
         }
         this.autoflush = autoflush;
-        if (!Charset.isSupported(enc)) {
+        try {
+            if (!Charset.isSupported(enc)) {
+                throw new UnsupportedEncodingException(enc);
+            }
+        } catch (IllegalCharsetNameException e) {
             throw new UnsupportedEncodingException(enc);
         }
         encoding = enc;

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Integer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Integer.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Integer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Integer.java Wed Sep  5 02:14:01 2007
@@ -160,19 +160,17 @@
                 return valueOf(0);
             }
             if ((firstDigit = string.charAt(i)) == 'x' || firstDigit == 'X') {
-                if (i == length) {
+                if (++i == length) {
                     throw new NumberFormatException(string);
                 }
-                i++;
                 base = 16;
             } else {
                 base = 8;
             }
         } else if (firstDigit == '#') {
-            if (i == length) {
+            if (++i == length) {
                 throw new NumberFormatException(string);
             }
-            i++;
             base = 16;
         }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/InetAddress.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/InetAddress.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/InetAddress.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/InetAddress.java Wed Sep  5 02:14:01 2007
@@ -168,13 +168,10 @@
      */
     public static InetAddress[] getAllByName(String host)
             throws UnknownHostException {
-        if (host == null) {
+        if (host == null || 0 == host.length()) {
             return new InetAddress[] { preferIPv6Addresses() ? Inet6Address.LOOPBACK
                     : LOOPBACK };
         }
-        if (0 == host.length()) {
-            throw new UnknownHostException(Msg.getString("K0038")); //$NON-NLS-1$
-        }
 
         if (isHostName(host)) {
             SecurityManager security = System.getSecurityManager();
@@ -975,7 +972,7 @@
             for (int i = 0; i < 4; i++) {
                 copy_address[i] = ipAddress[i];
             }
-            return new Inet4Address(ipAddress);
+            return new Inet4Address(copy_address);
         }
 
         if (ipAddress != null && ipAddress.length == 16) {
@@ -992,6 +989,8 @@
             copy_address = ipAddress.clone();
             return new Inet6Address(copy_address, scope_id);
         }
+
+        // K0339=Invalid IP Address is neither 4 or 16 bytes
         throw new UnknownHostException(Msg.getString("K0339")); //$NON-NLS-1$
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URL.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URL.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URL.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URL.java Wed Sep  5 02:14:01 2007
@@ -259,8 +259,18 @@
                 // According to RFC 2396 scheme part should match
                 // the following expression:
                 // alpha *( alpha | digit | "+" | "-" | "." )
-                if (!protocol.matches("\\A\\p{Alpha}[\\p{Alnum}+-.]*\\z") || //$NON-NLS-1$
-                        protocol.indexOf('/') >= 0) {
+                char c = protocol.charAt(0);
+                boolean valid = ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
+                for (int i = 1; valid && (i < protocol.length()); i++) {
+                    c = protocol.charAt(i);
+                    valid = ('a' <= c && c <= 'z') ||
+                            ('A' <= c && c <= 'Z') ||
+                            ('0' <= c && c <= '9') ||
+                            (c == '+') ||
+                            (c == '-') ||
+                            (c == '.');
+                }
+                if (!valid) {
                     protocol = null;
                     index = -1;
                 } else {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLConnection.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLConnection.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLConnection.java Wed Sep  5 02:14:01 2007
@@ -722,26 +722,83 @@
      * @throws IOException
      *             If an IO error occurs
      */
+    @SuppressWarnings("nls")
     public static String guessContentTypeFromStream(InputStream is)
             throws IOException {
+
         if (!is.markSupported()) {
             return null;
         }
-        is.mark(4);
-        char[] chars = new char[4];
-        for (int i = 0; i < chars.length; i++) {
-            chars[i] = (char) is.read();
-        }
+        // Look ahead up to 64 bytes for the longest encoded header
+        is.mark(64);
+        byte[] bytes = new byte[64];
+        int length = is.read(bytes);
         is.reset();
-        if ((chars[0] == 'P') && (chars[1] == 'K')) {
-            return "application/zip"; //$NON-NLS-1$
+
+        // Check for Unicode BOM encoding indicators
+        String encoding = "ASCII";
+        int start = 0;
+        if (length > 1) {
+            if ((bytes[0] == (byte) 0xFF) && (bytes[1] == (byte) 0xFE)) {
+                encoding = "UTF-16LE";
+                start = 2;
+                length -= length & 1;
+            }
+            if ((bytes[0] == (byte) 0xFE) && (bytes[1] == (byte) 0xFF)) {
+                encoding = "UTF-16BE";
+                start = 2;
+                length -= length & 1;
+            }
+            if (length > 2) {
+                if ((bytes[0] == (byte) 0xEF) && (bytes[1] == (byte) 0xBB)
+                        && (bytes[2] == (byte) 0xBF)) {
+                    encoding = "UTF-8";
+                    start = 3;
+                }
+                if (length > 3) {
+                    if ((bytes[0] == (byte) 0x00) && (bytes[1] == (byte) 0x00)
+                            && (bytes[2] == (byte) 0xFE)
+                            && (bytes[3] == (byte) 0xFF)) {
+                        encoding = "UTF-32BE";
+                        start = 4;
+                        length -= length & 3;
+                    }
+                    if ((bytes[0] == (byte) 0xFF) && (bytes[1] == (byte) 0xFE)
+                            && (bytes[2] == (byte) 0x00)
+                            && (bytes[3] == (byte) 0x00)) {
+                        encoding = "UTF-32LE";
+                        start = 4;
+                        length -= length & 3;
+                    }
+                }
+            }
+        }
+
+        String header = new String(bytes, start, length - start, encoding);
+
+        // Check binary types
+        if (header.startsWith("PK")) {
+            return "application/zip";
+        }
+        if (header.startsWith("GI")) {
+            return "image/gif";
         }
-        if ((chars[0] == 'G') && (chars[1] == 'I')) {
-            return "image/gif"; //$NON-NLS-1$
+
+        // Check text types
+        String textHeader = header.trim().toUpperCase();
+        if (textHeader.startsWith("<!DOCTYPE HTML") ||
+                textHeader.startsWith("<HTML") ||
+                textHeader.startsWith("<HEAD") ||
+                textHeader.startsWith("<BODY") ||
+                textHeader.startsWith("<HEAD")) {
+            return "text/html";
         }
-        if (new String(chars).trim().startsWith("<")) { //$NON-NLS-1$
-            return "text/html"; //$NON-NLS-1$
+
+        if (textHeader.startsWith("<?XML")) {
+            return "application/xml";
         }
+
+        // Give up
         return null;
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HugeEnumSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HugeEnumSet.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HugeEnumSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HugeEnumSet.java Wed Sep  5 02:14:01 2007
@@ -83,6 +83,8 @@
             currentElementMask = unProcessedBits[bitsPosition]
                     & (-unProcessedBits[bitsPosition]);
             unProcessedBits[bitsPosition] -= currentElementMask;
+            int index = Long.numberOfTrailingZeros(currentElementMask)
+                    + bitsPosition * BIT_IN_LONG;
             if (0 == unProcessedBits[bitsPosition]) {
                 int oldBitsPosition = bitsPosition;
                 findNextNoneZeroPosition(bitsPosition + 1);
@@ -90,8 +92,7 @@
                     canProcess = false;
                 }
             }
-            return enums[Long.numberOfTrailingZeros(currentElementMask)
-                    + bitsPosition * BIT_IN_LONG];
+            return enums[index];
         }
 
         public void remove() {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java Wed Sep  5 02:14:01 2007
@@ -129,13 +129,23 @@
             return MimeTable.UNKNOWN;
         }
         if (isDir) {
-            return "text/html"; //$NON-NLS-1$
+            return "text/plain"; //$NON-NLS-1$
         }
         String result = guessContentTypeFromName(url.getFile());
-        if (result == null) {
-            return MimeTable.UNKNOWN;
+        if (result != null) {
+            return result;
         }
-        return result;
+
+        try {
+            result = guessContentTypeFromStream(is);
+        } catch (IOException e) {
+            // Ignore
+        }
+        if (result != null) {
+            return result;
+        }
+
+        return MimeTable.UNKNOWN;
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties Wed Sep  5 02:14:01 2007
@@ -320,3 +320,4 @@
 KA025=Method has not been implemented
 KA026=JAR entry {0} not found in {1}
 KA027=Inputstream of the JarURLConnection has been closed
+KA028=Cannot set protocol version when stream in use

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=572907&r1=572906&r2=572907&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 Wed Sep  5 02:14:01 2007
@@ -145,6 +145,56 @@
             exception = true;
         }
         assertTrue("Failed to throw exception for 9999999999", exception);
+
+        try {
+            Integer.decode("-");
+            fail("Expected exception for -");
+        } catch (NumberFormatException e) {
+            // Expected
+        }
+
+        try {
+            Integer.decode("0x");
+            fail("Expected exception for 0x");
+        } catch (NumberFormatException e) {
+            // Expected
+        }
+
+        try {
+            Integer.decode("#");
+            fail("Expected exception for #");
+        } catch (NumberFormatException e) {
+            // Expected
+        }
+
+        try {
+            Integer.decode("x123");
+            fail("Expected exception for x123");
+        } catch (NumberFormatException e) {
+            // Expected
+        }
+
+        try {
+            Integer.decode(null);
+            fail("Expected exception for null");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        try {
+            Integer.decode("");
+            fail("Expected exception for empty string");
+        } catch (NumberFormatException ex) {
+            // Expected
+        }
+
+        try {
+            Integer.decode(" ");
+            fail("Expected exception for single space");
+        } catch (NumberFormatException ex) {
+            // Expected
+        }
+
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.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/InetAddressTest.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java Wed Sep  5 02:14:01 2007
@@ -150,7 +150,7 @@
     /**
      * @tests java.net.InetAddress#getAddress()
      */
-    public void test_getAddress() {
+    public void test_getAddress() throws UnknownHostException {
         // Test for method byte [] java.net.InetAddress.getAddress()
         try {
             InetAddress ia = InetAddress
@@ -161,6 +161,12 @@
                 assertTrue("Incorrect address returned", caddr[i] == addr[i]);
         } catch (java.net.UnknownHostException e) {
         }
+        
+        byte[] origBytes = new byte[] { 0, 1, 2, 3 };
+        InetAddress address = InetAddress.getByAddress(origBytes);
+        origBytes[0] = -1;
+        byte[] newBytes = address.getAddress();
+        assertSame((byte) 0, newBytes[0]);
     }
 
     /**
@@ -202,6 +208,11 @@
         InetAddress[] ia = InetAddress.getAllByName(null);
         assertEquals("Assert 0: No loopback address", 1, ia.length);
         assertTrue("Assert 1: getAllByName(null) not loopback",
+                ia[0].isLoopbackAddress());
+        
+        ia = InetAddress.getAllByName("");
+        assertEquals("Assert 2: No loopback address", 1, ia.length);
+        assertTrue("Assert 3: getAllByName(\"\") not loopback",
                 ia[0].isLoopbackAddress());
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectOutputStreamTest.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectOutputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectOutputStreamTest.java Wed Sep  5 02:14:01 2007
@@ -30,6 +30,7 @@
 import java.io.ObjectOutput;
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamClass;
+import java.io.ObjectStreamConstants;
 import java.io.ObjectStreamException;
 import java.io.ObjectStreamField;
 import java.io.OutputStream;
@@ -763,6 +764,16 @@
         assertTrue(
                 "Cannot read/write PROTOCAL_VERSION_1 Externalizable objects: "
                         + t2.getValue(), t1.getValue().equals(t2.getValue()));
+
+        // Cannot set protocol version when stream in-flight
+        ObjectOutputStream out = new ObjectOutputStream(new ByteArrayOutputStream());
+        out.writeObject("hello world");
+        try {
+            out.useProtocolVersion(ObjectStreamConstants.PROTOCOL_VERSION_1);
+            fail("Expected IllegalStateException");
+        } catch (IllegalStateException e) {
+            // Expected
+        }
     }
 
 	/**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectStreamClassTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectStreamClassTest.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectStreamClassTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectStreamClassTest.java Wed Sep  5 02:14:01 2007
@@ -24,6 +24,7 @@
 import java.io.ObjectStreamClass;
 import java.io.ObjectStreamField;
 import java.io.Serializable;
+import java.lang.reflect.Proxy;
 
 public class ObjectStreamClassTest extends junit.framework.TestCase {
 
@@ -186,17 +187,26 @@
         assertEquals(0, osc.getFields().length);
     }
     
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
-	protected void setUp() {
-	}
-
-	/**
-	 * Tears down the fixture, for example, close a network connection. This
-	 * method is called after a test is executed.
-	 */
-	protected void tearDown() {
-	}
+    public void test_specialTypes() {
+        Class<?> proxyClass = Proxy.getProxyClass(this.getClass()
+                .getClassLoader(), new Class[] { Runnable.class });
+
+        ObjectStreamClass proxyStreamClass = ObjectStreamClass
+                .lookup(proxyClass);
+
+        assertEquals("Proxy classes should have zero serialVersionUID", 0,
+                proxyStreamClass.getSerialVersionUID());
+        ObjectStreamField[] proxyFields = proxyStreamClass.getFields();
+        assertEquals("Proxy classes should have no serialized fields", 0,
+                proxyFields.length);
+
+        ObjectStreamClass enumStreamClass = ObjectStreamClass
+                .lookup(Thread.State.class);
+
+        assertEquals("Enum classes should have zero serialVersionUID", 0,
+                enumStreamClass.getSerialVersionUID());
+        ObjectStreamField[] enumFields = enumStreamClass.getFields();
+        assertEquals("Enum classes should have no serialized fields", 0,
+                enumFields.length);
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PrintStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PrintStreamTest.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PrintStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PrintStreamTest.java Wed Sep  5 02:14:01 2007
@@ -112,6 +112,19 @@
     }
 
     /**
+     * @tests java.io.PrintStream#PrintStream(java.io.OutputStream, boolean, String)
+     */
+    public void test_ConstructorLjava_io_OutputStreamZLjava_lang_String() {
+        try {
+            new PrintStream(new ByteArrayOutputStream(), false,
+                    "%Illegal_name!");
+            fail("Expected UnsupportedEncodingException");
+        } catch (UnsupportedEncodingException e) {
+            // expected
+        }
+    }
+
+    /**
      * @tests java.io.PrintStream#checkError()
      */
     public void test_checkError() throws Exception {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java Wed Sep  5 02:14:01 2007
@@ -18,6 +18,7 @@
 package tests.api.java.net;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FilePermission;
@@ -159,6 +160,26 @@
 		}
 	}
 
+        static String getContentType(String fileName) throws IOException {
+            String resourceName = "org/apache/harmony/luni/tests/" + fileName;
+            URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
+            assertNotNull("Cannot find test resource " + resourceName, url);
+            return url.openConnection().getContentType();
+        }
+
+        /**
+         * @tests java.net.URLConnection#getContentType()
+         */
+        public void test_getContentType_regression() throws IOException {
+            // Regression for HARMONY-4699
+            assertEquals(getContentType("test.rtf"), "application/rtf");
+            assertEquals(getContentType("test.java"), "text/plain");
+            assertEquals(getContentType("test.doc"), "application/msword"); // RI would return "content/unknown"
+            assertEquals(getContentType("test.htx"), "text/html");
+            assertEquals(getContentType("test.xml"), "application/xml");
+            assertEquals(getContentType("."), "text/plain");
+        }
+
 	/**
 	 * @tests java.net.URLConnection#getDate()
 	 */
@@ -887,28 +908,76 @@
 		assertTrue("getUseCaches should have returned true", uc.getUseCaches());
 	}
 
-	/**
-	 * @tests java.net.URLConnection#guessContentTypeFromStream(java.io.InputStream)
-	 */
-	public void test_guessContentTypeFromStreamLjava_io_InputStream() throws IOException {
-        InputStream in = uc.getInputStream();
-        byte[] bytes = new byte[in.available()];
-
-        in.read(bytes, 0, bytes.length);
-        in.close();
-        // RI fails and it's a non-bug difference.
-        assertEquals("Should have returned text/html", "text/html",
-                URLConnection
-                        .guessContentTypeFromStream(new ByteArrayInputStream(
-                                bytes)));
+    private byte[] toBOMBytes(String text, String enc) throws IOException {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
-        try {
+        if (enc.equals("UTF-8")) bos.write(new byte[] {(byte)0xEF, (byte)0xBB, (byte)0xBF});
+        if (enc.equals("UTF-16BE")) bos.write(new byte[] {(byte)0xFE, (byte)0xFF});
+        if (enc.equals("UTF-16LE")) bos.write(new byte[] {(byte)0xFF, (byte)0xFE});
+        if (enc.equals("UTF-32BE")) bos.write(new byte[] {(byte)0x00, (byte)0x00, (byte)0xFE, (byte)0xFF});
+        if (enc.equals("UTF-32LE")) bos.write(new byte[] {(byte)0xFF, (byte)0xFE, (byte)0x00, (byte)0x00});
+
+        bos.write(text.getBytes(enc));
+        return bos.toByteArray();
+    }
+    
+    /**
+     * @tests java.net.URLConnection#guessContentTypeFromStream(java.io.InputStream)
+     */
+    public void test_guessContentTypeFromStreamLjava_io_InputStream() throws IOException {
+        String[] headers = new String[] {
+                "<html>",
+                "<head>",
+                " <head ",
+                "<body",
+                "<BODY ",
+                "<!DOCTYPE html",
+                "<?xml "
+        };
+        String[] expected = new String[] {
+                "text/html",
+                "text/html",
+                "text/html",
+                "text/html",
+                "text/html",
+                "text/html",
+                "application/xml"
+        };
+
+        String[] encodings = new String[] {"ASCII", "UTF-8", "UTF-16BE", "UTF-16LE", "UTF-32BE", "UTF-32LE"};
+        for (int i = 0; i < headers.length; i++) {
+            for (String enc : encodings) {
+                InputStream is = new ByteArrayInputStream(toBOMBytes(headers[i], enc));
+                String mime = URLConnection.guessContentTypeFromStream(is);
+                assertEquals("checking " + headers[i] + " with " + enc,
+                        expected[i], mime);
+            }
+        }
+
+        // Try simple case
+         try {
             URLConnection.guessContentTypeFromStream(null);
             fail("should throw NullPointerException");
         } catch (NullPointerException e){
             // expected
         }
+
+        // Test magic bytes
+        byte[][] bytes = new byte[][] {
+                { 'P', 'K' },
+                { 'G', 'I' }
+        };
+        expected = new String[] {
+                "application/zip",
+                "image/gif"
+        };
+
+        for (int i = 0; i < bytes.length; i++) {
+            InputStream is = new ByteArrayInputStream(bytes[i]);
+            assertEquals(expected[i], URLConnection.guessContentTypeFromStream(is));
+        }
     }
+
 
 	/**
 	 * @tests java.net.URLConnection#setAllowUserInteraction(boolean)

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/EnumSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/EnumSetTest.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/EnumSetTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/EnumSetTest.java Wed Sep  5 02:14:01 2007
@@ -1546,6 +1546,14 @@
         assertFalse(hugeSet.contains(HugeEnum.a));
         // RI's bug, EnumFoo.b should not exist at the moment.
         assertFalse("Should return false", set.contains(EnumFoo.b)); //$NON-NLS-1$
+        
+        // Regression for HARMONY-4728
+        hugeSet = EnumSet.allOf(HugeEnum.class);
+        hIterator = hugeSet.iterator();
+        for( int i = 0; i < 63; i++) {
+            hIterator.next();
+        }
+        assertSame(HugeEnum.ll, hIterator.next());
     }
     
     /**

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=572907&r1=572906&r2=572907&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 Sep  5 02:14:01 2007
@@ -20,10 +20,13 @@
 // NOTE: Do not extract strings as messages; this code is still a
 // work-in-progress
 // NOTE: Also, don't get rid of 'else' statements for the hell of it ...
-import org.apache.harmony.pack200.Segment.SegmentConstantPool;
 
-public class AttributeLayout {
+public class AttributeLayout implements IMatcher {
 	static class Key {
+		private final int context;
+
+		private final String name;
+
 		public Key(String name, int context) throws Pack200Exception {
 			if (name == null || name.length() == 0)
 				throw new Pack200Exception("Cannot have an unnamed layout");
@@ -36,20 +39,6 @@
 
 		}
 
-		private int context;
-
-		private String name;
-
-		
-		public int hashCode() {
-			final int PRIME = 31;
-			int result = 1;
-			result = PRIME * result + context;
-			result = PRIME * result + ((name == null) ? 0 : name.hashCode());
-			return result;
-		}
-
-		
 		public boolean equals(Object obj) {
 			if (this == obj)
 				return true;
@@ -68,120 +57,71 @@
 			return true;
 		}
 
+		public int hashCode() {
+			final int PRIME = 31;
+			int result = 1;
+			result = PRIME * result + context;
+			result = PRIME * result + ((name == null) ? 0 : name.hashCode());
+			return result;
+		}
+
 		public String toString() {
 			return contextNames[context] + ": " + name;
 		}
 
 	}
 
-	private String layout;
-
-	Key key;
-
-	private long mask;
-
-	public static final String ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS = "RuntimeInvisibleAnnotations";
-
-	public static final String ATTRIBUTE_CLASS_FILE_VERSION = "class-file version";
-
-	public static final String ATTRIBUTE_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = "RuntimeInvisibleParameterAnnotations";
-
-	public static final String ATTRIBUTE_ANNOTATION_DEFAULT = "AnnotationDefault";
-
-	public static final String ATTRIBUTE_CODE = "Code";
-
-	public static final String ATTRIBUTE_SOURCE_FILE = "SourceFile";
-
-	public static final String ATTRIBUTE_LOCAL_VARIABLE_TYPE_TABLE = "LocalVariableTypeTable";
-
-	public static final String ATTRIBUTE_LOCAL_VARIABLE_TABLE = "LocalVariableTable";
-
-	public static final String ATTRIBUTE_LINE_NUMBER_TABLE = "LineNumberTable";
-
-	public static final String ATTRIBUTE_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = "RuntimeVisibleParameterAnnotations";
-
-	public static final String ATTRIBUTE_INNER_CLASSES = "InnerClasses";
-
-	public static final String ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations";
-
-	public static final String ATTRIBUTE_DEPRECATED = "Deprecated";
-
-	public static final String ATTRIBUTE_CONSTANT_VALUE = "ConstantValue";
-
-	public static final String ATTRIBUTE_ENCLOSING_METHOD = "EnclosingMethod";
-
-	public static final String ATTRIBUTE_EXCEPTIONS = "Exceptions";
-
-	public static final String ATTRIBUTE_SIGNATURE = "Signature";
-
-	public static final int CONTEXT_CODE = 1 << 4;
-
+	public static final String ACC_ABSTRACT = "ACC_ABSTRACT"; //$NON-NLS-1$
+	public static final String ACC_ANNOTATION = "ACC_ANNOTATION"; //$NON-NLS-1$
+	public static final String ACC_ENUM = "ACC_ENUM"; //$NON-NLS-1$
+	public static final String ACC_FINAL = "ACC_FINAL"; //$NON-NLS-1$
+	public static final String ACC_INTERFACE = "ACC_INTERFACE"; //$NON-NLS-1$
+	public static final String ACC_NATIVE = "ACC_NATIVE"; //$NON-NLS-1$
+	public static final String ACC_PRIVATE = "ACC_PRIVATE"; //$NON-NLS-1$
+	public static final String ACC_PROTECTED = "ACC_PROTECTED"; //$NON-NLS-1$
+	public static final String ACC_PUBLIC = "ACC_PUBLIC"; //$NON-NLS-1$
+	public static final String ACC_STATIC = "ACC_STATIC"; //$NON-NLS-1$
+	public static final String ACC_STRICT = "ACC_STRICT"; //$NON-NLS-1$
+	public static final String ACC_SYNCHRONIZED = "ACC_SYNCHRONIZED"; //$NON-NLS-1$
+	public static final String ACC_SYNTHETIC = "ACC_SYNTHETIC"; //$NON-NLS-1$
+	public static final String ACC_TRANSIENT = "ACC_TRANSIENT"; //$NON-NLS-1$
+	public static final String ACC_VOLATILE = "ACC_VOLATILE"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_ANNOTATION_DEFAULT = "AnnotationDefault"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_CLASS_FILE_VERSION = "class-file version"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_CODE = "Code"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_CONSTANT_VALUE = "ConstantValue"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_DEPRECATED = "Deprecated"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_ENCLOSING_METHOD = "EnclosingMethod"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_EXCEPTIONS = "Exceptions"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_INNER_CLASSES = "InnerClasses"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_LINE_NUMBER_TABLE = "LineNumberTable"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_LOCAL_VARIABLE_TABLE = "LocalVariableTable"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_LOCAL_VARIABLE_TYPE_TABLE = "LocalVariableTypeTable"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS = "RuntimeInvisibleAnnotations"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = "RuntimeInvisibleParameterAnnotations"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = "RuntimeVisibleParameterAnnotations"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_SIGNATURE = "Signature"; //$NON-NLS-1$
+	public static final String ATTRIBUTE_SOURCE_FILE = "SourceFile"; //$NON-NLS-1$
 	public static final int CONTEXT_CLASS = 1 << 0;
-
+	public static final int CONTEXT_CODE = 1 << 4;
 	public static final int CONTEXT_FIELD = 1 << 2;
-
 	public static final int CONTEXT_METHOD = 1 << 3;
+	private static final String[] contextNames = { "Class", "Field", "Method", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			"Code", }; //$NON-NLS-1$
 
-	private static final String[] contextNames = { "Class", "Field", "Method",
-			"Code", };
-
-	public Codec getCodec() {
-		if (layout.indexOf("O") >= 0) {
-			return Codec.BRANCH5;
-		} else if (layout.indexOf("P") >= 0) {
-			return Codec.BCI5;
-		} else if (layout.indexOf("S") >= 0 && layout.indexOf("KS") < 0
-				&& layout.indexOf("RS") < 0) {
-			return Codec.SIGNED5;
-		} else if (layout.indexOf("B") >= 0) {
-			return Codec.BYTE1;
-		}
-		/*
-		 * TODO Add this as a test (and don't commit since this is copyright
-		 * text) && ) If the layout contains 'O', use BRANCH5. Otherwise, if the
-		 * layout contains 'P', use BCI5. Otherwise, if the layout contains 'S'
-		 * but not 'KS' or 'RS', use SIGNED5. Otherwise, if the layout contains
-		 * 'B', use BYTE1. For all other layouts use UNSIGNED5.
-		 */
-		else {
-			return Codec.UNSIGNED5;
-		}
-	}
-
-	public Object getValue(long value, String type, Segment segment)
-			throws Pack200Exception {
-		// TODO This really needs to be better tested, esp. the different types
-		// TODO This should have the ability to deal with RUN stuff too, and unions
-		if (layout.startsWith("KQ")) {
-			if (type.equals("Ljava/lang/String;")) {
-				Object value2 = getValue("KS", value, segment);
-				return value2;
-			} else {
-				return getValue("K" + type + layout.substring(2), value,
-						segment);
-			}
-		} else {
-			return getValue(layout, value, segment);
-		}
-	}
-
-	public Object getValue(long value, Segment segment) throws Pack200Exception {
-		return getValue(layout, value, segment);
-	}
-
-	private static Object getValue(String layout, long value, Segment segment)
+	private static Object getValue(String layout, long value, SegmentConstantPool pool)
 			throws Pack200Exception {
-		SegmentConstantPool pool = segment.getConstantPool();
-		if (layout.startsWith("R")) {
+		if (layout.startsWith("R")) { //$NON-NLS-1$
 			// references
 			if (layout.indexOf('N') != -1)
 				value--;
-			if (layout.startsWith("RU")) {
+			if (layout.startsWith("RU")) { //$NON-NLS-1$
 				return pool.getValue(SegmentConstantPool.UTF_8, value);
-			} else if (layout.startsWith("RS")) {
+			} else if (layout.startsWith("RS")) { //$NON-NLS-1$
 				return pool.getValue(SegmentConstantPool.SIGNATURE, value);
 			}
-		} else if (layout.startsWith("K")) {
+		} else if (layout.startsWith("K")) { //$NON-NLS-1$
 			char type = layout.charAt(1);
 			switch (type) {
 			case 'S': // String
@@ -192,14 +132,20 @@
 			case 'F': // Float
 				return pool.getValue(SegmentConstantPool.CP_FLOAT, value);
 			case 'J': // Long
-				return pool.getValue(SegmentConstantPool.CP_LONG,value);
+				return pool.getValue(SegmentConstantPool.CP_LONG, value);
 			case 'D': // Double
-				return pool.getValue(SegmentConstantPool.CP_DOUBLE,value);
+				return pool.getValue(SegmentConstantPool.CP_DOUBLE, value);
 			}
 		}
 		throw new Pack200Exception("Unknown layout encoding: " + layout);
 	}
 
+	Key key;
+
+	private final String layout;
+
+	private long mask;
+
 	public AttributeLayout(String name, int context, String layout, int index)
 			throws Pack200Exception {
 		super();
@@ -214,31 +160,6 @@
 		this.layout = layout;
 	}
 
-	public boolean isCode() {
-		return key.context == CONTEXT_CODE;
-	}
-
-	public boolean isClass() {
-		return key.context == CONTEXT_CLASS;
-	}
-
-	public boolean isMethod() {
-		return key.context == CONTEXT_METHOD;
-	}
-
-	public boolean isField() {
-		return key.context == CONTEXT_FIELD;
-	}
-
-	public int hashCode() {
-		return key.hashCode();
-	}
-
-	public boolean matches(long value) {
-		return (value & mask) != 0;
-	}
-
-	
 	public boolean equals(Object obj) {
 		if (this == obj)
 			return true;
@@ -260,12 +181,84 @@
 		return true;
 	}
 
-	public String toString() {
-		return key.toString();
+	public Codec getCodec() {
+		if (layout.indexOf("O") >= 0) { //$NON-NLS-1$
+			return Codec.BRANCH5;
+		} else if (layout.indexOf("P") >= 0) { //$NON-NLS-1$
+			return Codec.BCI5;
+		} else if (layout.indexOf("S") >= 0 && layout.indexOf("KS") < 0 //$NON-NLS-1$ //$NON-NLS-2$
+				&& layout.indexOf("RS") < 0) { //$NON-NLS-1$
+			return Codec.SIGNED5;
+		} else if (layout.indexOf("B") >= 0) { //$NON-NLS-1$
+			return Codec.BYTE1;
+		}
+		/*
+		 * TODO Add this as a test (and don't commit since this is copyright
+		 * text) && ) If the layout contains 'O', use BRANCH5. Otherwise, if the
+		 * layout contains 'P', use BCI5. Otherwise, if the layout contains 'S'
+		 * but not 'KS' or 'RS', use SIGNED5. Otherwise, if the layout contains
+		 * 'B', use BYTE1. For all other layouts use UNSIGNED5.
+		 */
+		else {
+			return Codec.UNSIGNED5;
+		}
 	}
 
 	public String getLayout() {
 		return layout;
+	}
+
+	public Object getValue(long value, SegmentConstantPool pool) throws Pack200Exception {
+		return getValue(layout, value, pool);
+	}
+
+	public Object getValue(long value, String type, SegmentConstantPool pool)
+			throws Pack200Exception {
+		// TODO This really needs to be better tested, esp. the different types
+		// TODO This should have the ability to deal with RUN stuff too, and
+		// unions
+		if (layout.startsWith("KQ")) { //$NON-NLS-1$
+			if (type.equals("Ljava/lang/String;")) { //$NON-NLS-1$
+				Object value2 = getValue("KS", value, pool); //$NON-NLS-1$
+				return value2;
+			} else {
+				return getValue("K" + type + layout.substring(2), value, //$NON-NLS-1$
+						pool);
+			}
+		} else {
+			return getValue(layout, value, pool);
+		}
+	}
+
+	public int hashCode() {
+		return key.hashCode();
+	}
+
+	public boolean isClass() {
+		return key.context == CONTEXT_CLASS;
+	}
+
+	public boolean isCode() {
+		return key.context == CONTEXT_CODE;
+	}
+
+	public boolean isField() {
+		return key.context == CONTEXT_FIELD;
+	}
+
+	public boolean isMethod() {
+		return key.context == CONTEXT_METHOD;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.harmony.pack200.IMatches#matches(long)
+	 */
+	public boolean matches(long value) {
+		return (value & mask) != 0;
+	}
+
+	public String toString() {
+		return key.toString();
 	}
 
 }

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=572907&r1=572906&r2=572907&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 Sep  5 02:14:01 2007
@@ -15,9 +15,11 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
+// NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
+// NOTE: Do not extract strings as messages; this code is still a
+// work-in-progress
+// NOTE: Also, don't get rid of 'else' statements for the hell of it ...
 import java.util.HashMap;
 import java.util.Map;
 
@@ -31,26 +33,122 @@
 	private static AttributeLayout[] getDefaultAttributeLayouts()
 			throws Pack200Exception {
 		return new AttributeLayout[] {
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_LINE_NUMBER_TABLE,
+				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.ATTRIBUTE_LOCAL_VARIABLE_TABLE,
+
+				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.ATTRIBUTE_LOCAL_VARIABLE_TYPE_TABLE,
+
+				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_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_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,
@@ -59,31 +157,41 @@
 						AttributeLayout.CONTEXT_FIELD, "", 20),
 				new AttributeLayout(AttributeLayout.ATTRIBUTE_DEPRECATED,
 						AttributeLayout.CONTEXT_METHOD, "", 20),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
+				new AttributeLayout(
+						AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
 						AttributeLayout.CONTEXT_CLASS, "*", 21),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
+				new AttributeLayout(
+						AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
 						AttributeLayout.CONTEXT_FIELD, "*", 21),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
+				new AttributeLayout(
+						AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS,
 						AttributeLayout.CONTEXT_METHOD, "*", 21),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
+				new AttributeLayout(
+						AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
 						AttributeLayout.CONTEXT_CLASS, "*", 22),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
+				new AttributeLayout(
+						AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
 						AttributeLayout.CONTEXT_FIELD, "*", 22),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS,
+				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,
+				new AttributeLayout(
+						AttributeLayout.ATTRIBUTE_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS,
 						AttributeLayout.CONTEXT_METHOD, "*", 23),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_CLASS_FILE_VERSION,
+				new AttributeLayout(
+						AttributeLayout.ATTRIBUTE_CLASS_FILE_VERSION,
 						AttributeLayout.CONTEXT_CLASS, "*", 24),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS,
+				new AttributeLayout(
+						AttributeLayout.ATTRIBUTE_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS,
 						AttributeLayout.CONTEXT_METHOD, "*", 24),
-				new AttributeLayout(AttributeLayout.ATTRIBUTE_ANNOTATION_DEFAULT,
+				new AttributeLayout(
+						AttributeLayout.ATTRIBUTE_ANNOTATION_DEFAULT,
 						AttributeLayout.CONTEXT_METHOD, "*", 25) };
 	}
 
-	private Map layouts;
+	private final Map layouts;
 
 	public AttributeLayoutMap() throws Pack200Exception {
 		this.layouts = new HashMap();

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java Wed Sep  5 02:14:01 2007
@@ -227,4 +227,32 @@
 		}
 		return result;
 	}
+    
+    /**
+     * Decodes a sequence of <code>n</code> values from <code>in</code>.
+     * 
+     * @param n
+     *            the number of values to decode
+     * @param in
+     *            the input stream to read from
+     * @param firstValue
+     *            the first value in the band if it has already been read
+     * @return an array of <code>long</code> values corresponding to values
+     *         decoded, with firstValue as the first value in the array.
+     * @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 long[] decode(int n, InputStream in, long firstValue) throws IOException,
+            Pack200Exception {
+        long result[] = new long[n + 1];
+        long last = 0;
+        for(int i=1;i<n+1;i++) {
+            result[i] = last = decode(in,last);
+        }
+        return result;
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IMatcher.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IMatcher.java?rev=572907&r1=572906&r2=572907&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IMatcher.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IMatcher.java Wed Sep  5 02:14:01 2007
@@ -1,7 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.harmony.pack200;
 
 public interface IMatcher {
 
 	public abstract boolean matches(long value);
 
-}
\ No newline at end of file
+}



Mime
View raw message