harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r957214 [1/2] - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/beans/src/main/java/java/beans/ classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ classlib/modules/...
Date Wed, 23 Jun 2010 14:25:38 GMT
Author: hindessm
Date: Wed Jun 23 14:25:36 2010
New Revision: 957214

URL: http://svn.apache.org/viewvc?rev=957214&view=rev
Log:
Merge changes from trunk@956455

Added:
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/spi/ImageReaderSpiTest.java
      - copied unchanged from r956455, harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ImageReaderSpiTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerParseLargeFileBenchmarkTest.java
      - copied unchanged from r956455, harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerParseLargeFileBenchmarkTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/resources/org/apache/harmony/luni/tests/java/net/url-test.jar
      - copied unchanged from r956455, harmony/enhanced/java/trunk/classlib/modules/luni/src/test/resources/org/apache/harmony/luni/tests/java/net/url-test.jar
Modified:
    harmony/enhanced/java/branches/java6/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/depends/libs/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIOServiceProvider.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageInputStreamSpi.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageOutputStreamSpi.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/InputStreamReader.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/PrintStream.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/lang/String.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLClassLoader.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLStreamHandler.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/util/Scanner.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnectionImpl.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PrintStreamTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/JarURLConnectionTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/math/src/main/java/java/math/BigInteger.java
    harmony/enhanced/java/branches/java6/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerModPowTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c
    harmony/enhanced/java/branches/java6/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java
    harmony/enhanced/java/branches/java6/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java
    harmony/enhanced/java/branches/java6/common_resources/   (props changed)
    harmony/enhanced/java/branches/java6/drlvm/   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/   (props changed)

Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 23 14:25:36 2010
@@ -1,3 +1,3 @@
 /harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-953280
+/harmony/enhanced/java/trunk:929253-956455
 /harmony/enhanced/trunk:810871-929252

Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 23 14:25:36 2010
@@ -1,7 +1,7 @@
 /harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
 /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
 /harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-953280
+/harmony/enhanced/java/trunk/classlib:929253-956455
 /harmony/enhanced/trunk/classlib:476395-929252
 /harmony/enhanced/trunk/working_classlib:476396-920147
 /incubator/harmony/enhanced/trunk/working_classlib:423974-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 23 14:25:36 2010
@@ -1,3 +1,3 @@
 /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-953280
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-956455
 /harmony/enhanced/trunk/classlib/depends/libs:476395-929252

Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java Wed Jun 23 14:25:36 2010
@@ -294,25 +294,21 @@ public class DefaultPersistenceDelegate 
      */
     @Override
     protected boolean mutatesTo(Object o1, Object o2) {
-        if (null == o1 || null == o2) {
-            return false;
-        }
-        Class<? extends Object> c = o1.getClass();
         if (this.propertyNames.length > 0) {
+            Class<?> clazz = o1.getClass();
             // Check the "equals" method has been declared
             Method equalMethod = null;
             try {
-                equalMethod = c.getDeclaredMethod("equals", //$NON-NLS-1$
+                equalMethod = clazz.getDeclaredMethod("equals", //$NON-NLS-1$
                         new Class[] { Object.class });
-            } catch (NoSuchMethodException ex) {
-                // ignore
+            } catch (NoSuchMethodException e) {
+                // Ignored
             }
 
             if (null != equalMethod) {
                 return o1.equals(o2);
             }
         }
-
         return super.mutatesTo(o1, o2);
     }
 }
\ No newline at end of file

Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java Wed Jun 23 14:25:36 2010
@@ -828,6 +828,45 @@ public class DefaultPersistenceDelegateT
         pd.writeObject(ia, enc);
     }
 
