2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
5506
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
2
|
22 |
*/
|
|
23 |
|
|
24 |
/* @test
|
|
25 |
* @bug 4227192
|
|
26 |
* @summary This test verifies that a proxy class can be created with
|
|
27 |
* (and defined in) the null class loader.
|
|
28 |
* @author Peter Jones
|
|
29 |
*
|
|
30 |
* @build NullClassLoader
|
|
31 |
* @run main NullClassLoader
|
|
32 |
*/
|
|
33 |
|
|
34 |
import java.lang.reflect.*;
|
|
35 |
import java.util.Observer;
|
|
36 |
|
|
37 |
public class NullClassLoader {
|
|
38 |
|
|
39 |
public static void main(String[] args) {
|
|
40 |
|
|
41 |
System.err.println(
|
|
42 |
"\nTest creating proxy class with the null class loader.\n");
|
|
43 |
|
|
44 |
try {
|
36511
|
45 |
ClassLoader ld = null;
|
|
46 |
Class p = Proxy.getProxyClass(ld, new Class[] { Runnable.class, Observer.class });
|
2
|
47 |
System.err.println("proxy class: " + p);
|
|
48 |
|
|
49 |
ClassLoader loader = p.getClassLoader();
|
|
50 |
System.err.println("proxy class's class loader: " + loader);
|
|
51 |
|
|
52 |
if (loader != null) {
|
|
53 |
throw new RuntimeException(
|
|
54 |
"proxy class not defined in the null class loader");
|
|
55 |
}
|
|
56 |
|
|
57 |
System.err.println("\nTEST PASSED");
|
|
58 |
|
|
59 |
} catch (Throwable e) {
|
|
60 |
System.err.println("\nTEST FAILED:");
|
|
61 |
e.printStackTrace();
|
|
62 |
throw new RuntimeException("TEST FAILED: " + e.toString());
|
|
63 |
}
|
|
64 |
}
|
|
65 |
}
|