changeset 11473:36607eb3168f

8072656: test/java/lang/reflect/Proxy/ClassRestrictions.java assumes app class loader be URLClassLoader Reviewed-by: lancea, alanb
author mchung
date Wed, 18 Feb 2015 18:14:41 -0800
parents 89bc656dc8c4
children 607ea68032cd
files test/java/lang/reflect/Proxy/ClassRestrictions.java
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/lang/reflect/Proxy/ClassRestrictions.java	Wed Feb 18 08:59:55 2015 -0800
+++ b/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 {