+    class MockDefaultPersistenceDelegate extends DefaultPersistenceDelegate {
+        public MockDefaultPersistenceDelegate(String[] args) {
+            super(args);
+        }
+
+        public boolean mockMutatesTo(Object obj1, Object obj2) {
+            return mutatesTo(obj1, obj2);
+        }
+    }
+
+    public void test_MutatesTo_scenario1() throws Exception {
+        MockDefaultPersistenceDelegate mockDPD = new MockDefaultPersistenceDelegate(
+                new String[1]);
+        try {
+            mockDPD.mockMutatesTo((Object) null, (Object) null);
+            fail("should throw NPE");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        try {
+            mockDPD.mockMutatesTo((Object) null, (Object) "");
+            fail("should throw NPE");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        assertFalse(mockDPD.mockMutatesTo((Object) "", (Object) null));
+    }
+
+    public void test_MutatesTo_scenario2() throws Exception {
+        MockDefaultPersistenceDelegate mockDPD = new MockDefaultPersistenceDelegate(
+                new String[0]);
+        assertFalse(mockDPD.mockMutatesTo((Object) null, (Object) null));
+        assertFalse(mockDPD.mockMutatesTo((Object) null, (Object) ""));
+        assertFalse(mockDPD.mockMutatesTo((Object) "", (Object) null));
+        assertTrue(mockDPD.mockMutatesTo((Object) "", (Object) ""));
+    }
+
     /*
      * BeanInfo for the MockBean below.
      */

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java Wed Jun 23 14:25:36 2010
@@ -30,6 +30,7 @@ import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Arrays;
+import java.util.List;
 import java.awt.image.BufferedImage;
 import java.awt.image.RenderedImage;
 import java.net.URL;
@@ -38,7 +39,8 @@ import org.apache.harmony.x.imageio.inte
 public final class ImageIO {
 
     private static final IIORegistry registry = IIORegistry.getDefaultInstance();
-
+    private static final Cache cacheInfo =  new Cache();
+    
     private ImageIO() {}
     
 
@@ -47,24 +49,20 @@ public final class ImageIO {
         throw new NotImplementedException();
     }
 
-    public static void setUseCache(boolean useCache) throws NotImplementedException {
-        // TODO: implement
+    public static void setUseCache(boolean useCache) {
+        cacheInfo.setUseCache(useCache);
     }
 
-    public static boolean getUseCache()  throws NotImplementedException {
-        // TODO: implement
-        return false;
+    public static boolean getUseCache() {
+        return cacheInfo.getUseCache();
     }
 
-    public static void setCacheDirectory(File cacheDirectory) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public static void setCacheDirectory(File cacheDirectory) {
+        cacheInfo.setCacheDirectory(cacheDirectory);
     }
 
-    public static File getCacheDirectory() throws NotImplementedException {
-        // TODO: implement
-        //-- null indicates system-dep default temporary directory
-        return null;
+    public static File getCacheDirectory() {
+        return cacheInfo.getCacheDirectory();
     }
 
     public static ImageInputStream createImageInputStream(Object input)
@@ -104,7 +102,7 @@ public final class ImageIO {
     }
 
     public static String[] getReaderFormatNames() {
-        ArrayList<String> FormatNames = new ArrayList<String>();
+        List<String> FormatNames = new ArrayList<String>();
 
         Iterator<ImageReaderSpi> it = registry.getServiceProviders(ImageReaderSpi.class, true);
         while (it.hasNext()) {
@@ -116,7 +114,7 @@ public final class ImageIO {
     }
 
     public static String[] getReaderMIMETypes() {
-        ArrayList<String> MIMETypes = new ArrayList<String>();
+        List<String> MIMETypes = new ArrayList<String>();
 
         Iterator<ImageReaderSpi> it = registry.getServiceProviders(ImageReaderSpi.class, true);
         while (it.hasNext()) {
@@ -413,6 +411,46 @@ public final class ImageIO {
         return rt;
     }
 
+    private static class Cache {
+        private boolean useCache = true;
+        private File cacheDirectory = null;
+        
+        public Cache() {
+        }
+    	
+        public File getCacheDirectory() {
+            return cacheDirectory;
+        }
+    	
+        public void setCacheDirectory(File cacheDirectory) {
+            if ((cacheDirectory != null) && (!cacheDirectory.isDirectory())) {
+                throw new IllegalArgumentException(Messages.getString("imageio.0B"));
+            }
+            
+            SecurityManager security = System.getSecurityManager();
+            if (security != null) {
+                String filepath;
+                
+                if (cacheDirectory == null) {
+                    filepath = System.getProperty("java.io.tmpdir");
+                } else {
+                    filepath = cacheDirectory.getPath();
+                }
+                
+                security.checkWrite(filepath);
+            }
+            
+            this.cacheDirectory = cacheDirectory;
+        }
+        
+        public boolean getUseCache() {
+            return useCache;
+        }
+        
+        public void setUseCache(boolean useCache) {
+            this.useCache = useCache;
+        }
+    }
 
     /**
      * Filter to match spi by format name

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIOServiceProvider.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIOServiceProvider.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIOServiceProvider.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIOServiceProvider.java Wed Jun 23 14:25:36 2010
@@ -21,7 +21,6 @@ package javax.imageio.spi;
 
 import java.util.Locale;
 
-import org.apache.harmony.luni.util.NotImplementedException;
 import org.apache.harmony.x.imageio.internal.nls.Messages;
 
 public abstract class IIOServiceProvider implements RegisterableService {
@@ -40,18 +39,16 @@ public abstract class IIOServiceProvider
         this.version = version;
     }
 
-    public IIOServiceProvider() throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public IIOServiceProvider() {
+        // the default impl. does nothing
     }
 
     public void onRegistration(ServiceRegistry registry, Class<?> category) {
         // the default impl. does nothing
     }
 
-    public void onDeregistration(ServiceRegistry registry, Class<?> category) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public void onDeregistration(ServiceRegistry registry, Class<?> category) {
+        // the default impl. does nothing
     }
 
     public String getVendorName() {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageInputStreamSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageInputStreamSpi.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageInputStreamSpi.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageInputStreamSpi.java Wed Jun 23 14:25:36 2010
@@ -23,15 +23,12 @@ import java.io.File;
 import java.io.IOException;
 import javax.imageio.stream.ImageInputStream;
 
-import org.apache.harmony.luni.util.NotImplementedException;
-
 public abstract class ImageInputStreamSpi extends IIOServiceProvider implements
         RegisterableService {
     protected Class<?> inputClass;
 
-    protected ImageInputStreamSpi() throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    protected ImageInputStreamSpi() {
+        // the default impl. does nothing
     }
 
     public ImageInputStreamSpi(String vendorName, String version, Class<?> inputClass) {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageOutputStreamSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageOutputStreamSpi.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageOutputStreamSpi.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageOutputStreamSpi.java Wed Jun 23 14:25:36 2010
@@ -21,8 +21,6 @@ package javax.imageio.spi;
 
 import javax.imageio.stream.ImageOutputStream;
 
-import org.apache.harmony.luni.util.NotImplementedException;
-
 import java.io.IOException;
 import java.io.File;
 
@@ -30,9 +28,8 @@ public abstract class ImageOutputStreamS
         RegisterableService {
     protected Class<?> outputClass;
 
-    protected ImageOutputStreamSpi() throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    protected ImageOutputStreamSpi() {
+        // the default impl. does nothing
     }
 
     public ImageOutputStreamSpi(String vendorName, String version, Class<?> outputClass) {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java Wed Jun 23 14:25:36 2010
@@ -22,8 +22,6 @@ package javax.imageio.spi;
 import javax.imageio.stream.ImageInputStream;
 import javax.imageio.ImageReader;
 
-import org.apache.harmony.luni.util.NotImplementedException;
-
 import java.io.IOException;
 import org.apache.harmony.x.imageio.internal.nls.Messages;
 
@@ -34,9 +32,8 @@ public abstract class ImageReaderSpi ext
     protected Class[] inputTypes;
     protected String[] writerSpiNames;
 
-    protected ImageReaderSpi() throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    protected ImageReaderSpi() {
+        // the default impl. does nothing 
     }
 
     public ImageReaderSpi(String vendorName, String version, String[] names, String[] suffixes,
@@ -78,9 +75,12 @@ public abstract class ImageReaderSpi ext
 
     public abstract ImageReader createReaderInstance(Object extension) throws IOException;
 
-    public boolean isOwnReader(ImageReader reader) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public boolean isOwnReader(ImageReader reader) {
+        if (reader == null) {
+            throw new IllegalArgumentException(Messages.getString("imageio.97"));
+        }
+        
+        return reader.getClass().getName().equals(pluginClassName);
     }
 
     public String[] getImageWriterSpiNames() {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageWriterSpi.java Wed Jun 23 14:25:36 2010
@@ -23,8 +23,6 @@ import javax.imageio.stream.ImageInputSt
 import javax.imageio.ImageTypeSpecifier;
 import javax.imageio.ImageWriter;
 
-import org.apache.harmony.luni.util.NotImplementedException;
-
 import java.awt.image.RenderedImage;
 import java.io.IOException;
 import org.apache.harmony.x.imageio.internal.nls.Messages;
@@ -36,9 +34,8 @@ public abstract class ImageWriterSpi ext
     protected Class[] outputTypes;
     protected String[] readerSpiNames;
 
-    protected ImageWriterSpi() throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    protected ImageWriterSpi() {
+        // the default impl. does nothing
     }
 
     public ImageWriterSpi(String vendorName, String version, String[] names,
@@ -90,9 +87,12 @@ public abstract class ImageWriterSpi ext
 
     public abstract ImageWriter createWriterInstance(Object extension) throws IOException;
 
-    public boolean isOwnWriter(ImageWriter writer) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public boolean isOwnWriter(ImageWriter writer) {
+        if (writer == null) {
+            throw new IllegalArgumentException(Messages.getString("imageio.96"));
+        }
+        
+        return writer.getClass().getName().equals(pluginClassName);
     }
 
     public String[] getImageReaderSpiNames() {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java Wed Jun 23 14:25:36 2010
@@ -65,24 +65,22 @@ public class ServiceRegistry {
         categories.addProvider(provider, null);
     }
 
-    public <T> boolean deregisterServiceProvider(T provider, Class<T> category) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public <T> boolean deregisterServiceProvider(T provider, Class<T> category) {
+        return categories.removeProvider(provider, category);
     }
 
-    public void deregisterServiceProvider(Object provider) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public void deregisterServiceProvider(Object provider) {
+        categories.removeProvider(provider);
     }
 
-    @SuppressWarnings("unchecked")
+//    @SuppressWarnings("unchecked")
     public <T> Iterator<T> getServiceProviders(Class<T> category, Filter filter, boolean useOrdering) {
-        return new FilteredIterator<T>(filter, (Iterator<T>)categories.getProviders(category, useOrdering));
+        return new FilteredIterator<T>(filter, (Iterator<T>) categories.getProviders(category, useOrdering));
     }
 
-    @SuppressWarnings("unchecked")
+//    @SuppressWarnings("unchecked")
     public <T> Iterator<T> getServiceProviders(Class<T> category, boolean useOrdering) {
-        return (Iterator<T>)categories.getProviders(category, useOrdering);
+        return (Iterator<T>) categories.getProviders(category, useOrdering);
     }
 
     public <T> T getServiceProviderByClass(Class<T> providerClass) throws NotImplementedException {
@@ -90,24 +88,20 @@ public class ServiceRegistry {
         throw new NotImplementedException();
     }
 
-    public <T> boolean setOrdering(Class<T> category, T firstProvider, T secondProvider) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public <T> boolean setOrdering(Class<T> category, T firstProvider, T secondProvider) {
+        return categories.setOrdering(category, firstProvider, secondProvider);
     }
 
-    public <T> boolean unsetOrdering(Class<T> category, T firstProvider, T secondProvider) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public <T> boolean unsetOrdering(Class<T> category, T firstProvider, T secondProvider) {
+        return categories.unsetOrdering(category, firstProvider, secondProvider);
     }
 
-    public void deregisterAll(Class<?> category) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public void deregisterAll(Class<?> category) {
+        categories.removeAll(category);
     }
 
-    public void deregisterAll() throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public void deregisterAll() {
+        categories.removeAll();
     }
 
     @Override
@@ -116,9 +110,12 @@ public class ServiceRegistry {
         //deregisterAll();
     }
 
-    public boolean contains(Object provider) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public boolean contains(Object provider) {
+        if (provider == null) {
+            throw new IllegalArgumentException(Messages.getString("imageio.5E"));
+        }
+        
+        return categories.contains(provider);
     }
 
     public Iterator<Class<?>> getCategories() {
@@ -138,6 +135,37 @@ public class ServiceRegistry {
             this.registry = registry;
         }
 
+        boolean contains(Object provider) {
+            for (Map.Entry<Class<?>, ProvidersMap> e : categories.entrySet()) {
+                ProvidersMap providers = e.getValue();
+                if (providers.contains(provider)) {
+                    return true;
+                }
+            }
+            
+            return false;
+        }
+
+        <T> boolean setOrdering(Class<T> category, T firstProvider, T secondProvider) {
+            ProvidersMap providers = categories.get(category);
+            
+            if (providers == null) {
+                throw new IllegalArgumentException(Messages.getString("imageio.92", category));
+            }
+            
+            return providers.setOrdering(firstProvider, secondProvider);
+        }
+        
+        <T> boolean unsetOrdering(Class<T> category, T firstProvider, T secondProvider) {
+            ProvidersMap providers = categories.get(category);
+            
+            if (providers == null) {
+                throw new IllegalArgumentException(Messages.getString("imageio.92", category));
+            }
+            
+            return providers.unsetOrdering(firstProvider, secondProvider);
+        }
+        
         //-- TODO: useOrdering
         Iterator<?> getProviders(Class<?> category, boolean useOrdering) {
             ProvidersMap providers = categories.get(category);
@@ -183,6 +211,9 @@ public class ServiceRegistry {
         }
 
         private boolean addToNamed(Object provider, Class<?> category) {
+            if (!category.isAssignableFrom(provider.getClass())) {
+                throw new ClassCastException();
+            }
             Object obj = categories.get(category);
 
             if (null == obj) {
@@ -201,25 +232,167 @@ public class ServiceRegistry {
             }
             return rt;
         }
+        
+        boolean removeProvider(Object provider, Class<?> category) {
+            if (provider == null) {
+                throw new IllegalArgumentException(Messages.getString("imageio.5E"));
+            }
+            
+            if (!category.isAssignableFrom(provider.getClass())) {
+                throw new ClassCastException();
+            }
+            
+            Object obj = categories.get(category);
+            
+            if (obj == null) {
+                throw new IllegalArgumentException(Messages.getString("imageio.92", category));
+            }
+            
+            return ((ProvidersMap) obj).removeProvider(provider, registry, category);
+        }
+        
+        void removeProvider(Object provider) {
+            if (provider == null) {
+                throw new IllegalArgumentException(Messages.getString("imageio.5E"));
+            }
+            
+            for (Entry<Class<?>, ProvidersMap> e : categories.entrySet()) {
+                ProvidersMap providers = e.getValue();
+                providers.removeProvider(provider, registry, e.getKey());
+            }
+        }
+        
+        void removeAll(Class<?> category) {
+            Object obj = categories.get(category);
+            
+            if (obj == null) {
+                throw new IllegalArgumentException(Messages.getString("imageio.92", category));
+            }
+            
+            ((ProvidersMap) obj).clear(registry);         
+        }
+        
+        void removeAll() {
+            for ( Map.Entry<Class<?>, ProvidersMap> e : categories.entrySet()) {
+                removeAll(e.getKey());                
+            }
+        }
     }
 
     private static class ProvidersMap {
-        //-- TODO: providers ordering support
 
         Map<Class<?>, Object> providers = new HashMap<Class<?>, Object>();
+        Map<Object, ProviderNode> nodeMap = new HashMap<Object, ProviderNode>();
 
         boolean addProvider(Object provider) {
-            return providers.put(provider.getClass(), provider) == null;
+            ProviderNode node =  new ProviderNode(provider);
+            nodeMap.put(provider, node);
+            Object obj = providers.put(provider.getClass(), provider);
+            
+            if (obj !=  null) {
+                nodeMap.remove(obj);
+                return false;
+            }
+            
+            return true;
+        }
+
+        boolean contains(Object provider) {
+            return providers.containsValue(provider);
+        }
+
+        boolean removeProvider(Object provider,
+                ServiceRegistry registry, Class<?> category) {
+            
+            Object obj = providers.get(provider.getClass());
+            if ((obj == null) || (obj != provider)) {
+                return false;
+            }
+            
+            providers.remove(provider.getClass());
+            nodeMap.remove(provider);
+            
+            if (provider instanceof RegisterableService) {
+                ((RegisterableService) provider).onDeregistration(registry, category);
+            }            
+            
+            return true;
+        }
+        
+        void clear(ServiceRegistry registry) {
+            for (Map.Entry<Class<?>, Object> e : providers.entrySet()) {
+                Object provider = e.getValue();
+                
+                if (provider instanceof RegisterableService) {
+                    ((RegisterableService) provider).onDeregistration(registry, e.getKey());
+                }
+            }
+            
+            providers.clear();
+            nodeMap.clear();
         }
 
         Iterator<Class<?>> getProviderClasses() {
             return providers.keySet().iterator();
         }
 
-        //-- TODO ordering
-        Iterator<?> getProviders(boolean userOrdering) {
+        Iterator<?> getProviders(boolean useOrdering) {
+            if (useOrdering) {
+                return new OrderedProviderIterator(nodeMap.values().iterator());              
+            }
+            
             return providers.values().iterator();
         }
+        
+        public <T> boolean setOrdering(T firstProvider, T secondProvider) {
+            if (firstProvider == secondProvider) {
+                throw new IllegalArgumentException(Messages.getString("imageio.98"));
+            }
+            
+            if ((firstProvider == null) || (secondProvider == null)) {
+                throw new IllegalArgumentException(Messages.getString("imageio.5E"));
+            }
+           
+            ProviderNode firstNode = nodeMap.get(firstProvider);
+            ProviderNode secondNode = nodeMap.get(secondProvider);
+                    
+            // if the ordering is already set, return false
+            if ((firstNode == null) || (firstNode.contains(secondNode))) {
+                return false;
+            }
+            
+            // put secondProvider into firstProvider's outgoing nodes list
+            firstNode.addOutEdge(secondNode);
+            // increase secondNode's incoming edge by 1
+            secondNode.addInEdge();         
+            
+            return true;
+        }
+        
+        public <T> boolean unsetOrdering(T firstProvider, T secondProvider) {
+            if (firstProvider == secondProvider) {
+                throw new IllegalArgumentException(Messages.getString("imageio.98"));
+            }
+            
+            if ((firstProvider == null) || (secondProvider == null)) {
+                throw new IllegalArgumentException(Messages.getString("imageio.5E"));
+            }
+            
+            ProviderNode firstNode = nodeMap.get(firstProvider);
+            ProviderNode secondNode = nodeMap.get(secondProvider); 
+                    
+            // if the ordering is not set, return false
+            if ((firstNode == null) || (!firstNode.contains(secondNode))) {
+                return false;
+            }
+                    
+            // remove secondProvider from firstProvider's outgoing nodes list
+            firstNode.removeOutEdge(secondNode);
+            // decrease secondNode's incoming edge by 1
+            secondNode.removeInEdge();
+                    
+            return true;            
+        }
     }
 
     private static class FilteredIterator<E> implements Iterator<E> {
@@ -265,4 +438,116 @@ public class ServiceRegistry {
             }
         }
     }
+    
+    private static class ProviderNode {
+        // number of incoming edges
+        private int incomingEdges;  
+        // all outgoing nodes
+        private Set<Object> outgoingNodes; 
+        private Object provider;
+                
+        public ProviderNode(Object provider) {
+            incomingEdges = 0;
+            outgoingNodes = new HashSet<Object>();
+            this.provider = provider;
+        }
+            
+        public Object getProvider() {
+            return provider;
+        }
+        
+        public Iterator<Object> getOutgoingNodes() {
+            return outgoingNodes.iterator();
+        }
+        
+        public boolean addOutEdge(Object secondProvider) {
+            return outgoingNodes.add(secondProvider);
+        }
+        
+        public <T> boolean removeOutEdge(Object provider) {
+            return outgoingNodes.remove(provider);
+        }
+        
+        public void addInEdge() {
+            incomingEdges++;
+        }
+        
+        public void removeInEdge() {
+            incomingEdges--;
+        }
+        
+        public int getIncomingEdges() {
+            return incomingEdges;
+        }
+        
+        public boolean contains(Object provider) {
+            return outgoingNodes.contains(provider);
+        }
+    }
+
+    /**
+     * The iterator implements Kahn topological sorting algorithm.
+     * @see <a href="http://en.wikipedia.org/wiki/Topological_sorting">Wikipedia</a>
+     * for further reference.
+     */
+    private static class OrderedProviderIterator implements Iterator {
+
+        // the stack contains nodes which has no lesser nodes
+        // except those already returned by the iterator
+        private Stack<ProviderNode> firstNodes = new Stack<ProviderNode>();
+
+        // a dynamic counter of incoming nodes
+        // when a node is returned by iterator, the counters for connected
+        // nodes decrement
+        private Map<ProviderNode, Integer> incomingEdges = new HashMap<ProviderNode, Integer>();
+        
+        public OrderedProviderIterator(Iterator it) {
+            // find all the nodes that with no incoming edges and
+            // add them to firstNodes
+            while (it.hasNext()) {
+                ProviderNode node = (ProviderNode) it.next();
+                incomingEdges.put(node, new Integer(node.getIncomingEdges()));
+                if (node.getIncomingEdges() == 0) {
+                    firstNodes.push(node);
+                }
+            }
+        }
+            
+        public boolean hasNext() {
+            return !firstNodes.empty();
+        }
+
+        public Object next() {
+            if (firstNodes.empty()) {
+               throw new NoSuchElementException();
+            }
+                            
+            // get a node from firstNodes
+            ProviderNode node = firstNodes.pop();
+                            
+            // find all the outgoing nodes
+            Iterator it = node.getOutgoingNodes();
+            while (it.hasNext()) {
+                ProviderNode outNode = (ProviderNode) it.next();
+                
+                // remove the incoming edge from the node.
+                int edges = incomingEdges.get(outNode);
+                edges--;
+                incomingEdges.put(outNode, new Integer(edges));
+                
+                // add to the firstNodes if this node's incoming edge is equal to 0
+                if (edges == 0) {
+                    firstNodes.push(outNode);
+                }
+            }
+            
+            incomingEdges.remove(node);
+                            
+            return node.getProvider();
+        }
+        
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+    }
 }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties Wed Jun 23 14:25:36 2010
@@ -100,7 +100,7 @@ imageio.52=input == null!
 imageio.53=image cannot be NULL
 imageio.54=output cannot be NULL
 imageio.55=MIMEType cannot be NULL
-imageio.56=Use deregisterServiceprovider instead of Iterator.remove()
+imageio.56=Use deregisterServiceProvider instead of Iterator.remove()
 imageio.57=format names array cannot be NULL or empty
 imageio.58=Plugin class name cannot be NULL
 imageio.59=output types array cannot be NULL or empty
@@ -108,7 +108,7 @@ imageio.5A=vendor name cannot be NULL
 imageio.5B=version name cannot be NULL
 imageio.5C=input types array cannot be NULL or empty
 imageio.5D=categories iterator should not be NULL
-imageio.5E=provider should be != NULL
+imageio.5E=Provider should be != NULL
 imageio.5F=raster should not be NULL
 imageio.60=no thumbnails were set
 imageio.61=newChild == null!
@@ -166,4 +166,5 @@ imageio.94=Output {0} is not supported
 imageio.95=Input is not an instance of java.io.RandomAccessFile
 imageio.96=Writer cannot be null
 imageio.97=Reader cannot be null
+imageio.98=Ordered providers cannot be equal
 

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java Wed Jun 23 14:25:36 2010
@@ -70,7 +70,7 @@ public class PNGImageWriter extends Imag
     private native int encode(byte[] input, int bytesInBuffer, int bytePixelSize, Object ios, int imageWidth,
             int imageHeight, int bitDepth, int colorType, int[] palette, int i, boolean b);
 
-    protected PNGImageWriter(ImageWriterSpi iwSpi) {
+    public PNGImageWriter(ImageWriterSpi iwSpi) {
         super(iwSpi);
     }
 

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java Wed Jun 23 14:25:36 2010
@@ -17,9 +17,15 @@
 
 package javax.imageio;
 
+import java.io.File;
 import java.net.URL;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import junit.framework.TestCase;
 
@@ -45,4 +51,98 @@ public class ImageIOTest extends TestCas
 
         return img;
     }
+    
+    public void testCache() throws Exception {
+        ImageIO.setUseCache(true);
+        assertTrue("Failed to enable cache", ImageIO.getUseCache());
+        ImageIO.setUseCache(false);
+        assertFalse("Failed to disable cache", ImageIO.getUseCache());
+        
+        ImageIO.setCacheDirectory(null);
+        assertNull("Failed to set cache directory", ImageIO.getCacheDirectory());
+        
+        try {
+            ImageIO.setCacheDirectory(new File(""));
+            fail("IllegalArgumentException expected");
+        } 
+        catch (IllegalArgumentException expected) {
+            //OK
+        }
+    }
+
+    private void testFormat(String format) {
+        ImageReader reader = ImageIO.getImageReadersByFormatName(format).next();
+        ImageWriter writer = ImageIO.getImageWritersByFormatName(format).next();
+
+        assertEquals("getImageReader() returns an incorrect reader for " + format,
+            ImageIO.getImageReader(writer).getClass(), reader.getClass());
+        assertEquals("getImageWriter() returns an incorrect writer for " + format,
+            ImageIO.getImageWriter(reader).getClass(), writer.getClass());
+    }
+    
+    // assume we have exactly one reader/writer pair
+    public void testGetJpegReaderWriter() throws Exception {
+        testFormat("jpeg");
+    }
+
+    // assume we have exactly one reader/writer pair
+    public void testGetPngReaderWriter() throws Exception {
+        testFormat("png");
+    }
+ 	
+    // GIF has no writer
+    // public void testGetGifReaderWriter() throws Exception {
+    //     testFormat("gif");
+    // }
+
+    public void testGetNullReaderWriter() throws Exception {
+    	try {
+            ImageIO.getImageWriter(null);
+            fail("Expected IllegalArgumentException");
+        }
+        catch (IllegalArgumentException expected) {
+            // Ok
+        }
+
+        try {
+            ImageIO.getImageReader(null);
+            fail("Expected IllegalArgumentException");
+        }
+        catch (IllegalArgumentException expected) {
+            // Ok
+        }
+    }
+        
+    public void testGetReaderMIMETypes() {
+        Set<String> expectedMIMETypes = new HashSet<String>(Arrays.asList(new String[] {
+            "image/gif", "image/x-png", "image/png", "image/jpeg" } ));
+        
+        Set<String> actualMIMETypes = new HashSet<String>(Arrays.asList(ImageIO.getReaderMIMETypes()));
+        assertTrue(actualMIMETypes.containsAll(expectedMIMETypes));
+    }
+    
+    public void testGetWriterMIMETypes() {
+        Set<String> expectedMIMETypes = new HashSet<String>(Arrays.asList(new String[] {
+            "image/x-png", "image/png", "image/jpeg" } ));
+        
+        Set<String> actualMIMETypes = new HashSet<String>(Arrays.asList(ImageIO.getWriterMIMETypes()));
+        assertTrue(actualMIMETypes.containsAll(expectedMIMETypes));
+    }
+    
+    public void testGetReaderFormatNames() {
+        Set<String> expectedFormatNames = new HashSet<String>(Arrays.asList(new String[] {
+            "JPG", "jpg", "GIF", "gif", "JPEG", "jpeg", "PNG", "png" } ));
+        
+        Set<String> actualFormatNames = new HashSet<String>(Arrays.asList(ImageIO.getReaderFormatNames()));
+        assertTrue(actualFormatNames.containsAll(expectedFormatNames));
+    }
+    
+    public void testGetWriterFormatNames() {
+        Set<String> expectedFormatNames = new HashSet<String>(Arrays.asList(new String[] {
+            "JPG", "jpg", "JPEG", "jpeg", "PNG", "png" } ));
+        
+        Set<String> actualFormatNames = new HashSet<String>(Arrays.asList(ImageIO.getWriterFormatNames()));
+        assertTrue(actualFormatNames.containsAll(expectedFormatNames));
+    }
+
 }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java Wed Jun 23 14:25:36 2010
@@ -18,16 +18,138 @@
 package javax.imageio.spi;
 
 import java.util.Arrays;
+import java.util.Iterator;
 import java.util.Locale;
 
 import junit.framework.TestCase;
 
 import javax.imageio.ImageReader;
+import javax.imageio.ImageWriter;
+import javax.imageio.ImageTypeSpecifier;
 import javax.imageio.spi.ImageReaderSpi;
 import javax.imageio.spi.ImageWriterSpi;
 
 public class ServiceRegistryTest extends TestCase {
+
+    public void testDeregisterAll() {
+        Class[] CATEGORIES = new Class[] {
+                ImageReaderSpi.class };
+        
+        ServiceRegistry registry = new ServiceRegistry(Arrays.<Class<?>> asList(CATEGORIES).iterator());
+        
+        ImageReaderSpi reader1 = new Reader1Spi();
+        ImageReaderSpi reader2 = new Reader2Spi();
+        
+        // Register two providers
+        registry.registerServiceProvider(reader1, CATEGORIES[0]);
+        registry.registerServiceProvider(reader2, CATEGORIES[0]);
+        
+        registry.deregisterAll(ImageReaderSpi.class);
+        assertFalse("Reader1 is still regitered, deregisterAll(Class) failed",registry.contains(reader1));
+        assertFalse("Reader2 is still regitered, deregisterAll(Class) failed",registry.contains(reader2));
+        
+        // Re-register two providers
+        registry.registerServiceProvider(reader1, CATEGORIES[0]);
+        registry.registerServiceProvider(reader2, CATEGORIES[0]);
+        
+        registry.deregisterAll();
+        assertFalse("Reader1 is still regitered, deregisterAll() failed",registry.contains(reader1));
+        assertFalse("Reader2 is still regitered, deregisterAll() failed",registry.contains(reader2));
+    }
     
+	public void testContains() {
+		Class[] CATEGORIES = new Class[] {
+                ImageReaderSpi.class };
+        
+        ServiceRegistry registry = new ServiceRegistry(Arrays.<Class<?>> asList(CATEGORIES).iterator());
+        
+        ImageReaderSpi reader1 = new SampleImageReaderSpi();
+        ImageReaderSpi reader2 = new SampleImageReaderSpi();
+        
+        registry.registerServiceProvider(reader1, CATEGORIES[0]);
+        
+        assertTrue("Failed to check if reader1 registered", registry.contains(reader1));
+        assertFalse("Failed to check if reader2 registered", registry.contains(reader2));        
+	}
+	
+    public void testGetServiceProviders() {
+        Class[] CATEGORIES = new Class[] {
+                ImageReaderSpi.class };
+        
+        ServiceRegistry registry = new ServiceRegistry(Arrays.<Class<?>> asList(CATEGORIES).iterator());
+        
+        ImageReaderSpi reader = new SampleImageReaderSpi();
+        ImageReaderSpi reader1 = new Reader1Spi();
+        ImageReaderSpi reader2 = new Reader2Spi();
+        
+        // Add 3 different providers to the registry
+        registry.registerServiceProvider(reader, CATEGORIES[0]);
+        registry.registerServiceProvider(reader1, CATEGORIES[0]);
+        registry.registerServiceProvider(reader2, CATEGORIES[0]);
+        
+        // Add a different type of provider to the category
+        ImageWriterSpi writer = new SampleImageWriterSpi();
+        try {
+            registry.registerServiceProvider(writer, CATEGORIES[0]);
+            fail("ClassCastException expected");
+        }
+        catch (ClassCastException expected) {
+            // Ok
+        }
+        
+        // Set ordering between these providers
+        // reader2 > reader1 >  reader
+        assertTrue("Failed to set ordering: reader2 > reader1",
+            registry.setOrdering(CATEGORIES[0], reader2, reader1));
+        assertTrue("Failed to set ordering: reader1 > reader",
+            registry.setOrdering(CATEGORIES[0], reader1, reader));
+        
+        // Return false if this ordering has already been set
+        assertFalse("Failed to check if the ordering reader1 > reader has been set",
+            registry.setOrdering(CATEGORIES[0], reader1, reader));
+        
+        // If two providers are the same
+        try {
+        	registry.setOrdering(CATEGORIES[0], reader, reader);
+        	fail("IllegalArgumentException expected");
+        }
+        catch (IllegalArgumentException expected) {
+            // Ok
+        }
+        
+        // If either provider is null
+        try {
+        	registry.setOrdering(CATEGORIES[0], null, reader);
+        	fail("IllegalArgumentException expected");
+        }
+        catch (IllegalArgumentException expected) {
+            // Ok
+        }
+        
+        // Get the iterator of sorted providers
+        Iterator it = registry.getServiceProviders(CATEGORIES[0], true);
+        
+        // Verify the order
+        assertEquals("Failed to return reader2", it.next(), reader2);
+        assertEquals("Failed to return reader1", it.next(), reader1);
+        assertEquals("Failed to return reader", it.next(), reader);
+        
+        // The iterator should be able to run more than once
+        it = registry.getServiceProviders(CATEGORIES[0], true);
+        
+        // Verify the order
+        assertEquals("Failed to return reader2", it.next(), reader2);
+        assertEquals("Failed to return reader1", it.next(), reader1);
+        assertEquals("Failed to return reader", it.next(), reader);
+
+        // Unset orderings
+        assertTrue("Failed to unset ordering: reader2 > reader1", registry.unsetOrdering(CATEGORIES[0], reader2, reader1));
+        assertTrue("Failed to unset ordering: reader1 > reader", registry.unsetOrdering(CATEGORIES[0], reader1, reader));
+        
+        // Return false if this ordering is not set
+        assertFalse("Failed to check if the ordering is not set", registry.unsetOrdering(CATEGORIES[0], reader2, reader));
+    }
+
     public void testRegistryServiceProvider() throws Exception {
         Class[] CATEGORIES = new Class[] {
                 ImageWriterSpi.class, ImageReaderSpi.class
@@ -43,6 +165,37 @@ public class ServiceRegistryTest extends
         assertFalse("registerServiceProvider() returns incorrect value if a provider of the same class was previously registered",
             registry.registerServiceProvider(spiB, CATEGORIES[1]));
     }
+    
+    @SuppressWarnings("unchecked")
+    public void testDeregisterServiceProvider() throws Exception {
+        Class[] CATEGORIES = new Class[] {
+                javax.imageio.spi.ImageReaderSpi.class,
+                javax.imageio.spi.SampleImageReaderSpi.class};
+
+        ServiceRegistry registry = new ServiceRegistry(Arrays.<Class<?>> asList(CATEGORIES).iterator());
+
+        SampleImageReaderSpi spi = new SampleImageReaderSpi();
+        
+        // Test deregisterServiceProvider(Object, Class)
+        registry.registerServiceProvider(spi, CATEGORIES[0]);
+        
+        assertTrue("deregisterServiceProvider(Object, Class) returns incorrect value for a registered provider ",
+                registry.deregisterServiceProvider(spi, CATEGORIES[0]));
+        
+        assertFalse("deregisterServiceProvider(Object, Class) returns incorrect value for a unregistered provider",
+                registry.deregisterServiceProvider(spi, CATEGORIES[0]));
+        
+        // Test deregisterServiceProvider(Object)
+        registry.registerServiceProvider(spi, CATEGORIES[0]);
+        registry.registerServiceProvider(spi, CATEGORIES[1]);
+
+        registry.deregisterServiceProvider(spi);
+        
+        assertFalse("deregisterServiceProvider(Object) failed to remove all providers",
+                registry.deregisterServiceProvider(spi, CATEGORIES[0]));
+        assertFalse("deregisterServiceProvider(Object) failed to remove all providers",
+                registry.deregisterServiceProvider(spi, CATEGORIES[1]));
+    }
 }
 
 class SampleImageReaderSpi extends ImageReaderSpi {
@@ -66,3 +219,30 @@ class SampleImageReaderSpi extends Image
     }
 }
 
+class Reader1Spi extends SampleImageReaderSpi {
+}
+
+class Reader2Spi extends SampleImageReaderSpi {
+}
+
+class SampleImageWriterSpi extends ImageWriterSpi {
+    SampleImageWriterSpi() {
+        super("sample vendor", "1.0", new String[] { "sample" },
+            null, null, SampleImageReaderSpi.class.getName(),
+            STANDARD_OUTPUT_TYPE, null, false, null, null,
+            null, null, false, null, null, null, null);
+    }
+
+    public boolean canEncodeImage(ImageTypeSpecifier type) {
+        return false;
+    }
+
+    public ImageWriter createWriterInstance(Object extension) {
+        return null;
+    }
+
+    public String getDescription(Locale locale) {
+        return null;
+    }
+}
+

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/InputStreamReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/InputStreamReader.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/InputStreamReader.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/InputStreamReader.java Wed Jun 23 14:25:36 2010
@@ -101,7 +101,7 @@ public class InputStreamReader extends R
                     CodingErrorAction.REPLACE);
         } catch (IllegalArgumentException e) {
             throw (UnsupportedEncodingException)
-                    new UnsupportedEncodingException().initCause(e);
+                    new UnsupportedEncodingException(enc).initCause(e);
         }
         bytes.limit(0);
     }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java Wed Jun 23 14:25:36 2010
@@ -30,13 +30,11 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 
-import org.apache.harmony.misc.accessors.ObjectAccessor;
-import org.apache.harmony.misc.accessors.AccessorFactory;
-
 import org.apache.harmony.kernel.vm.VM;
 import org.apache.harmony.luni.internal.nls.Messages;
-import org.apache.harmony.luni.internal.nls.Messages;
 import org.apache.harmony.luni.util.PriviAction;
+import org.apache.harmony.misc.accessors.AccessorFactory;
+import org.apache.harmony.misc.accessors.ObjectAccessor;
 
 /**
  * A specialized {@link InputStream} that is able to read (deserialize) Java

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/PrintStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/PrintStream.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/PrintStream.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/PrintStream.java Wed Jun 23 14:25:36 2010
@@ -175,7 +175,7 @@ public class PrintStream extends FilterO
             throw new NullPointerException();
         }
         if (!Charset.isSupported(csn)) {
-            throw new UnsupportedEncodingException();
+            throw new UnsupportedEncodingException(csn);
         }
         encoding = csn;
     }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/lang/String.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/lang/String.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/lang/String.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/lang/String.java Wed Jun 23 14:25:36 2010
@@ -1525,12 +1525,15 @@ public final class String implements Ser
         if (start == 0 && end == count) {
             return this;
         }
-        // NOTE last character not copied!
-        // Fast range check.
-        if (0 <= start && start <= end && end <= count) {
-            return new String(offset + start, end - start, value);
+        if (start < 0) {
+            throw new StringIndexOutOfBoundsException(start);
+        } else if (start > end) {
+            throw new StringIndexOutOfBoundsException(end - start);
+        } else if (end > count) {
+            throw new StringIndexOutOfBoundsException(end);
         }
-        throw new StringIndexOutOfBoundsException();
+        // NOTE last character not copied!
+        return new String(offset + start, end - start, value);
     }
 
     /**

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLClassLoader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLClassLoader.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLClassLoader.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLClassLoader.java Wed Jun 23 14:25:36 2010
@@ -664,9 +664,6 @@ public class URLClassLoader extends Secu
      */
     @Override
     public Enumeration<URL> findResources(final String name) throws IOException {
-        if (name == null) {
-            return null;
-        }
         ArrayList<URL> result = AccessController.doPrivileged(
                 new PrivilegedAction<ArrayList<URL>>() {
                     public ArrayList<URL> run() {
@@ -694,6 +691,9 @@ public class URLClassLoader extends Secu
     }
 
     void findResourcesImpl(String name, ArrayList<URL> result) {
+        if (name == null) {
+            return;
+        }
         int n = 0;
         while (true) {
             URLHandler handler = getHandler(n++);

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLStreamHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLStreamHandler.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLStreamHandler.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/URLStreamHandler.java Wed Jun 23 14:25:36 2010
@@ -85,22 +85,19 @@ public abstract class URLStreamHandler {
      * @see URL
      */
     protected void parseURL(URL u, String str, int start, int end) {
-        // For compatibility, refer to Harmony-2941
-        if (str.startsWith("//", start) //$NON-NLS-1$
-                && str.indexOf('/', start + 2) == -1
-                && end <= Integer.MIN_VALUE + 1) {
-            throw new StringIndexOutOfBoundsException(end - 2 - start);
-        }
-        if (end < start) {
+        if (end < start || end < 0) {
+            // Checks to ensure string index exception ahead of
+            // security exception for compatibility.
+            if (end <= Integer.MIN_VALUE + 1 && (start >= str.length() || start < 0)
+                    || str.startsWith("//", start) && str.indexOf('/', start + 2) == -1) { //$NON-NLS-1$
+                throw new StringIndexOutOfBoundsException(end);
+            }
             if (this != u.strmHandler) {
                 throw new SecurityException();
             }
             return;
         }
-        String parseString = ""; //$NON-NLS-1$
-        if (start < end) {
-            parseString = str.substring(start, end);
-        }
+        String parseString = str.substring(start, end);
         end -= start;
         int fileIdx = 0;
 

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/util/Scanner.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/util/Scanner.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/util/Scanner.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/util/Scanner.java Wed Jun 23 14:25:36 2010
@@ -2017,6 +2017,8 @@ public final class Scanner implements It
         return negative;
     }
 
+    private int tokenStart = 0;
+    private int tokenEnd = 0;
     /*
      * Find the prefixed delimiter and posefixed delimiter in the input resource
      * and set the start index and end index of Matcher region. If postfixed
@@ -2031,11 +2033,13 @@ public final class Scanner implements It
         matcher.usePattern(delimiter);
         matcher.region(findStartIndex, bufferLength);
 
-        tokenStartIndex = findPreDelimiter();
-        if (setHeadTokenRegion(tokenStartIndex)) {
+        findPreDelimiter();
+        if (setHeadTokenRegion(tokenStart)) {
             return true;
         }
-        tokenEndIndex = findPostDelimiter();
+        findPostDelimiter();
+        tokenStartIndex = tokenStart;
+        tokenEndIndex = tokenEnd;
         // If the second delimiter is not found
         if (-1 == tokenEndIndex) {
             // Just first Delimiter Exists
@@ -2053,8 +2057,8 @@ public final class Scanner implements It
     /*
      * Find prefix delimiter
      */
-    private int findPreDelimiter() {
-        int tokenStartIndex;
+    private void findPreDelimiter() {
+    	tokenStart = 0;
         boolean findComplete = false;
         while (!findComplete) {
             if (matcher.find()) {
@@ -2074,13 +2078,14 @@ public final class Scanner implements It
                     readMore();
                     resetMatcher();
                 } else {
-                    return -1;
+                    tokenStart = -1;
+                    return;
                 }
             }
         }
-        tokenStartIndex = matcher.end();
+
+        tokenStart = matcher.end();
         findStartIndex = matcher.end();
-        return tokenStartIndex;
     }
 
     /*
@@ -2113,8 +2118,8 @@ public final class Scanner implements It
     /*
      * Find postfix delimiter
      */
-    private int findPostDelimiter() {
-        int tokenEndIndex = 0;
+    private void findPostDelimiter() {
+        tokenEnd = 0;
         boolean findComplete = false;
         while (!findComplete) {
             if (matcher.find()) {
@@ -2128,13 +2133,16 @@ public final class Scanner implements It
                     readMore();
                     resetMatcher();
                 } else {
-                    return -1;
+                    tokenStart = findStartIndex;
+                    tokenEnd = -1;
+                    return;
                 }
             }
         }
-        tokenEndIndex = matcher.start();
+
+        tokenStart = findStartIndex;
+        tokenEnd = matcher.start();
         findStartIndex = matcher.start();
-        return tokenEndIndex;
     }
 
     /*
@@ -2143,13 +2151,12 @@ public final class Scanner implements It
      * true, otherwise set to false.
      */
     private void readMore() {
-        int oldPosition = buffer.position();
-        int oldBufferLength = bufferLength;
         // Increase capacity if empty space is not enough
         if (bufferLength >= buffer.capacity()) {
             expandBuffer();
         }
-
+        int oldPosition = buffer.position();
+        int oldBufferLength = bufferLength;
         // Read input resource
         int readCount = 0;
         try {
@@ -2183,15 +2190,67 @@ public final class Scanner implements It
 
     // Expand the size of internal buffer.
     private void expandBuffer() {
-        int oldPosition = buffer.position();
-        int oldCapacity = buffer.capacity();
+        //inital new indexes values
+        int nFindStartIndex = 0;
+        int nPreStartIndex = 0;
+        int nBufferLength = 0;
+        int nLimit = 0;
+        int nPostion = 0;       
+        int nCachehasNextIndex = 0;
+
+        //store old buffer set
+        int oldLength = bufferLength;
+        int oldPostion = buffer.position();
         int oldLimit = buffer.limit();
-        int newCapacity = oldCapacity * DIPLOID;
-        char[] newBuffer = new char[newCapacity];
-        System.arraycopy(buffer.array(), 0, newBuffer, 0, oldLimit);
-        buffer = CharBuffer.wrap(newBuffer, 0, newCapacity);
-        buffer.position(oldPosition);
-        buffer.limit(oldLimit);
+        int oldCapacity = buffer.capacity();
+        
+        //new start index for new buffer
+        int startIndex = 0;
+        
+        if (preStartIndex == -1) {
+            startIndex = findStartIndex;
+            nPreStartIndex = -1;
+            nFindStartIndex = 0;
+        } else {
+            startIndex = preStartIndex;
+            nPreStartIndex = 0;
+            nFindStartIndex = findStartIndex - startIndex;
+        }
+        
+        int nCapacity = oldCapacity;
+        char[] newBuffer = null;
+        // set nCapacity
+        if (startIndex < oldCapacity / 2) {
+            nCapacity = nCapacity << 1;
+            newBuffer = new char[nCapacity];
+        } else {
+            newBuffer = buffer.array();
+        }
+
+        //new buffer set
+        nBufferLength = oldLength - startIndex;
+        nLimit = oldLimit - startIndex;
+        if (oldPostion < startIndex) {
+            nPostion = 0;
+        } else {
+            nPostion = oldPostion - startIndex;
+        }
+        // new CachedhasNextIndex;
+        if (cachehasNextIndex != -1) {
+            nCachehasNextIndex = cachehasNextIndex - startIndex;
+        } else {
+            nCachehasNextIndex = -1;
+        }
+        System.arraycopy(buffer.array(), startIndex, newBuffer, 0, nLimit);
+
+        buffer = CharBuffer.wrap(newBuffer, 0, nCapacity);
+        buffer.position(nPostion);
+        buffer.limit(nLimit);
+
+        preStartIndex = nPreStartIndex;
+        findStartIndex = nFindStartIndex;
+        bufferLength = nBufferLength;
+        cachehasNextIndex = nCachehasNextIndex;
     }
 
     /**

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnectionImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnectionImpl.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnectionImpl.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnectionImpl.java Wed Jun 23 14:25:36 2010
@@ -28,6 +28,7 @@ import java.net.ContentHandlerFactory;
 import java.net.JarURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.URLDecoder;
 import java.security.AccessController;
 import java.security.Permission;
 import java.security.PrivilegedAction;
@@ -207,12 +208,14 @@ public class JarURLConnectionImpl extend
      * URLConnection}.
      */
     private void findJarEntry() throws IOException {
-        if (getEntryName() == null) {
+        String entryName = getEntryName();
+        if (entryName == null) {
             return;
         }
-        jarEntry = jarFile.getJarEntry(getEntryName());
+        String decodedName = URLDecoder.decode(entryName, "UTF-8"); //$NON-NLS-1$
+        jarEntry = jarFile.getJarEntry(decodedName);
         if (jarEntry == null) {
-            throw new FileNotFoundException(getEntryName());
+            throw new FileNotFoundException(entryName);
         }
     }
 

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java Wed Jun 23 14:25:36 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/java6/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/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java Wed Jun 23 14:25:36 2010
@@ -24,6 +24,7 @@ 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;
@@ -211,7 +212,7 @@ public class InputStreamReaderTest exten
             is = new InputStreamReader(fis, "Bogus");
             fail("Failed to throw Unsupported Encoding exception");
         } catch (UnsupportedEncodingException e) {
-            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {

Modified: harmony/enhanced/java/branches/java6/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/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PrintStreamTest.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PrintStreamTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PrintStreamTest.java Wed Jun 23 14:25:36 2010
@@ -82,6 +82,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/java6/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/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java Wed Jun 23 14:25:36 2010
@@ -743,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/java6/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/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java Wed Jun 23 14:25:36 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/java6/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/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/JarURLConnectionTest.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/JarURLConnectionTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/JarURLConnectionTest.java Wed Jun 23 14:25:36 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/java6/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/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java Wed Jun 23 14:25:36 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/java6/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/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java Wed Jun 23 14:25:36 2010
@@ -1382,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/java6/classlib/modules/math/src/main/java/java/math/BigInteger.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/math/src/main/java/java/math/BigInteger.java?rev=957214&r1=957213&r2=957214&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/math/src/main/java/java/math/BigInteger.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/math/src/main/java/java/math/BigInteger.java Wed Jun 23 14:25:36 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);



Mime
View raw message