8131926: java/beans/SimpleBeanInfo/LoadingStandardIcons/LoadingStandardIcons.java failure with modular JDK
authorserb
Wed, 12 Aug 2015 14:37:44 +0300
changeset 32284 d0571ef4278c
parent 32283 1a96ab120a48
child 32285 932b5c08592e
8131926: java/beans/SimpleBeanInfo/LoadingStandardIcons/LoadingStandardIcons.java failure with modular JDK Reviewed-by: azvegint, alexsch
jdk/src/java.desktop/share/classes/java/beans/SimpleBeanInfo.java
--- a/jdk/src/java.desktop/share/classes/java/beans/SimpleBeanInfo.java	Wed Aug 12 13:57:12 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/java/beans/SimpleBeanInfo.java	Wed Aug 12 14:37:44 2015 +0300
@@ -27,8 +27,7 @@
 
 import java.awt.Image;
 import java.awt.Toolkit;
-import java.awt.image.ImageProducer;
-import java.net.URL;
+import java.io.InputStream;
 
 /**
  * This is a support class to make it easier for people to provide
@@ -122,14 +121,8 @@
      * @return  an image object.  May be null if the load failed.
      */
     public Image loadImage(final String resourceName) {
-        try {
-            final URL url = getClass().getResource(resourceName);
-            if (url != null) {
-                final ImageProducer ip = (ImageProducer) url.getContent();
-                if (ip != null) {
-                    return Toolkit.getDefaultToolkit().createImage(ip);
-                }
-            }
+        try (InputStream in = getClass().getResourceAsStream(resourceName)) {
+            return Toolkit.getDefaultToolkit().createImage(in.readAllBytes());
         } catch (final Exception ignored) {
         }
         return null;