jdk/src/share/classes/sun/applet/AppletPanel.java
changeset 21785 fc0bfa7d9d95
parent 16092 129d7d8a7399
child 22584 eed64ee05369
--- a/jdk/src/share/classes/sun/applet/AppletPanel.java	Fri Nov 15 17:40:34 2013 +0400
+++ b/jdk/src/share/classes/sun/applet/AppletPanel.java	Mon Nov 18 19:22:29 2013 +0400
@@ -794,18 +794,13 @@
             doInit = true;
         } else {
             // serName is not null;
-            InputStream is = (InputStream)
-                java.security.AccessController.doPrivileged(
-                                                            new java.security.PrivilegedAction() {
-                                                                public Object run() {
-                                                                    return loader.getResourceAsStream(serName);
-                                                                }
-                                                            });
-            ObjectInputStream ois =
-                new AppletObjectInputStream(is, loader);
-            Object serObject = ois.readObject();
-            applet = (Applet) serObject;
-            doInit = false; // skip over the first init
+            try (InputStream is = AccessController.doPrivileged(
+                    (PrivilegedAction<InputStream>)() -> loader.getResourceAsStream(serName));
+                 ObjectInputStream ois = new AppletObjectInputStream(is, loader)) {
+
+                applet = (Applet) ois.readObject();
+                doInit = false; // skip over the first init
+            }
         }
 
         // Determine the JDK level that the applet targets.
@@ -1239,20 +1234,13 @@
             // append .class
             final String resourceName = name + ".class";
 
-            InputStream is = null;
             byte[] classHeader = new byte[8];
 
-            try {
-                is = (InputStream) java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                        public Object run() {
-                            return loader.getResourceAsStream(resourceName);
-                        }
-                    });
+            try (InputStream is = AccessController.doPrivileged(
+                    (PrivilegedAction<InputStream>) () -> loader.getResourceAsStream(resourceName))) {
 
                 // Read the first 8 bytes of the class file
                 int byteRead = is.read(classHeader, 0, 8);
-                is.close();
 
                 // return if the header is not read in entirely
                 // for some reasons.