changeset 27034:ac2dd06dba4a

8060166: javax/management/MBeanInfo/NotificationInfoTest.java fails with modular image Reviewed-by: dfuchs
author alanb
date Mon, 13 Oct 2014 17:35:19 +0100
parents 17712e486fb2
children e1bd64d9b536
files jdk/test/javax/management/MBeanInfo/NotificationInfoTest.java
diffstat 1 files changed, 4 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/test/javax/management/MBeanInfo/NotificationInfoTest.java	Mon Oct 13 17:55:14 2014 +0800
+++ b/jdk/test/javax/management/MBeanInfo/NotificationInfoTest.java	Mon Oct 13 17:35:19 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...");