提交 332bce5b 编写于 作者: E egahlin

6959636: testcase failing on windows javax/management/loading/LibraryLoader/LibraryLoaderTest.java

Reviewed-by: sla, jbachorik
上级 090aaac3
...@@ -139,9 +139,6 @@ sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java macosx-all ...@@ -139,9 +139,6 @@ sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java macosx-all
# jdk_jmx # jdk_jmx
# 6959636
javax/management/loading/LibraryLoader/LibraryLoaderTest.java windows-all
############################################################################ ############################################################################
# jdk_math # jdk_math
......
/* /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2013 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* @author Luis-Miguel Alventosa * @author Luis-Miguel Alventosa
* @run clean LibraryLoaderTest * @run clean LibraryLoaderTest
* @run build LibraryLoaderTest * @run build LibraryLoaderTest
* @run main LibraryLoaderTest * @run main/othervm LibraryLoaderTest
*/ */
import java.io.File; import java.io.File;
...@@ -48,7 +48,7 @@ public class LibraryLoaderTest { ...@@ -48,7 +48,7 @@ public class LibraryLoaderTest {
{"testDomain:type=MLet,index=1", "UseNativeLib1.html"} {"testDomain:type=MLet,index=1", "UseNativeLib1.html"}
}; };
public static void main (String args[]) { public static void main(String args[]) throws Exception {
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name");
System.out.println("os.name=" + osName); System.out.println("os.name=" + osName);
...@@ -83,83 +83,73 @@ public class LibraryLoaderTest { ...@@ -83,83 +83,73 @@ public class LibraryLoaderTest {
"file:/" + testSrc.replace(File.separatorChar, '/') + "/"; "file:/" + testSrc.replace(File.separatorChar, '/') + "/";
} }
try { // Create MBeanServer
// Create MBeanServer //
MBeanServer server = MBeanServerFactory.newMBeanServer();
// Create MLet instances and call getRandom on the loaded MBeans
//
for (int i = 0; i < mletInfo.length; i++) {
// Create ObjectName for MLet
// //
MBeanServer server = MBeanServerFactory.newMBeanServer(); ObjectName mlet = new ObjectName(mletInfo[i][0]);
server.createMBean("javax.management.loading.MLet", mlet);
System.out.println("MLet = " + mlet);
// Create MLet instances and call getRandom on the loaded MBeans // Display old library directory and set it to test.classes
// //
for (int i = 0; i < mletInfo.length; i++) { String libraryDirectory =
// Create ObjectName for MLet (String) server.getAttribute(mlet, "LibraryDirectory");
// System.out.println("Old Library Directory = " +
ObjectName mlet = new ObjectName(mletInfo[i][0]); libraryDirectory);
server.createMBean("javax.management.loading.MLet", mlet); Attribute attribute =
System.out.println("MLet = " + mlet); new Attribute("LibraryDirectory", workingDir);
server.setAttribute(mlet, attribute);
libraryDirectory =
(String) server.getAttribute(mlet, "LibraryDirectory");
System.out.println("New Library Directory = " +
libraryDirectory);
// Display old library directory and set it to test.classes // Get MBeans from URL
// //
String libraryDirectory = String mletURL = urlCodebase + mletInfo[i][1];
(String) server.getAttribute(mlet, "LibraryDirectory"); System.out.println("MLet URL = " + mletURL);
System.out.println("Old Library Directory = " + Object[] params = new Object[] { mletURL };
libraryDirectory); String[] signature = new String[] {"java.lang.String"};
Attribute attribute = Object res[] = ((Set<?>) server.invoke(mlet,
new Attribute("LibraryDirectory", workingDir); "getMBeansFromURL",
server.setAttribute(mlet, attribute); params,
libraryDirectory = signature)).toArray();
(String) server.getAttribute(mlet, "LibraryDirectory");
System.out.println("New Library Directory = " +
libraryDirectory);
// Get MBeans from URL // Iterate through all the loaded MBeans
//
for (int j = 0; j < res.length; j++) {
// Now ensure none of the returned objects is a Throwable
// //
String mletURL = urlCodebase + mletInfo[i][1]; if (res[j] instanceof Throwable) {
System.out.println("MLet URL = " + mletURL); ((Throwable) res[j]).printStackTrace(System.out);
Object[] params = new Object[] { mletURL }; throw new Exception("Failed to load the MBean #" + j
String[] signature = new String[] {"java.lang.String"}; ,(Throwable)res[j]);
Object res[] = ((Set) server.invoke(mlet, }
"getMBeansFromURL",
params,
signature)).toArray();
// Iterate through all the loaded MBeans // On each of the loaded MBeans, try to invoke their
// native operation
// //
for (int j = 0; j < res.length; j++) { Object result = null;
// Now ensure none of the returned objects is a Throwable try {
// ObjectName mbean =
if (res[j] instanceof Throwable) { ((ObjectInstance) res[j]).getObjectName();
((Throwable) res[j]).printStackTrace(System.out); result = server.getAttribute(mbean, "Random");
System.out.println("Failed to load the MBean #" + j + System.out.println("MBean #" + j + " = " + mbean);
". The shown Throwable was caught."); System.out.println("Random number = " + result);
System.exit(1); } catch (ReflectionException e) {
} e.getTargetException().printStackTrace(System.out);
throw new Exception ("A ReflectionException "
// On each of the loaded MBeans, try to invoke their + "occured when attempting to invoke "
// native operation + "a native library based operation.",
// e.getTargetException());
Object result = null;
try {
ObjectName mbean =
((ObjectInstance) res[j]).getObjectName();
result = server.getAttribute(mbean, "Random");
System.out.println("MBean #" + j + " = " + mbean);
System.out.println("Random number = " + result);
} catch (ReflectionException e) {
e.getTargetException().printStackTrace(System.out);
System.out.println("A ReflectionException, wrapping " +
"the shown exception, occured when" +
" attempting to invoke a native " +
"library based operation.");
System.exit(1);
}
} }
} }
} catch (Exception e) {
e.printStackTrace(System.out);
System.out.println(e.getMessage());
System.out.println("Unexpected error");
System.exit(1);
} }
System.out.println("Bye! Bye!");
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册