8072656: test/java/lang/reflect/Proxy/ClassRestrictions.java assumes app class loader be URLClassLoader
authormchung
Wed, 18 Feb 2015 18:14:41 -0800
changeset 29036 63d5aec20b48
parent 29035 af8778de756a
child 29037 8a11fed0d1a0
8072656: test/java/lang/reflect/Proxy/ClassRestrictions.java assumes app class loader be URLClassLoader Reviewed-by: lancea, alanb
jdk/test/java/lang/reflect/Proxy/ClassRestrictions.java
--- a/jdk/test/java/lang/reflect/Proxy/ClassRestrictions.java	Wed Feb 18 08:59:55 2015 -0800
+++ b/jdk/test/java/lang/reflect/Proxy/ClassRestrictions.java	Wed Feb 18 18:14:41 2015 -0800
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4227192 8004928
+ * @bug 4227192 8004928 8072656
  * @summary This is a test of the restrictions on the parameters that may
  * be passed to the Proxy.getProxyClass method.
  * @author Peter Jones
@@ -31,9 +31,12 @@
  * @run main ClassRestrictions
  */
 
+import java.io.File;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Proxy;
 import java.net.URLClassLoader;
+import java.net.URL;
+import java.nio.file.Paths;
 
 public class ClassRestrictions {
 
@@ -105,8 +108,13 @@
              * All of the interfaces types must be visible by name though the
              * specified class loader.
              */
-            ClassLoader altLoader = new URLClassLoader(
-                ((URLClassLoader) loader).getURLs(), null);
+            String[] cpaths = System.getProperty("test.classes", ".")
+                                    .split(File.pathSeparator);
+            URL[] urls = new URL[cpaths.length];
+            for (int i=0; i < cpaths.length; i++) {
+                urls[i] = Paths.get(cpaths[i]).toUri().toURL();
+            }
+            ClassLoader altLoader = new URLClassLoader(urls, null);
             Class altBarClass;
             altBarClass = Class.forName(Bar.class.getName(), false, altLoader);
             try {