< prev index next >
test/javax/management/loading/ArrayClassTest.java
Print this page
rev 11832 : 8078896: Add @modules as needed to the jdk_svc tests
Reviewed-by: alanb, mchung
*** 1,7 ****
/*
! * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 25,58 ****
* @test
* @bug 4974913
* @summary Test that array classes can be found in signatures always
* and can be deserialized by the deprecated MBeanServer.deserialize method
* @author Eamonn McManus
* @run clean ArrayClassTest
* @run build ArrayClassTest
* @run main ArrayClassTest
*/
import java.io.*;
import java.lang.reflect.*;
import java.net.*;
import javax.management.*;
import javax.management.loading.*;
public class ArrayClassTest {
public static void main(String[] args) throws Exception {
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
! /* If this test isn't loaded by a URLClassLoader we will get
! a ClassCastException here, which is good because it means
! this test isn't valid. */
! URLClassLoader testLoader =
! (URLClassLoader) ArrayClassTest.class.getClassLoader();
// Create an MLet that can load the same class names but
// will produce different results.
! ClassLoader loader = new SpyLoader(testLoader.getURLs());
ObjectName loaderName = new ObjectName("test:type=SpyLoader");
mbs.registerMBean(loader, loaderName);
ObjectName testName = new ObjectName("test:type=Test");
mbs.createMBean(Test.class.getName(), testName, loaderName,
--- 25,61 ----
* @test
* @bug 4974913
* @summary Test that array classes can be found in signatures always
* and can be deserialized by the deprecated MBeanServer.deserialize method
* @author Eamonn McManus
+ * @modules java.management
* @run clean ArrayClassTest
* @run build ArrayClassTest
* @run main ArrayClassTest
*/
import java.io.*;
import java.lang.reflect.*;
import java.net.*;
+ import java.nio.file.Paths;
import javax.management.*;
import javax.management.loading.*;
public class ArrayClassTest {
public static void main(String[] args) throws Exception {
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
! 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();
! }
// Create an MLet that can load the same class names but
// will produce different results.
! ClassLoader loader = new SpyLoader(urls);
ObjectName loaderName = new ObjectName("test:type=SpyLoader");
mbs.registerMBean(loader, loaderName);
ObjectName testName = new ObjectName("test:type=Test");
mbs.createMBean(Test.class.getName(), testName, loaderName,
< prev index next >