You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2010/06/23 14:58:31 UTC

svn commit: r957178 [3/3] - in /harmony/enhanced/java/branches/mrh: ./ classlib/ classlib/depends/build/ classlib/depends/build/platform/ classlib/modules/beans/src/main/java/java/beans/ classlib/modules/beans/src/main/java/org/apache/harmony/beans/ cl...

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java Wed Jun 23 12:58:28 2010
@@ -89,8 +89,8 @@ class ProxyMethod {
                 throw new IllegalArgumentException(Messages.getString("luni.19",
                         method.getName()));
             }
-        }        
-        
+        }
+
         if (commonExceptions.length != 0) {
             Class[] otherExceptions = otherMethod.getExceptionTypes();
             if (otherExceptions.length == 0) {
@@ -109,7 +109,11 @@ class ProxyMethod {
                         }
                         if (cException.isAssignableFrom(oException)) {
                             // oException is a subclass, keep it instead
-                            commonExceptions[c] = cException = oException;
+                            if(!containsClass(commonExceptions, oException)){
+                                //if exceptions in throw list have Parent-Child relationship just ignore it
+                                //otherwise, keep the subclass
+                                commonExceptions[c] = cException = oException;
+                            }
                             continue nextException;
                         }
                     }
@@ -130,7 +134,16 @@ class ProxyMethod {
         }
         return true;
     }
