8068578: test/java/io/Serializable/subclassGC/SubclassGC.java assumes app class loader is a URLClassLoader
authorbchristi
Thu, 29 Jan 2015 14:49:15 -0800
changeset 28682 6c7c7cad5e64
parent 28681 fc0698dfbb23
child 28683 a36c179aa292
8068578: test/java/io/Serializable/subclassGC/SubclassGC.java assumes app class loader is a URLClassLoader Reviewed-by: alanb
jdk/test/java/io/Serializable/subclassGC/SubclassGC.java
jdk/test/java/io/Serializable/subclassGC/security.policy
--- a/jdk/test/java/io/Serializable/subclassGC/SubclassGC.java	Thu Jan 29 20:45:30 2015 +0000
+++ b/jdk/test/java/io/Serializable/subclassGC/SubclassGC.java	Thu Jan 29 14:49:15 2015 -0800
@@ -50,8 +50,9 @@
                 }
 
                 ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
-                ClassLoader loader = new URLClassLoader(((URLClassLoader) systemLoader).getURLs(),
-                                                                                        systemLoader.getParent());
+                URL testClassesURL = new File(System.getProperty("test.classes")).toURI().toURL();
+                ClassLoader loader = new URLClassLoader(new URL[] { testClassesURL } ,
+                                                        systemLoader.getParent());
                 Class<? extends ObjectOutputStream> cl =
                         Class.forName(SubclassOfOOS.class.getName(), false,
                                                   loader).asSubclass(ObjectOutputStream.class);
--- a/jdk/test/java/io/Serializable/subclassGC/security.policy	Thu Jan 29 20:45:30 2015 +0000
+++ b/jdk/test/java/io/Serializable/subclassGC/security.policy	Thu Jan 29 14:49:15 2015 -0800
@@ -2,5 +2,7 @@
 grant {
 	permission java.lang.RuntimePermission "createClassLoader";
 	permission java.lang.RuntimePermission "getClassLoader";
+	permission java.util.PropertyPermission "test.classes", "read";
+	permission java.io.FilePermission "<<ALL FILES>>", "read";
 };