changeset 12632:58fde919b6c3

8131926: java/beans/SimpleBeanInfo/LoadingStandardIcons/LoadingStandardIcons.java failure with modular JDK Reviewed-by: azvegint, alexsch
author serb
date Wed, 12 Aug 2015 14:37:44 +0300
parents 09b17ef4ac24
children ce6d5938944b
files src/java.desktop/share/classes/java/beans/SimpleBeanInfo.java
diffstat 1 files changed, 3 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/share/classes/java/beans/SimpleBeanInfo.java	Wed Aug 12 13:57:12 2015 +0300
+++ b/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;