-    
+
+    private boolean containsClass(Class<?>[] classArray, Class<?> clazz) {
+        for (Class<?> c : classArray) {
+            if (c.equals(clazz)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     Class getDeclaringClass() {
     	return declaringClass;
     }

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/shared/OSFileSystem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/shared/OSFileSystem.c?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/shared/OSFileSystem.c (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/shared/OSFileSystem.c Wed Jun 23 12:58:28 2010
@@ -164,7 +164,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_
       return -1;
     }
 
-  return (jlong) hyfile_seek ((IDATA) fd, (IDATA) offset, hywhence);
+  return (jlong) hyfile_seek ((IDATA) fd, (I_64) offset, hywhence);
 }
 
 /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java Wed Jun 23 12:58:28 2010
@@ -1,537 +1,538 @@
-/*
- *  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.luni.tests.java.io;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CodingErrorAction;
-import java.nio.charset.MalformedInputException;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-public class InputStreamReaderTest extends TestCase {
-
-    static class LimitedByteArrayInputStream extends ByteArrayInputStream {
-
-        // A ByteArrayInputStream that only returns a single byte per read
-        byte[] bytes;
-
-        int count;
-
-        public LimitedByteArrayInputStream(int type) {
-            super(new byte[0]);
-            switch (type) {
-            case 0:
-                bytes = new byte[] { 0x61, 0x72 };
-                break;
-            case 1:
-                bytes = new byte[] { (byte) 0xff, (byte) 0xfe, 0x61, 0x72 };
-                break;
-            case 2:
-                bytes = new byte[] { '\u001b', '$', 'B', '6', 'e', 'B', 'h',
-                        '\u001b', '(', 'B' };
-                break;
-            }
-            count = bytes.length;
-        }
-
-        @Override
-        public int available() {
-            return count;
-        }
-
-        @Override
-        public int read() {
-            if (count == 0) {
-                return -1;
-            }
-            count--;
-            return bytes[bytes.length - count];
-        }
-
-        @Override
-        public int read(byte[] buffer, int offset, int length) {
-            if (count == 0) {
-                return -1;
-            }
-            if (length == 0) {
-                return 0;
-            }
-            buffer[offset] = bytes[bytes.length - count];
-            count--;
-            return 1;
-        }
-    }
-
-    public String fileString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\n";
-
-    private InputStream fis;
-
-    private InputStream in;
-
-    private InputStreamReader is;
-
-    private InputStreamReader reader;
-
-    private final String source = "This is a test message with Unicode character. \u4e2d\u56fd is China's name in Chinese";
-
-    /*
-     * @see TestCase#setUp()
-     */
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        in = new ByteArrayInputStream(source.getBytes("UTF-8"));
-        reader = new InputStreamReader(in, "UTF-8");
-
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        OutputStreamWriter osw = new OutputStreamWriter(bos);
-        char[] buf = new char[fileString.length()];
-        fileString.getChars(0, fileString.length(), buf, 0);
-        osw.write(buf);
-        osw.close();
-        fis = new ByteArrayInputStream(bos.toByteArray());
-        is = new InputStreamReader(fis);
-    }
-
-    /*
-     * @see TestCase#tearDown()
-     */
-    @Override
-    protected void tearDown() throws Exception {
-        try {
-            in.close();
-            is.close();
-            fis.close();
-        } catch (IOException e) {
-            // Ignored
-        }
-
-        super.tearDown();
-    }
-
-    /**
-     * @tests java.io.InputStreamReader#close()
-     */
-    public void test_close() throws IOException {
-        is.close();
-        try {
-            is.read();
-            fail("Should throw IOException");
-        } catch (IOException e) {
-            // Expected
-        }
-
-        reader.close();
-        try {
-            reader.ready();
-            fail("Should throw IOException");
-        } catch (IOException e) {
-            // Expected
-        }
-
-        // Should be a no-op
-        reader.close();
-
-        // Tests after reader closed
-        in = new BufferedInputStream(
-                this
-                        .getClass()
-                        .getClassLoader()
-                        .getResourceAsStream(
-                                "org/apache/harmony/luni/tests/java/io/testfile-utf8.txt"));
-        reader = new InputStreamReader(in, "utf-8");
-        in.close();
-        try {
-            int count = reader.read(new char[1]);
-            fail("count:" + count);
-        } catch (IOException e) {
-            // Expected
-        }
-        try {
-            reader.read();
-            fail();
-        } catch (IOException e) {
-            // Expected
-        }
-
-        assertFalse(reader.ready());
-        Charset cs = Charset.forName("utf-8");
-        assertEquals(cs, Charset.forName(reader.getEncoding()));
-    }
-
-    /**
-     * @tests java.io.InputStreamReader#InputStreamReader(java.io.InputStream)
-     */
-    public void test_ConstructorLjava_io_InputStream() throws IOException {
-        try {
-            reader = new InputStreamReader(null);
-            fail();
-        } catch (NullPointerException e) {
-            // Expected
-        }
-        InputStreamReader reader2 = new InputStreamReader(in);
-        reader2.close();
-    }
-
-    /**
-     * @tests java.io.InputStreamReader#InputStreamReader(java.io.InputStream,
-     *        java.lang.String)
-     */
-    public void test_ConstructorLjava_io_InputStreamLjava_lang_String()
-            throws IOException {
-        is = new InputStreamReader(fis, "8859_1");
-
-        try {
-            is = new InputStreamReader(fis, "Bogus");
-            fail("Failed to throw Unsupported Encoding exception");
-        } catch (UnsupportedEncodingException e) {
-            // Expected
-        }
-
-        try {
-            reader = new InputStreamReader(null, "utf-8");
-            fail();
-        } catch (NullPointerException e) {
-            // Expected
-        }
-        try {
-            reader = new InputStreamReader(in, (String) null);
-            fail();
-        } catch (NullPointerException e) {
-            // Expected
-        }
-        try {
-            reader = new InputStreamReader(in, "");
-            fail();
-        } catch (UnsupportedEncodingException e) {
-            // Expected
-        }
-        try {
-            reader = new InputStreamReader(in, "badname");
-            fail();
-        } catch (UnsupportedEncodingException e) {
-            // Expected
-        }
-        InputStreamReader reader2 = new InputStreamReader(in, "utf-8");
-        assertEquals(Charset.forName(reader2.getEncoding()), Charset
-                .forName("utf-8"));
-        reader2.close();
-        reader2 = new InputStreamReader(in, "utf8");
-        assertEquals(Charset.forName(reader2.getEncoding()), Charset
-                .forName("utf-8"));
-        reader2.close();
-    }
-
-    /**
-     * @tests java.io.InputStreamReader(java.io.InputStream,
-     *        java.nio.charset.Charset)
-     */
-    public void test_ConstructorLjava_io_InputStreamLjava_nio_charset_Charset()
-            throws IOException {
-        Charset cs = Charset.forName("utf-8");
-        try {
-            reader = new InputStreamReader(null, cs);
-            fail();
-        } catch (NullPointerException e) {
-            // Expected
-        }
-        try {
-            reader = new InputStreamReader(in, (Charset) null);
-            fail();
-        } catch (NullPointerException e) {
-            // Expected
-        }
-        InputStreamReader reader2 = new InputStreamReader(in, cs);
-        assertEquals(Charset.forName(reader2.getEncoding()), cs);
-        reader2.close();
-    }
-
-    /**
-     * @tests java.io.InputStreamReader(java.io.InputStream,
-     *        java.nio.charset.CharsetDecoder)
-     */
-    public void test_ConstructorLjava_io_InputStreamLjava_nio_charset_CharsetDecoder()
-            throws IOException {
-        CharsetDecoder decoder = Charset.forName("utf-8").newDecoder();
-        try {
-            reader = new InputStreamReader(null, decoder);
-            fail();
-        } catch (NullPointerException e) {
-            // Expected
-        }
-        try {
-            reader = new InputStreamReader(in, (CharsetDecoder) null);
-            fail();
-        } catch (NullPointerException e) {
-            // Expected
-        }
-        InputStreamReader reader2 = new InputStreamReader(in, decoder);
-        assertEquals(Charset.forName(reader2.getEncoding()), decoder.charset());
-        reader2.close();
-    }
-
-    /**
-     * @tests java.io.InputStreamReader#getEncoding()
-     */
-    public void test_getEncoding() throws IOException {
-        InputStreamReader isr = new InputStreamReader(fis, "8859_1");
-        assertEquals("Returned incorrect encoding when setting 8859_1",
-                "ISO8859_1", isr.getEncoding());
-
-        isr = new InputStreamReader(fis, "ISO-8859-1");
-        assertEquals("Returned incorrect encoding when setting ISO-8859-1",
-                "ISO8859_1", isr.getEncoding());
-
-        byte b[] = new byte[5];
-        isr = new InputStreamReader(new ByteArrayInputStream(b), "UTF-16BE");
-        isr.close();
-        assertNull(isr.getEncoding());
-
-        try {
-            isr = new InputStreamReader(System.in, "UTF-16BE");
-        } catch (UnsupportedEncodingException e) {
-            // Ignored
-        }
-        assertEquals("UnicodeBigUnmarked", isr.getEncoding());
-    }
-
-    /**
-     * @tests java.io.InputStreamReader#read()
-     */
-    public void test_read() throws IOException {
-        assertEquals('T', (char) reader.read());
-        assertEquals('h', (char) reader.read());
-        assertEquals('i', (char) reader.read());
-        assertEquals('s', (char) reader.read());
-        assertEquals(' ', (char) reader.read());
-        reader.read(new char[source.length() - 5], 0, source.length() - 5);
-        assertEquals(-1, reader.read());
-
-        int c = is.read();
-        assertTrue("returned incorrect char", (char) c == fileString.charAt(0));
-        InputStreamReader reader = new InputStreamReader(
-                new ByteArrayInputStream(new byte[] { (byte) 0xe8, (byte) 0x9d,
-                        (byte) 0xa5 }), "UTF8");
-        assertTrue("wrong double byte char", reader.read() == '\u8765');
-
-        // Regression for HARMONY-166
-        InputStream in;
-
-        in = new LimitedByteArrayInputStream(0);
-        reader = new InputStreamReader(in, "UTF-16BE");
-        assertEquals("Incorrect byte UTF-16BE", '\u6172', reader.read());
-
-        in = new LimitedByteArrayInputStream(0);
-        reader = new InputStreamReader(in, "UTF-16LE");
-        assertEquals("Incorrect byte UTF-16BE", '\u7261', reader.read());
-
-        in = new LimitedByteArrayInputStream(1);
-        reader = new InputStreamReader(in, "UTF-16");
-        assertEquals("Incorrect byte UTF-16BE", '\u7261', reader.read());
-
-        /*
-         * Temporarily commented out due to lack of ISO2022 support in ICU4J 3.8
-         * in = new LimitedByteArrayInputStream(2); reader = new
-         * InputStreamReader(in, "ISO2022JP"); assertEquals("Incorrect byte
-         * ISO2022JP 1", '\u4e5d', reader.read()); assertEquals("Incorrect byte
-         * ISO2022JP 2", '\u7b2c', reader.read());
-         */
-    }
-
-    /*
-     * Class under test for int read() Regression for Harmony-411
-     */
-    public void test_read_1() throws IOException {
-        // if the decoder is constructed by InputStreamReader itself, the
-        // decoder's default error action is REPLACE
-        InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(
-                new byte[] { -32, -96 }), "UTF-8");
-        assertEquals("read() return incorrect value", 65533, isr.read());
-
-        InputStreamReader isr2 = new InputStreamReader(
-                new ByteArrayInputStream(new byte[] { -32, -96 }), Charset
-                        .forName("UTF-8"));
-        assertEquals("read() return incorrect value", 65533, isr2.read());
-
-        // if the decoder is passed in, keep its status intact
-        CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
-        decoder.onMalformedInput(CodingErrorAction.REPORT);
-        InputStreamReader isr3 = new InputStreamReader(
-                new ByteArrayInputStream(new byte[] { -32, -96 }), decoder);
-        try {
-            isr3.read();
-            fail("Should throw MalformedInputException");
-        } catch (MalformedInputException e) {
-            // expected
-        }
-
-        CharsetDecoder decoder2 = Charset.forName("UTF-8").newDecoder();
-        decoder2.onMalformedInput(CodingErrorAction.IGNORE);
-        InputStreamReader isr4 = new InputStreamReader(
-                new ByteArrayInputStream(new byte[] { -32, -96 }), decoder2);
-        assertEquals("read() return incorrect value", -1, isr4.read());
-
-        CharsetDecoder decoder3 = Charset.forName("UTF-8").newDecoder();
-        decoder3.onMalformedInput(CodingErrorAction.REPLACE);
-        InputStreamReader isr5 = new InputStreamReader(
-                new ByteArrayInputStream(new byte[] { -32, -96 }), decoder3);
-        assertEquals("read() return incorrect value", 65533, isr5.read());
-    }
-
-    public void test_read_specialCharset() throws IOException {
-        reader.close();
-        in = this.getClass().getClassLoader().getResourceAsStream(
-                "org/apache/harmony/luni/tests/java/io/testfile-utf8.txt");
-        reader = new InputStreamReader(in, "utf-8");
-        int c;
-        StringBuffer sb = new StringBuffer();
-        while ((c = reader.read()) != -1) {
-            sb.append((char) c);
-        }
-        // delete BOM
-        assertEquals(source, sb.deleteCharAt(0).toString());
-
-        sb.setLength(0);
-        reader.close();
-        in = this.getClass().getClassLoader().getResourceAsStream(
-                "org/apache/harmony/luni/tests/java/io/testfile.txt");
-        try {
-            reader = new InputStreamReader(in, "gb18030");
-        } catch (UnsupportedEncodingException e) {
-            System.out
-                    .println("GB18030 is not supported, abort test InputStreamReaderTest.testSpecialCharsetReading().");
-        }
-        while ((c = reader.read()) != -1) {
-            sb.append((char) c);
-        }
-        assertEquals(source, sb.toString());
-    }
-
-    /**
-     * @tests java.io.InputStreamReader#read(char[], int, int)
-     */
-    public void test_read$CII() throws IOException {
-        char[] rbuf = new char[100];
-        char[] sbuf = new char[100];
-        fileString.getChars(0, 100, sbuf, 0);
-        is.read(rbuf, 0, 100);
-        for (int i = 0; i < rbuf.length; i++) {
-            assertTrue("returned incorrect chars", rbuf[i] == sbuf[i]);
-        }
-
-        // Test successive reads
-        byte[] data = new byte[8192 * 2];
-        Arrays.fill(data, (byte) 116); // 116 = ISO-8859-1 value for 't'
-        ByteArrayInputStream bis = new ByteArrayInputStream(data);
-        InputStreamReader isr = new InputStreamReader(bis, "ISO-8859-1");
-
-        // One less than the InputStreamReader.BUFFER_SIZE
-        char[] buf = new char[8191];
-        int bytesRead = isr.read(buf, 0, buf.length);
-        assertFalse(-1 == bytesRead);
-        bytesRead = isr.read(buf, 0, buf.length);
-        assertFalse(-1 == bytesRead);
-
-        bis = new ByteArrayInputStream(source.getBytes("UTF-8"));
-        isr = new InputStreamReader(in, "UTF-8");
-        char[] chars = new char[source.length()];
-        assertEquals(source.length() - 3, isr.read(chars, 0, chars.length - 3));
-        assertEquals(3, isr.read(chars, 0, 10));
-    }
-
-    /*
-     * Class under test for int read(char[], int, int)
-     */
-    public void test_read$CII_1() throws IOException {
-        try {
-            // Throws IndexOutOfBoundsException before NullPointerException
-            reader.read(null, -1, 1);
-            fail("Should throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-
-        try {
-            // Throws NullPointerException before IndexOutOfBoundsException
-            reader.read(null, 0, -1);
-            fail("Should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
-        }
-
-        try {
-            reader.read(null, 0, 1);
-            fail();
-        } catch (NullPointerException e) {
-            // Expected
-        }
-        try {
-            reader.read(new char[3], -1, 1);
-            fail();
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        }
-        try {
-            reader.read(new char[3], 0, -1);
-            fail();
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        }
-        try {
-            reader.read(new char[3], 1, 3);
-            fail();
-        } catch (IndexOutOfBoundsException e) {
-            // Expected
-        }
-        assertEquals(0, reader.read(new char[3], 3, 0));
-        char[] chars = new char[source.length()];
-        assertEquals(0, reader.read(chars, 0, 0));
-        assertEquals(0, chars[0]);
-        assertEquals(3, reader.read(chars, 0, 3));
-        assertEquals(5, reader.read(chars, 3, 5));
-        assertEquals(source.length() - 8, reader.read(chars, 8,
-                chars.length - 8));
-        assertTrue(Arrays.equals(chars, source.toCharArray()));
-        assertEquals(-1, reader.read(chars, 0, chars.length));
-        assertTrue(Arrays.equals(chars, source.toCharArray()));
-    }
-
-    /**
-     * @tests java.io.InputStreamReader#ready()
-     */
-    public void test_ready() throws IOException {
-        assertTrue("Ready test failed", is.ready());
-        is.read();
-        assertTrue("More chars, but not ready", is.ready());
-
-        assertTrue(reader.ready());
-        reader.read(new char[source.length()]);
-        assertFalse(reader.ready());
-    }
-}
+/*
+ *  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.luni.tests.java.io;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CodingErrorAction;
+import java.nio.charset.MalformedInputException;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+public class InputStreamReaderTest extends TestCase {
+
+    static class LimitedByteArrayInputStream extends ByteArrayInputStream {
+
+        // A ByteArrayInputStream that only returns a single byte per read
+        byte[] bytes;
+
+        int count;
+
+        public LimitedByteArrayInputStream(int type) {
+            super(new byte[0]);
+            switch (type) {
+            case 0:
+                bytes = new byte[] { 0x61, 0x72 };
+                break;
+            case 1:
+                bytes = new byte[] { (byte) 0xff, (byte) 0xfe, 0x61, 0x72 };
+                break;
+            case 2:
+                bytes = new byte[] { '\u001b', '$', 'B', '6', 'e', 'B', 'h',
+                        '\u001b', '(', 'B' };
+                break;
+            }
+            count = bytes.length;
+        }
+
+        @Override
+        public int available() {
+            return count;
+        }
+
+        @Override
+        public int read() {
+            if (count == 0) {
+                return -1;
+            }
+            count--;
+            return bytes[bytes.length - count];
+        }
+
+        @Override
+        public int read(byte[] buffer, int offset, int length) {
+            if (count == 0) {
+                return -1;
+            }
+            if (length == 0) {
+                return 0;
+            }
+            buffer[offset] = bytes[bytes.length - count];
+            count--;
+            return 1;
+        }
+    }
+
+    public String fileString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\n";
+
+    private InputStream fis;
+
+    private InputStream in;
+
+    private InputStreamReader is;
+
+    private InputStreamReader reader;
+
+    private final String source = "This is a test message with Unicode character. \u4e2d\u56fd is China's name in Chinese";
+
+    /*
+     * @see TestCase#setUp()
+     */
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        in = new ByteArrayInputStream(source.getBytes("UTF-8"));
+        reader = new InputStreamReader(in, "UTF-8");
+
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        OutputStreamWriter osw = new OutputStreamWriter(bos);
+        char[] buf = new char[fileString.length()];
+        fileString.getChars(0, fileString.length(), buf, 0);
+        osw.write(buf);
+        osw.close();
+        fis = new ByteArrayInputStream(bos.toByteArray());
+        is = new InputStreamReader(fis);
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    @Override
+    protected void tearDown() throws Exception {
+        try {
+            in.close();
+            is.close();
+            fis.close();
+        } catch (IOException e) {
+            // Ignored
+        }
+
+        super.tearDown();
+    }
+
+    /**
+     * @tests java.io.InputStreamReader#close()
+     */
+    public void test_close() throws IOException {
+        is.close();
+        try {
+            is.read();
+            fail("Should throw IOException");
+        } catch (IOException e) {
+            // Expected
+        }
+
+        reader.close();
+        try {
+            reader.ready();
+            fail("Should throw IOException");
+        } catch (IOException e) {
+            // Expected
+        }
+
+        // Should be a no-op
+        reader.close();
+
+        // Tests after reader closed
+        in = new BufferedInputStream(
+                this
+                        .getClass()
+                        .getClassLoader()
+                        .getResourceAsStream(
+                                "org/apache/harmony/luni/tests/java/io/testfile-utf8.txt"));
+        reader = new InputStreamReader(in, "utf-8");
+        in.close();
+        try {
+            int count = reader.read(new char[1]);
+            fail("count:" + count);
+        } catch (IOException e) {
+            // Expected
+        }
+        try {
+            reader.read();
+            fail();
+        } catch (IOException e) {
+            // Expected
+        }
+
+        assertFalse(reader.ready());
+        Charset cs = Charset.forName("utf-8");
+        assertEquals(cs, Charset.forName(reader.getEncoding()));
+    }
+
+    /**
+     * @tests java.io.InputStreamReader#InputStreamReader(java.io.InputStream)
+     */
+    public void test_ConstructorLjava_io_InputStream() throws IOException {
+        try {
+            reader = new InputStreamReader(null);
+            fail();
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        InputStreamReader reader2 = new InputStreamReader(in);
+        reader2.close();
+    }
+
+    /**
+     * @tests java.io.InputStreamReader#InputStreamReader(java.io.InputStream,
+     *        java.lang.String)
+     */
+    public void test_ConstructorLjava_io_InputStreamLjava_lang_String()
+            throws IOException {
+        is = new InputStreamReader(fis, "8859_1");
+
+        try {
+            is = new InputStreamReader(fis, "Bogus");
+            fail("Failed to throw Unsupported Encoding exception");
+        } catch (UnsupportedEncodingException e) {
+            assertNotNull(e.getMessage());
+        }
+
+        try {
+            reader = new InputStreamReader(null, "utf-8");
+            fail();
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            reader = new InputStreamReader(in, (String) null);
+            fail();
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            reader = new InputStreamReader(in, "");
+            fail();
+        } catch (UnsupportedEncodingException e) {
+            // Expected
+        }
+        try {
+            reader = new InputStreamReader(in, "badname");
+            fail();
+        } catch (UnsupportedEncodingException e) {
+            // Expected
+        }
+        InputStreamReader reader2 = new InputStreamReader(in, "utf-8");
+        assertEquals(Charset.forName(reader2.getEncoding()), Charset
+                .forName("utf-8"));
+        reader2.close();
+        reader2 = new InputStreamReader(in, "utf8");
+        assertEquals(Charset.forName(reader2.getEncoding()), Charset
+                .forName("utf-8"));
+        reader2.close();
+    }
+
+    /**
+     * @tests java.io.InputStreamReader(java.io.InputStream,
+     *        java.nio.charset.Charset)
+     */
+    public void test_ConstructorLjava_io_InputStreamLjava_nio_charset_Charset()
+            throws IOException {
+        Charset cs = Charset.forName("utf-8");
+        try {
+            reader = new InputStreamReader(null, cs);
+            fail();
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            reader = new InputStreamReader(in, (Charset) null);
+            fail();
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        InputStreamReader reader2 = new InputStreamReader(in, cs);
+        assertEquals(Charset.forName(reader2.getEncoding()), cs);
+        reader2.close();
+    }
+
+    /**
+     * @tests java.io.InputStreamReader(java.io.InputStream,
+     *        java.nio.charset.CharsetDecoder)
+     */
+    public void test_ConstructorLjava_io_InputStreamLjava_nio_charset_CharsetDecoder()
+            throws IOException {
+        CharsetDecoder decoder = Charset.forName("utf-8").newDecoder();
+        try {
+            reader = new InputStreamReader(null, decoder);
+            fail();
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            reader = new InputStreamReader(in, (CharsetDecoder) null);
+            fail();
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        InputStreamReader reader2 = new InputStreamReader(in, decoder);
+        assertEquals(Charset.forName(reader2.getEncoding()), decoder.charset());
+        reader2.close();
+    }
+
+    /**
+     * @tests java.io.InputStreamReader#getEncoding()
+     */
+    public void test_getEncoding() throws IOException {
+        InputStreamReader isr = new InputStreamReader(fis, "8859_1");
+        assertEquals("Returned incorrect encoding when setting 8859_1",
+                "ISO8859_1", isr.getEncoding());
+
+        isr = new InputStreamReader(fis, "ISO-8859-1");
+        assertEquals("Returned incorrect encoding when setting ISO-8859-1",
+                "ISO8859_1", isr.getEncoding());
+
+        byte b[] = new byte[5];
+        isr = new InputStreamReader(new ByteArrayInputStream(b), "UTF-16BE");
+        isr.close();
+        assertNull(isr.getEncoding());
+
+        try {
+            isr = new InputStreamReader(System.in, "UTF-16BE");
+        } catch (UnsupportedEncodingException e) {
+            // Ignored
+        }
+        assertEquals("UnicodeBigUnmarked", isr.getEncoding());
+    }
+
+    /**
+     * @tests java.io.InputStreamReader#read()
+     */
+    public void test_read() throws IOException {
+        assertEquals('T', (char) reader.read());
+        assertEquals('h', (char) reader.read());
+        assertEquals('i', (char) reader.read());
+        assertEquals('s', (char) reader.read());
+        assertEquals(' ', (char) reader.read());
+        reader.read(new char[source.length() - 5], 0, source.length() - 5);
+        assertEquals(-1, reader.read());
+
+        int c = is.read();
+        assertTrue("returned incorrect char", (char) c == fileString.charAt(0));
+        InputStreamReader reader = new InputStreamReader(
+                new ByteArrayInputStream(new byte[] { (byte) 0xe8, (byte) 0x9d,
+                        (byte) 0xa5 }), "UTF8");
+        assertTrue("wrong double byte char", reader.read() == '\u8765');
+
+        // Regression for HARMONY-166
+        InputStream in;
+
+        in = new LimitedByteArrayInputStream(0);
+        reader = new InputStreamReader(in, "UTF-16BE");
+        assertEquals("Incorrect byte UTF-16BE", '\u6172', reader.read());
+
+        in = new LimitedByteArrayInputStream(0);
+        reader = new InputStreamReader(in, "UTF-16LE");
+        assertEquals("Incorrect byte UTF-16BE", '\u7261', reader.read());
+
+        in = new LimitedByteArrayInputStream(1);
+        reader = new InputStreamReader(in, "UTF-16");
+        assertEquals("Incorrect byte UTF-16BE", '\u7261', reader.read());
+
+        /*
+         * Temporarily commented out due to lack of ISO2022 support in ICU4J 3.8
+         * in = new LimitedByteArrayInputStream(2); reader = new
+         * InputStreamReader(in, "ISO2022JP"); assertEquals("Incorrect byte
+         * ISO2022JP 1", '\u4e5d', reader.read()); assertEquals("Incorrect byte
+         * ISO2022JP 2", '\u7b2c', reader.read());
+         */
+    }
+
+    /*
+     * Class under test for int read() Regression for Harmony-411
+     */
+    public void test_read_1() throws IOException {
+        // if the decoder is constructed by InputStreamReader itself, the
+        // decoder's default error action is REPLACE
+        InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(
+                new byte[] { -32, -96 }), "UTF-8");
+        assertEquals("read() return incorrect value", 65533, isr.read());
+
+        InputStreamReader isr2 = new InputStreamReader(
+                new ByteArrayInputStream(new byte[] { -32, -96 }), Charset
+                        .forName("UTF-8"));
+        assertEquals("read() return incorrect value", 65533, isr2.read());
+
+        // if the decoder is passed in, keep its status intact
+        CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
+        decoder.onMalformedInput(CodingErrorAction.REPORT);
+        InputStreamReader isr3 = new InputStreamReader(
+                new ByteArrayInputStream(new byte[] { -32, -96 }), decoder);
+        try {
+            isr3.read();
+            fail("Should throw MalformedInputException");
+        } catch (MalformedInputException e) {
+            // expected
+        }
+
+        CharsetDecoder decoder2 = Charset.forName("UTF-8").newDecoder();
+        decoder2.onMalformedInput(CodingErrorAction.IGNORE);
+        InputStreamReader isr4 = new InputStreamReader(
+                new ByteArrayInputStream(new byte[] { -32, -96 }), decoder2);
+        assertEquals("read() return incorrect value", -1, isr4.read());
+
+        CharsetDecoder decoder3 = Charset.forName("UTF-8").newDecoder();
+        decoder3.onMalformedInput(CodingErrorAction.REPLACE);
+        InputStreamReader isr5 = new InputStreamReader(
+                new ByteArrayInputStream(new byte[] { -32, -96 }), decoder3);
+        assertEquals("read() return incorrect value", 65533, isr5.read());
+    }
+
+    public void test_read_specialCharset() throws IOException {
+        reader.close();
+        in = this.getClass().getClassLoader().getResourceAsStream(
+                "org/apache/harmony/luni/tests/java/io/testfile-utf8.txt");
+        reader = new InputStreamReader(in, "utf-8");
+        int c;
+        StringBuffer sb = new StringBuffer();
+        while ((c = reader.read()) != -1) {
+            sb.append((char) c);
+        }
+        // delete BOM
+        assertEquals(source, sb.deleteCharAt(0).toString());
+
+        sb.setLength(0);
+        reader.close();
+        in = this.getClass().getClassLoader().getResourceAsStream(
+                "org/apache/harmony/luni/tests/java/io/testfile.txt");
+        try {
+            reader = new InputStreamReader(in, "gb18030");
+        } catch (UnsupportedEncodingException e) {
+            System.out
+                    .println("GB18030 is not supported, abort test InputStreamReaderTest.testSpecialCharsetReading().");
+        }
+        while ((c = reader.read()) != -1) {
+            sb.append((char) c);
+        }
+        assertEquals(source, sb.toString());
+    }
+
+    /**
+     * @tests java.io.InputStreamReader#read(char[], int, int)
+     */
+    public void test_read$CII() throws IOException {
+        char[] rbuf = new char[100];
+        char[] sbuf = new char[100];
+        fileString.getChars(0, 100, sbuf, 0);
+        is.read(rbuf, 0, 100);
+        for (int i = 0; i < rbuf.length; i++) {
+            assertTrue("returned incorrect chars", rbuf[i] == sbuf[i]);
+        }
+
+        // Test successive reads
+        byte[] data = new byte[8192 * 2];
+        Arrays.fill(data, (byte) 116); // 116 = ISO-8859-1 value for 't'
+        ByteArrayInputStream bis = new ByteArrayInputStream(data);
+        InputStreamReader isr = new InputStreamReader(bis, "ISO-8859-1");
+
+        // One less than the InputStreamReader.BUFFER_SIZE
+        char[] buf = new char[8191];
+        int bytesRead = isr.read(buf, 0, buf.length);
+        assertFalse(-1 == bytesRead);
+        bytesRead = isr.read(buf, 0, buf.length);
+        assertFalse(-1 == bytesRead);
+
+        bis = new ByteArrayInputStream(source.getBytes("UTF-8"));
+        isr = new InputStreamReader(in, "UTF-8");
+        char[] chars = new char[source.length()];
+        assertEquals(source.length() - 3, isr.read(chars, 0, chars.length - 3));
+        assertEquals(3, isr.read(chars, 0, 10));
+    }
+
+    /*
+     * Class under test for int read(char[], int, int)
+     */
+    public void test_read$CII_1() throws IOException {
+        try {
+            // Throws IndexOutOfBoundsException before NullPointerException
+            reader.read(null, -1, 1);
+            fail("Should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+
+        try {
+            // Throws NullPointerException before IndexOutOfBoundsException
+            reader.read(null, 0, -1);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // expected
+        }
+
+        try {
+            reader.read(null, 0, 1);
+            fail();
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            reader.read(new char[3], -1, 1);
+            fail();
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        }
+        try {
+            reader.read(new char[3], 0, -1);
+            fail();
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        }
+        try {
+            reader.read(new char[3], 1, 3);
+            fail();
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        }
+        assertEquals(0, reader.read(new char[3], 3, 0));
+        char[] chars = new char[source.length()];
+        assertEquals(0, reader.read(chars, 0, 0));
+        assertEquals(0, chars[0]);
+        assertEquals(3, reader.read(chars, 0, 3));
+        assertEquals(5, reader.read(chars, 3, 5));
+        assertEquals(source.length() - 8, reader.read(chars, 8,
+                chars.length - 8));
+        assertTrue(Arrays.equals(chars, source.toCharArray()));
+        assertEquals(-1, reader.read(chars, 0, chars.length));
+        assertTrue(Arrays.equals(chars, source.toCharArray()));
+    }
+
+    /**
+     * @tests java.io.InputStreamReader#ready()
+     */
+    public void test_ready() throws IOException {
+        assertTrue("Ready test failed", is.ready());
+        is.read();
+        assertTrue("More chars, but not ready", is.ready());
+
+        assertTrue(reader.ready());
+        reader.read(new char[source.length()]);
+        assertFalse(reader.ready());
+    }
+}

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PrintStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PrintStreamTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PrintStreamTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PrintStreamTest.java Wed Jun 23 12:58:28 2010
@@ -77,6 +77,14 @@ public class PrintStreamTest extends jun
     	MockPrintStream os = new MockPrintStream(testFilePath, "utf-8");
     	assertNotNull(os);
     	os.close();
+    	
+    	// Test that a bogus charset is mentioned in the exception
+    	try {
+    	    new PrintStream(testFilePath, "Bogus");
+    	    fail("Exception expected");
+    	} catch (UnsupportedEncodingException e) {
+    	    assertNotNull(e.getMessage());
+    	}
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java Wed Jun 23 12:58:28 2010
@@ -697,6 +697,12 @@ public class String2Test extends junit.f
                 "a", "ccc"));
         assertEquals("Failed replace by smaller seq", "$bba^", "$aaaaa^"
                 .replace(new StringBuilder("aa"), "b"));
+        assertEquals("Failed to replace empty string", "%%a%%b%%c%%",
+                "abc".replace("", "%%"));
+        assertEquals("Failed to replace with empty string", "aacc",
+                "aabbcc".replace("b", ""));
+        assertEquals("Failed to replace in empty string", "abc",
+                "".replace("", "abc"));
     }
 
     /**
@@ -737,6 +743,33 @@ public class String2Test extends junit.f
                 && (hw1.substring(5, 10).equals("World")));
         assertTrue("not identical", hw1.substring(0, hw1.length()) == hw1);
     }
+    
+	/**
+	 * @tests java.lang.String#substring(int, int)
+	 */
+	public void test_substringErrorMessage() {
+		try {
+			hw1.substring(-1, 1);
+		} catch (StringIndexOutOfBoundsException ex) {
+			String msg = ex.getMessage();
+			assertTrue("Expected message to contain -1: " + msg, msg
+			        .indexOf("-1") != -1);
+		}
+		try {
+			hw1.substring(4, 1);
+		} catch (StringIndexOutOfBoundsException ex) {
+			String msg = ex.getMessage();
+			assertTrue("Expected message to contain -3: " + msg, msg
+			        .indexOf("-3") != -1);
+		}
+		try {
+			hw1.substring(0, 100);
+		} catch (StringIndexOutOfBoundsException ex) {
+			String msg = ex.getMessage();
+			assertTrue("Expected message to contain 100: " + msg, msg
+			        .indexOf("100") != -1);
+		}
+	}
 
     /**
      * @tests java.lang.String#toCharArray()

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java Wed Jun 23 12:58:28 2010
@@ -17,6 +17,7 @@
 
 package org.apache.harmony.luni.tests.java.lang.reflect;
 
+import java.io.IOException;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
@@ -24,6 +25,7 @@ import java.lang.reflect.UndeclaredThrow
 
 import java.security.AllPermission;
 import java.security.ProtectionDomain;
+import java.util.ArrayList;
 
 import tests.support.Support_Proxy_I1;
 import tests.support.Support_Proxy_I2;
@@ -251,6 +253,19 @@ public class ProxyTest extends junit.fra
         }
 
     }
+    
+    @SuppressWarnings("unchecked")
+    public void test_ProxyClass_withParentAndSubInThrowList() throws SecurityException, NoSuchMethodException{
+        TestParentIntf myImpl = new MyImplWithParentAndSubInThrowList();
+        Class<?> c = Proxy.getProxyClass(myImpl.getClass().getClassLoader(), myImpl.getClass().getInterfaces());
+        Method m = c.getMethod("test", (Class<?> [])null);
+        Class<?> []exceptions = m.getExceptionTypes();
+        ArrayList<Class> exps = new ArrayList<Class>();
+        for(Class<?> exp : exceptions){
+            exps.add(exp);
+        }
+        assertTrue(exps.contains(Exception.class));
+    }
 
     public static interface ITestReturnObject {
         Object f();
@@ -295,6 +310,11 @@ public class ProxyTest extends junit.fra
         }
     }
 
+    class MyImplWithParentAndSubInThrowList implements TestSubIntf{
+        public void test() throws Exception{
+            throw new Exception();
+        }
+    }
 
 
 	protected void setUp() {
@@ -305,3 +325,10 @@ public class ProxyTest extends junit.fra
 }
 
 interface PkgIntf {}
+
+interface TestParentIntf {
+    //IOException is a subclass of Exception
+    public void test() throws IOException, Exception;
+}
+
+interface TestSubIntf extends TestParentIntf{}

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java Wed Jun 23 12:58:28 2010
@@ -35,101 +35,6 @@ import tests.support.Support_Configurati
 
 public class InetAddressTest extends junit.framework.TestCase {
     
-    private static boolean someoneDone[] = new boolean[2];
-
-    protected static boolean threadedTestSucceeded;
-
-    protected static String threadedTestErrorString;
-
-    /**
-     * This class is used to test inet_ntoa, gethostbyaddr and gethostbyname
-     * functions in the VM to make sure they're threadsafe. getByName will cause
-     * the gethostbyname function to be called. getHostName will cause the
-     * gethostbyaddr to be called. getHostAddress will cause inet_ntoa to be
-     * called.
-     */
-    static class threadsafeTestThread extends Thread {
-        private String lookupName;
-
-        private InetAddress testAddress;
-
-        private int testType;
-
-        /*
-         * REP_NUM can be adjusted if desired. Since this error is
-         * non-deterministic it may not always occur. Setting REP_NUM higher,
-         * increases the chances of an error being detected, but causes the test
-         * to take longer. Because the Java threads spend a lot of time
-         * performing operations other than running the native code that may not
-         * be threadsafe, it is quite likely that several thousand iterations
-         * will elapse before the first error is detected.
-         */
-        private static final int REP_NUM = 20000;
-
-        public threadsafeTestThread(String name, String lookupName,
-                InetAddress testAddress, int type) {
-            super(name);
-            this.lookupName = lookupName;
-            this.testAddress = testAddress;
-            testType = type;
-        }
-
-        public void run() {
-            try {
-                String correctName = testAddress.getHostName();
-                String correctAddress = testAddress.getHostAddress();
-                long startTime = System.currentTimeMillis();
-
-                synchronized (someoneDone) {
-                }
-
-                for (int i = 0; i < REP_NUM; i++) {
-                    if (someoneDone[testType]) {
-                        break;
-                    } else if ((i % 25) == 0
-                            && System.currentTimeMillis() - startTime > 240000) {
-                        System.out
-                                .println("Exiting due to time limitation after "
-                                        + i + " iterations");
-                        break;
-                    }
-
-                    InetAddress ia = InetAddress.getByName(lookupName);
-                    String hostName = ia.getHostName();
-                    String hostAddress = ia.getHostAddress();
-
-                    // Intentionally not looking for exact name match so that 
-                    // the test works across different platforms that may or 
-                    // may not include a domain suffix on the hostname
-                    if (!hostName.startsWith(correctName)) {
-                        threadedTestSucceeded = false;
-                        threadedTestErrorString = (testType == 0 ? "gethostbyname"
-                                : "gethostbyaddr")
-                                + ": getHostName() returned "
-                                + hostName
-                                + " instead of " + correctName;
-                        break;
-                    }
-                    // IP addresses should match exactly
-                    if (!correctAddress.equals(hostAddress)) {
-                        threadedTestSucceeded = false;
-                        threadedTestErrorString = (testType == 0 ? "gethostbyname"
-                                : "gethostbyaddr")
-                                + ": getHostName() returned "
-                                + hostAddress
-                                + " instead of " + correctAddress;
-                        break;
-                    }
-
-                }
-                someoneDone[testType] = true;
-            } catch (Exception e) {
-                threadedTestSucceeded = false;
-                threadedTestErrorString = e.toString();
-            }
-        }
-    }
-    
     /**
      * @tests java.net.InetAddress#getByName(String)
      */
@@ -314,62 +219,6 @@ public class InetAddressTest extends jun
         } finally {
             System.setSecurityManager(oldman);
         }
-
-        // Make sure there is no caching
-        String originalPropertyValue = System
-                .getProperty("networkaddress.cache.ttl");
-        System.setProperty("networkaddress.cache.ttl", "0");
-
-        // Test for threadsafety
-        try {
-            InetAddress lookup1 = InetAddress
-                    .getByName(Support_Configuration.InetTestAddress);
-            assertTrue(lookup1 + " expected "
-                    + Support_Configuration.InetTestIP,
-                    Support_Configuration.InetTestIP.equals(lookup1
-                            .getHostAddress()));
-            InetAddress lookup2 = InetAddress
-                    .getByName(Support_Configuration.InetTestAddress2);
-            assertTrue(lookup2 + " expected "
-                    + Support_Configuration.InetTestIP2,
-                    Support_Configuration.InetTestIP2.equals(lookup2
-                            .getHostAddress()));
-            threadsafeTestThread thread1 = new threadsafeTestThread("1",
-                    lookup1.getHostName(), lookup1, 0);
-            threadsafeTestThread thread2 = new threadsafeTestThread("2",
-                    lookup2.getHostName(), lookup2, 0);
-            threadsafeTestThread thread3 = new threadsafeTestThread("3",
-                    lookup1.getHostAddress(), lookup1, 1);
-            threadsafeTestThread thread4 = new threadsafeTestThread("4",
-                    lookup2.getHostAddress(), lookup2, 1);
-
-            // initialize the flags
-            threadedTestSucceeded = true;
-            synchronized (someoneDone) {
-                thread1.start();
-                thread2.start();
-                thread3.start();
-                thread4.start();
-            }
-            thread1.join();
-            thread2.join();
-            thread3.join();
-            thread4.join();
-            /* FIXME: comment the assertion below because it is platform/configuration dependent
-             * Please refer to HARMONY-1664 (https://issues.apache.org/jira/browse/HARMONY-1664)
-             * for details
-             */
-//            assertTrue(threadedTestErrorString, threadedTestSucceeded);
-        } finally {
-            // restore the old value of the property
-            if (originalPropertyValue == null)
-                // setting the property to -1 has the same effect as having the
-                // property be null
-                System.setProperty("networkaddress.cache.ttl", "-1");
-            else
-                System.setProperty("networkaddress.cache.ttl",
-                        originalPropertyValue);
-        }
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/JarURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/JarURLConnectionTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/JarURLConnectionTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/JarURLConnectionTest.java Wed Jun 23 12:58:28 2010
@@ -305,6 +305,17 @@ public class JarURLConnectionTest extend
                 "content/unknown", u.openConnection().getContentType());
     }
 
