/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @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 javax.management.*;
public class ArrayClassTest {
/* 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. */
// Create an MLet that can load the same class names but
// will produce different results.
if (checkLoader != loader)
if (zarray instanceof Z[])
failed = "read back a real Z[]";
failed = "returned object of wrong type: " +
}
}
public static interface TestMBean {
}
}
public static class X {}
public static class Y {}
public static class Z implements Serializable {}
public static interface SpyLoaderMBean {}
/* We originally had this extend MLet but for some reason that
stopped the bug from happening. Some side-effect of registering
the MLet in the MBean server caused it not to fail when asked
to load Z[]. */
implements SpyLoaderMBean, PrivateClassLoader {
// important that the parent classloader be null!
// otherwise we can pick up classes from the classpath
}
/*
public Class loadClass(String name) throws ClassNotFoundException {
System.out.println("loadClass: " + name);
return super.loadClass(name);
}
public Class loadClass(String name, boolean resolve)
throws ClassNotFoundException {
System.out.println("loadClass: " + name + ", " + resolve);
return super.loadClass(name, resolve);
}
*/
if (false)
return c;
}
}
}