< prev index next >

test/jdk/java/net/URL/HandlerLoop.java

Print this page
rev 52726 : 8214445: [test] java/net/URL/HandlerLoop has illegal reflective access

*** 19,38 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! import java.io.*; /* * @test * @bug 4135031 ! * @summary Test boostrap problem when a URLStreamHandlerFactory is loaded * by the application class loader. ! * */ - import java.net.*; - public class HandlerLoop { public static void main(String args[]) throws Exception { URL.setURLStreamHandlerFactory( new HandlerFactory("sun.net.www.protocol")); --- 19,41 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! import java.lang.reflect.InvocationTargetException; ! import java.net.URL; ! import java.net.URLStreamHandler; ! import java.net.URLStreamHandlerFactory; ! /* * @test * @bug 4135031 ! * @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 */ public class HandlerLoop { public static void main(String args[]) throws Exception { URL.setURLStreamHandlerFactory( new HandlerFactory("sun.net.www.protocol"));
*** 55,71 **** // problem as the stream handler factory will be reentered // over and over again if the application class loader // 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) { e.printStackTrace(); } return null; } } --- 58,74 ---- // problem as the stream handler factory will be reentered // over and over again if the application class loader // shares the same stream handler factory. new Dummy(); try { ! Class<?> c = Class.forName(name); ! return (URLStreamHandler)c.getDeclaredConstructor().newInstance(); ! } catch (ClassNotFoundException | ! IllegalAccessException | ! InstantiationException | ! NoSuchMethodException | ! InvocationTargetException e) { e.printStackTrace(); } return null; } }
< prev index next >