+    public void test_getURLEncodedEntry() throws IOException {
+        String base = "file:resources/org/apache/harmony/luni/tests/java/net/url-test.jar";
+        URL url = new URL("jar:" + base + "!/test%20folder%20for%20url%20test/test");
+
+        if (url != null) {
+            // Force existence check
+            InputStream is = url.openStream();
+            is.close();
+        }
+    }
+
 	protected void setUp() {
 	}
 

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetworkInterfaceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetworkInterfaceTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetworkInterfaceTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetworkInterfaceTest.java Wed Jun 23 12:58:28 2010
@@ -376,12 +376,22 @@ public class NetworkInterfaceTest extend
 					networkInterface1.toString());
 			assertFalse("validate that non-zero length string is generated",
 					networkInterface1.toString().equals(""));
+
+            SecurityManager backup = System.getSecurityManager();
+            System.setSecurityManager(new SecurityManager());
+            assertNotNull(networkInterface1.toString());
+            System.setSecurityManager(backup);
 		}
 		if (atLeastTwoInterfaces) {
 			assertFalse(
 					"Validate strings are different for different interfaces",
 					networkInterface1.toString().equals(
 							networkInterface2.toString()));
+            
+            SecurityManager backup = System.getSecurityManager();
+            System.setSecurityManager(new SecurityManager());
+            assertNotNull(networkInterface2.toString());
+            System.setSecurityManager(backup);
 		}
 	}
 

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java Wed Jun 23 12:58:28 2010
@@ -138,6 +138,11 @@ public class URLClassLoaderTest extends 
                     resValues[i++], sb.toString());
         }
         assertEquals("Incorrect number of resources returned: " + i, 2, i);
