blob: 192772b4dff4f6786aad070032837190d471ca70 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
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 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
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
34import java.lang.reflect.*;
35import java.util.Observer;
36
37public 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 {
45 Class p = Proxy.getProxyClass(null,
46 new Class[] { Runnable.class, Observer.class });
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}