0N/A/*
2362N/A * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/* @test
0N/A * @bug 4978925
0N/A * @summary This test verifies that java.lang.reflect.Proxy will work
0N/A * with a proxy interface that contains names that are not valid Java
0N/A * identifiers but that are legal at runtime as of version 49.0 of the
0N/A * class file format.
0N/A * @author Peter Jones
0N/A *
0N/A * @build Test
0N/A * @run main Test
0N/A */
0N/A
0N/Aimport java.lang.reflect.Proxy;
0N/A
0N/Apublic class Test {
0N/A
0N/A private static final String CLASS_NAME = "Test+Interface";
0N/A
0N/A /**
0N/A * class file for empty interface named "Test+Interface"
0N/A */
0N/A private static final byte[] CLASS_FILE = {
0N/A (byte) 0xca, (byte) 0xfe, (byte) 0xba, (byte) 0xbe,
0N/A 0x00, 0x00, 0x00, 0x31,
0N/A 0x00, 0x07, 0x07, 0x00, 0x05, 0x07, 0x00, 0x06,
0N/A 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63,
0N/A 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x13,
0N/A 0x54, 0x65, 0x73, 0x74, 0x2b, 0x49, 0x6e, 0x74,
0N/A 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x6a,
0N/A 0x61, 0x76, 0x61, 0x01, 0x00, 0x0e, 0x54, 0x65,
0N/A 0x73, 0x74, 0x2b, 0x49, 0x6e, 0x74, 0x65, 0x72,
0N/A 0x66, 0x61, 0x63, 0x65, 0x01, 0x00, 0x10, 0x6a,
0N/A 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67,
0N/A 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x06,
0N/A 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,
0N/A 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00,
0N/A 0x00, 0x00, 0x02, 0x00, 0x04
0N/A };
0N/A
0N/A public static void main(String[] args) throws Exception {
0N/A ClassLoader l = new Loader();
0N/A Class i = Class.forName(CLASS_NAME, false, l);
0N/A System.out.println(i);
0N/A Class p = Proxy.getProxyClass(i.getClassLoader(), new Class[] { i });
0N/A System.out.println(p);
0N/A }
0N/A
0N/A private static class Loader extends ClassLoader {
0N/A Loader() { }
0N/A protected Class findClass(String name) throws ClassNotFoundException {
0N/A if (name.equals(CLASS_NAME)) {
0N/A return defineClass(name, CLASS_FILE, 0, CLASS_FILE.length);
0N/A } else {
0N/A return super.findClass(name);
0N/A }
0N/A }
0N/A }
0N/A}