+        
+        // Regression for HARMONY-6510
+        res = ucl.findResources(null);
+        assertNotNull(res);
+        assertFalse(res.hasMoreElements());
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java Wed Jun 23 12:58:28 2010
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.HttpURLConnection;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
@@ -68,6 +69,35 @@ public class URLTest extends TestCase {
     boolean caught = false;
 
     static boolean isSelectCalled;
+    
+    
+    /**
+     * Check when the argument in url consists of windows path character back-slach
+     * @tests java.net.URL#openConnection(Proxy)
+     * @throws Exception
+     */
+    public void test_openConnection_windows_path_character() throws Exception {
+        int port = 0;
+        HttpURLConnection con = null;
+        try {
+            port = Support_Jetty.startDefaultHttpServer();
+        } catch (Exception e) {
+            fail("Exception during setup jetty : " + e.getMessage());
+        }
+        try {
+            URL url = new URL("http://0.0.0.0:" + port + "/servlet?ResourceName=C:\\temp\\test.txt");
+            con = (HttpURLConnection)url.openConnection();
+            con.setDoInput(true);
+            con.setDoOutput(true);
+            con.setUseCaches(false);
+            con.setRequestMethod("GET");
+            InputStream is = con.getInputStream();
+         } catch (Exception e) {
+             fail("Unexpected exception : " + e.getMessage());
+         } finally {
+            con.disconnect();
+         }
+    }
 
     /**
      * @tests java.net.URL#URL(java.lang.String)
@@ -1352,6 +1382,49 @@ public class URLTest extends TestCase {
         } catch (SecurityException e) {
             // expected;
         }
+        
+        // Regression tests for HARMONY-6499
+        try {
+            handler.parse(url, "any", 10, Integer.MIN_VALUE);
+            fail("Should throw StringIndexOutOfBoundsException");
+        } catch (StringIndexOutOfBoundsException e) {
+            // expected;
+        }
+        
+        try {
+            handler.parse(url, "any", 10, Integer.MIN_VALUE+1);
+            fail("Should throw StringIndexOutOfBoundsException");
+        } catch (StringIndexOutOfBoundsException e) {
+            // expected;
+        }
+        
+        try {
+            handler.parse(url, "any", Integer.MIN_VALUE, Integer.MIN_VALUE);
+            fail("Should throw StringIndexOutOfBoundsException");
+        } catch (StringIndexOutOfBoundsException e) {
+            // expected;
+        }
+        
+        try {
+            handler.parse(url, "any", Integer.MIN_VALUE, 2);
+            fail("Should throw StringIndexOutOfBoundsException");
+        } catch (StringIndexOutOfBoundsException e) {
+            // expected;
+        }
+        
+        try {
+            handler.parse(url, "any", -1, 2);
+            fail("Should throw StringIndexOutOfBoundsException");
+        } catch (StringIndexOutOfBoundsException e) {
+            // expected;
+        }
+        
+        try {
+            handler.parse(url, "any", -1, -1);
+            fail("Should throw SecurityException");
+        } catch (SecurityException e) {
+            // expected;
+        }
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/math/src/main/java/java/math/BigInteger.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/math/src/main/java/java/math/BigInteger.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/math/src/main/java/java/math/BigInteger.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/math/src/main/java/java/math/BigInteger.java Wed Jun 23 12:58:28 2010
@@ -1344,8 +1344,8 @@ public class BigInteger extends Number i
         if (m.isOne() | (exponent.sign > 0 & base.sign == 0)) {
             return BigInteger.ZERO;
         }
-        if (base.sign == 0 && exponent.sign == 0) {
-            return BigInteger.ONE;
+        if (exponent.sign == 0) {
+            return BigInteger.ONE.mod(m);
         }
         if (exponent.sign < 0) {
             base = modInverse(m);

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerModPowTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerModPowTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerModPowTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerModPowTest.java Wed Jun 23 12:58:28 2010
@@ -47,6 +47,13 @@ public class BigIntegerModPowTest extend
 		} catch (ArithmeticException e) {
 			assertEquals("Improper exception message", "BigInteger: modulus not positive", e.getMessage());
 		}
+
+        try {
+            BigInteger.ZERO.modPow(new BigInteger("-1"), new BigInteger("10"));
+            fail("ArithmeticException has not been caught");
+        } catch (ArithmeticException e) {
+            // expected
+        }
 	}
 
 	/**
@@ -95,6 +102,29 @@ public class BigIntegerModPowTest extend
 		assertEquals("incorrect sign", 1, result.signum());
 	}
 
+    public void testModPowZeroExp() {
+        BigInteger exp = new BigInteger("0");
+        BigInteger[] base = new BigInteger[] {new BigInteger("-1"), new BigInteger("0"), new BigInteger("1")};
+        BigInteger[] mod = new BigInteger[] {new BigInteger("2"), new BigInteger("10"), new BigInteger("2147483648")};
+
+        for (int i = 0; i < base.length; ++i) {
+            for (int j = 0; j < mod.length; ++j) {
+                assertEquals(base[i] + " modePow(" + exp + ", " + mod[j]
+                        + ") should be " + BigInteger.ONE, BigInteger.ONE,
+                        base[i].modPow(exp, mod[j]));
+            }
+        }
+
+        mod = new BigInteger[] {new BigInteger("1")};
+        for (int i = 0; i < base.length; ++i) {
+            for (int j = 0; j < mod.length; ++j) {
+                assertEquals(base[i] + " modePow(" + exp + ", " + mod[j]
+                        + ") should be " + BigInteger.ZERO, BigInteger.ZERO,
+                        base[i].modPow(exp, mod[j]));
+            }
+        }
+    }
+
 	/**
 	 * modInverse: non-positive modulus
 	 */

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c Wed Jun 23 12:58:28 2010
@@ -27,17 +27,34 @@ JNIEXPORT jlong JNICALL Java_org_apache_
 	jclass descriptorCLS;
 	jfieldID descriptorFID;
 	hysocket_t hysocketP;
+
 	//TODO add to cache
 	descriptorCLS = (*env)->FindClass (env, "java/io/FileDescriptor");
 	if (NULL == descriptorCLS){
 		return 0;
 	}
+
 	descriptorFID = (*env)->GetFieldID (env, descriptorCLS, "descriptor", "J");
 	if (NULL == descriptorFID){
 		return 0;
 	}
+
 	hysocketP = (hysocket_t) ((IDATA)((*env)->GetLongField (env, fd, descriptorFID)));
-	return SOCKET_CAST(hysocketP);
+    if (NULL == hysocketP) {
+        return 0;
+    }
+
+#if defined(WIN32) || defined(WIN64)
+    if (hysocketP->flags & SOCKET_IPV4_OPEN_MASK) {
+        return (jlong)(hysocketP->ipv4);
+    } else if (hysocketP->flags & SOCKET_IPV6_OPEN_MASK) {
+        return (jlong)(hysocketP->ipv6);
+    } else {
+        return 0;
+    }
+#else 
+    return (jlong)(hysocketP->sock);
+#endif
 }
 
 

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/portlib/src/main/native/port/unix/hysock.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/portlib/src/main/native/port/unix/hysock.c?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/portlib/src/main/native/port/unix/hysock.c (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/portlib/src/main/native/port/unix/hysock.c Wed Jun 23 12:58:28 2010
@@ -131,6 +131,8 @@ I_32 map_sockettype_Hy_to_OS (I_32 socke
 
 static I_32 findHostError (int herr);
 
+static socklen_t getAddrLength(hysockaddr_t addr);
+
 #undef CDEV_CURRENT_FUNCTION
 
 #if NO_R
@@ -593,21 +595,10 @@ hysock_bind (struct HyPortLibrary * port
              hysockaddr_t addr)
 {
   I_32 rc = 0;
-  I_32 length = sizeof (addr->addr);
-
-#if defined(SIN6_LEN)
-  length = sizeof (struct sockaddr_storage);
-#if defined(IPv6_FUNCTION_SUPPORT)
-  if (((OSSOCKADDR *) & addr->addr)->sin_family == OS_AF_INET6)
-    {
-      length = ((OSSOCKADDR_IN6 *) & addr->addr)->sin6_len;
-    }
-#endif
-#endif
+  I_32 length = getAddrLength(addr);
 
   if (bind
-      (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr,
-       sizeof (addr->addr)) < 0)
+      (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr, length) < 0)
     {
       rc = errno;
       HYSOCKDEBUG ("<bind failed, err=%d>\n", rc);
@@ -678,10 +669,10 @@ hysock_connect (struct HyPortLibrary * p
                 hysockaddr_t addr)
 {
   I_32 rc = 0;
+  I_32 length = getAddrLength(addr);
 
   if (connect
-      (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr,
-       sizeof (addr->addr)) < 0)
+      (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr, length) < 0)
     {
       rc = errno;
       HYSOCKDEBUG ("<connect failed, err=%d>\n", rc);
@@ -2058,7 +2049,7 @@ I_32 VMCALL
 hysock_getpeername (struct HyPortLibrary * portLibrary, hysocket_t handle,
                     hysockaddr_t addrHandle)
 {
-  socklen_t addrlen = sizeof (addrHandle->addr);
+  socklen_t addrlen = getAddrLength(addrHandle);
 
   if (getpeername
       (SOCKET_CAST (handle), (struct sockaddr *) &addrHandle->addr,
@@ -2550,7 +2541,7 @@ hysock_readfrom (struct HyPortLibrary * 
 
   if (NULL == addrHandle)
     {
-      addrlen = sizeof (*addrHandle);
+      addrlen = sizeof (*addrHandle); /* TOFIX: This is not used? */
       bytesRec =
         recvfrom (SOCKET_CAST (sock), buf, nbyte, flags, NULL, &addrlen);
     }
@@ -2560,6 +2551,7 @@ hysock_readfrom (struct HyPortLibrary * 
       bytesRec =
         recvfrom (SOCKET_CAST (sock), buf, nbyte, flags,
                   (struct sockaddr *) &addrHandle->addr, &addrlen);
+      /* TOFIX: should check if addrlen > sizeof(addrlen) ? */
     }
   if (bytesRec == -1)
     {
@@ -3465,6 +3457,9 @@ hysock_sockaddr_init (struct HyPortLibra
   sockaddr->sin_family = family;
   sockaddr->sin_addr.s_addr = nipAddr;
   sockaddr->sin_port = nPort;
+#if defined(FREEBSD)
+  sockaddr->sin_len = sizeof(OSSOCKADDR);
+#endif
 
   return 0;
 }
@@ -3530,6 +3525,9 @@ hysock_sockaddr_init6 (struct HyPortLibr
           sockaddr_6->sin6_family = OS_AF_INET6;
           sockaddr_6->sin6_scope_id = scope_id;
           sockaddr_6->sin6_flowinfo = htonl (flowinfo);
+#if defined(FREEBSD)
+          sockaddr_6->sin6_len = sizeof(OSSOCKADDR_IN6);
+#endif
         }
       else
         {
@@ -3540,6 +3538,10 @@ hysock_sockaddr_init6 (struct HyPortLibr
           memcpy (&sockaddr->sin_addr.s_addr, addr, addrlength);
           sockaddr->sin_port = nPort;
           sockaddr->sin_family = OS_AF_INET4;
+#if defined(FREEBSD)
+          sockaddr->sin_len = sizeof(OSSOCKADDR);
+#endif
+
 #if defined(IPv6_FUNCTION_SUPPORT)
         }
 #endif
@@ -3555,12 +3557,7 @@ hysock_sockaddr_init6 (struct HyPortLibr
       sockaddr_6->sin6_scope_id = scope_id;
       sockaddr_6->sin6_flowinfo = htonl (flowinfo);
 #if defined(SIN6_LEN)
-      sockaddr_6->sin6_len = sizeof (struct sockaddr_in6);
-      if (((OSSOCKADDR_IN6 *) & handle->addr)->sin6_len != 0)
-        {
-          sockaddr_6->sin6_len =
-            ((OSSOCKADDR_IN6 *) & handle->addr)->sin6_len;
-        }
+      sockaddr_6->sin6_len = sizeof(OSSOCKADDR_IN6);
 #endif
     }
 #endif
@@ -3571,6 +3568,9 @@ hysock_sockaddr_init6 (struct HyPortLibr
       memcpy (&sockaddr->sin_addr.s_addr, addr, HYSOCK_INADDR_LEN);
       sockaddr->sin_port = nPort;
       sockaddr->sin_family = map_addr_family_Hy_to_OS (family);
+#if defined(FREEBSD)
+      sockaddr->sin_len = sizeof(OSSOCKADDR);
+#endif
     }
 
   return 0;
@@ -3845,7 +3845,7 @@ hysock_writeto (struct HyPortLibrary * p
   bytesSent =
     sendto (SOCKET_CAST (sock), buf, nbyte, flags,
             (struct sockaddr *) &(addrHandle->addr),
-            sizeof (addrHandle->addr));
+            getAddrLength(addrHandle));
 
   if (bytesSent == -1)
     {
@@ -5166,7 +5166,7 @@ hysock_connect_with_timeout (struct HyPo
 
       rc = connect
           (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr,
-           sizeof (addr->addr));
+           getAddrLength(addr));
       if (rc < 0)
         {
           rc = errno;
@@ -5274,6 +5274,15 @@ hysock_connect_with_timeout (struct HyPo
 
 #undef CDEV_CURRENT_FUNCTION
 
-#define CDEV_CURRENT_FUNCTION
+#define CDEV_CURRENT_FUNCTION getAddrLength
 
+static socklen_t getAddrLength(hysockaddr_t addr)
+{
+  return
+#if defined(IPv6_FUNCTION_SUPPORT)
+    ((OSSOCKADDR *) & addr->addr)->sin_family == OS_AF_INET6 ?
+    sizeof(OSSOCKADDR_IN6) :
+#endif
+    sizeof(OSSOCKADDR);
+}
 #undef CDEV_CURRENT_FUNCTION

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java Wed Jun 23 12:58:28 2010
@@ -199,7 +199,7 @@ public class PreferencesTest extends Tes
             prefs = Preferences.userNodeForPackage(PreferencesTest.class);
         } finally {
             try {
-                prefs = Preferences.userRoot().node("tests");
+                prefs = Preferences.userNodeForPackage(PreferencesTest.class);
                 prefs.removeNode();
             } catch (Exception e) {
                 // Ignored

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicArrowButton.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicArrowButton.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicArrowButton.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicArrowButton.java Wed Jun 23 12:58:28 2010
@@ -35,19 +35,23 @@ import org.apache.harmony.x.swing.Utilit
 public class BasicArrowButton extends JButton implements SwingConstants {
     protected int direction;
 
-    private static Color shadow = UIManager.getColor("ScrollBar.shadow");
-    private static Color darkShadow = UIManager.getColor("ScrollBar.darkShadow");
+    private Color shadow;
+    private Color darkShadow;
 
     public BasicArrowButton(final int direction) {
         this.direction = direction;
+        shadow = UIManager.getColor("ScrollBar.shadow");
+        darkShadow = UIManager.getColor("ScrollBar.darkShadow");
     }
 
-    public BasicArrowButton(final int direction, final Color background, final Color shadow,
-                            final Color darkShadow, final Color highlight) {
-        BasicArrowButton.shadow = shadow;
-        BasicArrowButton.darkShadow = darkShadow;
+    public BasicArrowButton(final int direction, final Color background,
+                            final Color shadow, final Color darkShadow,
+                            final Color highlight) {
+        this.shadow = shadow;
+        this.darkShadow = darkShadow;
         this.direction = direction;
         setBackground(background);
+        // TOFIX: highlight is ignored
     }
 
     public int getDirection() {
@@ -82,7 +86,10 @@ public class BasicArrowButton extends JB
         return false;
     }
 
-    public void paintTriangle(final Graphics g, final int x, final int y, final int size, final int direction, final boolean isEnabled) {
-        Utilities.fillArrow(g, x, y, direction, size, false, isEnabled ? darkShadow : shadow);
+    public void paintTriangle(final Graphics g, final int x, final int y,
+                              final int size, final int direction,
+                              final boolean isEnabled) {
+        Utilities.fillArrow(g, x, y, direction, size, false,
+                            isEnabled ? darkShadow : shadow);
     }
 }

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java Wed Jun 23 12:58:28 2010
@@ -505,8 +505,17 @@ public class DefaultMutableTreeNode impl
         return getUserObject() != null ? getUserObject().toString() : null;
     }
 
+    @Override
     public Object clone() {
-        return new DefaultMutableTreeNode(getUserObject());
+        try {
+            DefaultMutableTreeNode clone = (DefaultMutableTreeNode) super.clone();
+            // Spec says the new node must have no parent or children
+            clone.parent = null;
+            clone.children = null;
+            return clone;
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeException(e);
+        }
     }
 
 

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java Wed Jun 23 12:58:28 2010
@@ -148,6 +148,13 @@ public class JTree_DynamicUtilTreeNodeTe
         assertTrue(node.loadedChildren);
     }
 
+    public void testClone() {
+        Object obj = new Object();
+        DynamicUtilTreeNode t = new DynamicUtilTreeNode(obj, obj);
+        Object cl = t.clone();
+        assertEquals(t.getClass(), cl.getClass());
+    }
+
     public void testChildren() throws Exception {
         DynamicUtilTreeNode node = new DynamicUtilTreeNode("value", new Object[] { "1", "2" });
         assertFalse(node.loadedChildren);

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicArrowButtonTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicArrowButtonTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicArrowButtonTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicArrowButtonTest.java Wed Jun 23 12:58:28 2010
@@ -75,9 +75,6 @@ public class BasicArrowButtonTest extend
     public void testGetBackground() {
         final Color c = Color.red;
         BasicArrowButton b = new BasicArrowButton(240, c, c, c, c);
-
-        System.out.println("parameter background == " + c);
-        System.out.println("getBackground()==" + b.getBackground());
         assertSame(c, b.getBackground());
     } 
 }

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/text/src/main/java/java/text/DecimalFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/text/src/main/java/java/text/DecimalFormat.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/text/src/main/java/java/text/DecimalFormat.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/text/src/main/java/java/text/DecimalFormat.java Wed Jun 23 12:58:28 2010
@@ -636,6 +636,10 @@ public class DecimalFormat extends Numbe
      */
     public void applyLocalizedPattern(String pattern) {
         dform.applyLocalizedPattern(pattern);
+        super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+        super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+        super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+        super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
     }
 
     /**
@@ -650,6 +654,10 @@ public class DecimalFormat extends Numbe
     public void applyPattern(String pattern) {
 
         dform.applyPattern(pattern);
+        super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+        super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+        super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+        super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java Wed Jun 23 12:58:28 2010
@@ -751,6 +751,15 @@ public class DecimalFormatTest extends T
         assertEquals("Wrong pattern 3", "#", format.toPattern());
         format = new DecimalFormat(".#");
         assertEquals("Wrong pattern 4", "#.0", format.toPattern());
+        // Regression for HARMONY-6485
+        format = new DecimalFormat();
+        format.setMinimumIntegerDigits(0);
+        format.setMinimumFractionDigits(0);
+        format.setMaximumFractionDigits(0);
+        format.applyPattern("00.0#");
+        assertEquals("Minimum integer digits not set", 2, format.getMinimumIntegerDigits());
+        assertEquals("Minimum fraction digits not set", 1, format.getMinimumFractionDigits());
+        assertEquals("Maximum fraction digits not set", 2, format.getMaximumFractionDigits());
     }
 
     /**

Propchange: harmony/enhanced/java/branches/mrh/common_resources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 23 12:58:28 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh/common_resources:935751
-/harmony/enhanced/java/trunk/common_resources:935751-951343
+/harmony/enhanced/java/trunk/common_resources:935751-956455
 /harmony/enhanced/trunk/common_resources:476395-921782
 /incubator/harmony/enhanced/trunk/common_resources:292550-476394

Modified: harmony/enhanced/java/branches/mrh/debian/rules
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/debian/rules?rev=957178&r1=957177&r2=957178&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/debian/rules (original)
+++ harmony/enhanced/java/branches/mrh/debian/rules Wed Jun 23 12:58:28 2010
@@ -10,9 +10,7 @@
 # Modified to make a template file for a multi-binary package with separated
 # build-arch and build-indep targets  by Bill Allombert 2001
 
-# -lib /usr/share/java ensures that ant finds ecj.jar, etc
-ANT_FLAGS = -lib /usr/share/java \
-            -Dhy.local.zlib=true -Dhy.zip.api=false   \
+ANT_FLAGS = -Dhy.local.zlib=true -Dhy.zip.api=false   \
             -Dhy.no.thr=false -Dauto.fetch=true
 VMDIR=$(CURDIR)/debian/harmony-5.0-drlvm
 CLDIR=$(CURDIR)/debian/harmony-5.0-classlib
@@ -28,7 +26,7 @@ export DH_OPTIONS
 
 
 
-CFLAGS = -Wall -g
+CFLAGS = -g
 
 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
 	CFLAGS += -O0
@@ -104,6 +102,13 @@ install-arch:
 	-rm -rf $(CLDIR)/usr/lib/harmony-5.0/jdk/jre
 	mv $(CURDIR)/target/hdk/jdk/jre $(CLDIR)/usr/lib/harmony-5.0/jdk
 
+	# move *-src.jar back out so they end up in the jdk
+	mkdir -p $(CURDIR)/target/hdk/jdk/jre/lib/boot
+	mv $(CLDIR)/usr/lib/harmony-5.0/jdk/jre/lib/boot/*-src.jar \
+	   $(CURDIR)/target/hdk/jdk/jre/lib/boot
+	mv $(CLDIR)/usr/lib/harmony-5.0/jdk/jre/lib/*-src.jar \
+	   $(CURDIR)/target/hdk/jdk/jre/lib
+
 	mkdir -p $(JREDIR)/usr/lib/harmony-5.0/jdk/jre/bin
 	mv $(CLDIR)/usr/lib/harmony-5.0/jdk/jre/bin/java \
 	   $(JREDIR)/usr/lib/harmony-5.0/jdk/jre/bin

Propchange: harmony/enhanced/java/branches/mrh/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 23 12:58:28 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751
-/harmony/enhanced/java/trunk/drlvm:935751-951343
+/harmony/enhanced/java/trunk/drlvm:935751-956455
 /harmony/enhanced/trunk/drlvm:476395-926313
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/working_vm:423974-476394