This test gets a URL to MBeanServer.class in a way that is dependent on the JDK internal layout (assumes rt.jar). I'd like to change this test to just use ClassLoader.getSystemResource so that it works when we move to a modular image. The proposed attached are below.

-Alan

--- a/test/javax/management/MBeanInfo/NotificationInfoTest.java Fri Sep 19 12:07:21 2014 +0100 +++ b/test/javax/management/MBeanInfo/NotificationInfoTest.java Fri Sep 19 12:42:36 2014 +0100
@@ -36,7 +36,6 @@
 import java.lang.management.*;
 import java.lang.reflect.*;
 import java.net.*;
-import java.security.CodeSource;
 import java.util.*;
 import java.util.jar.*;
 import javax.management.*;
@@ -83,27 +82,10 @@
         System.out.println("Checking platform MBeans...");
         checkPlatformMBeans();

-        CodeSource cs =
- javax.management.MBeanServer.class.getProtectionDomain()
-            .getCodeSource();
-        URL codeBase;
-        if (cs == null) {
-            String javaHome = System.getProperty("java.home");
-            String[] candidates = {"/lib/rt.jar", "/classes/"};
-            codeBase = null;
-            for (String candidate : candidates) {
-                File file = new File(javaHome + candidate);
-                if (file.exists()) {
-                    codeBase = file.toURI().toURL();
-                    break;
-                }
-            }
-            if (codeBase == null) {
-                throw new Exception(
- "Could not determine codeBase for java.home=" + javaHome);
-            }
-        } else
-            codeBase = cs.getLocation();
+ URL codeBase = ClassLoader.getSystemResource("javax/management/MBeanServer.class");
+        if (codeBase == null) {
+ throw new Exception("Could not determine codeBase for " + MBeanServer.class);
+        }

         System.out.println();
         System.out.println("Looking for standard MBeans...");

Reply via email to