changeset 52920:c392f7b60fd9

8214445: [test] java/net/URL/HandlerLoop has illegal reflective access Reviewed-by: lancea, chegar, bpb
author rriggs
date Thu, 29 Nov 2018 09:19:16 -0500
parents b3866f3879e1
children 8a85d21d9616
files test/jdk/java/net/URL/HandlerLoop.java
diffstat 1 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/java/net/URL/HandlerLoop.java	Thu Nov 29 08:50:25 2018 -0500
+++ b/test/jdk/java/net/URL/HandlerLoop.java	Thu Nov 29 09:19:16 2018 -0500
@@ -21,16 +21,19 @@
  * questions.
  */
 
-import java.io.*;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+
 /*
  * @test
  * @bug 4135031
- * @summary Test boostrap problem when a URLStreamHandlerFactory is loaded
+ * @summary Test bootstrap problem when a URLStreamHandlerFactory is loaded
  *          by the application class loader.
- *
+ * @modules java.base/sun.net.www.protocol.file
+ * @run main HandlerLoop
  */
-import java.net.*;
-
 public class HandlerLoop {
 
     public static void main(String args[]) throws Exception {
@@ -57,13 +60,13 @@
             // shares the same stream handler factory.
             new Dummy();
             try {
-                Class c = Class.forName(name);
-                return (URLStreamHandler)c.newInstance();
-            } catch (ClassNotFoundException e) {
-                e.printStackTrace();
-            } catch (IllegalAccessException e) {
-                e.printStackTrace();
-            } catch (InstantiationException e) {
+                Class<?> c = Class.forName(name);
+                return (URLStreamHandler)c.getDeclaredConstructor().newInstance();
+            } catch (ClassNotFoundException |
+                    IllegalAccessException |
+                    InstantiationException |
+                    NoSuchMethodException |
+                    InvocationTargetException e) {
                 e.printStackTrace();
             }
             return null;