changeset 12366:8121478fab3a

8104574: Update tests to prepare for system class loader not be URLClassLoader Reviewed-by: chegar
author mchung
date Wed, 15 Jul 2015 12:10:03 +0800
parents 0a8899dad301
children 6c0e4a3e5f69 c3cc7e733ee2
files test/java/lang/reflect/Generics/ThreadSafety.java
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/lang/reflect/Generics/ThreadSafety.java	Tue Jul 14 22:21:52 2015 -0400
+++ b/test/java/lang/reflect/Generics/ThreadSafety.java	Wed Jul 15 12:10:03 2015 +0800
@@ -28,8 +28,11 @@
  * @run testng ThreadSafety
  */
 
+import java.io.File;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Collections;
 import java.util.concurrent.BrokenBarrierException;
 import java.util.concurrent.Callable;
@@ -71,9 +74,13 @@
     /** published via data race */
     private Class<?> racyClass = Object.class;
 
-    private URL[] urls = ((URLClassLoader) ThreadSafety.class.getClassLoader()).getURLs();
-
     private Class<?> createNewEmptyGenericSubclassClass() throws Exception {
+        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();
+        }
         URLClassLoader ucl = new URLClassLoader(urls, null);
         return Class.forName("ThreadSafety$EmptyClass$EmptyGenericSubclass", true, ucl);
     }