1 /*
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. 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 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.
22 */
54 // Turns I from a class into an interface when loading
55
56 ClassLoader cl = compiler.compile(C, I);
57 try {
58 java.lang.Class<?> C_class =
59 java.lang.Class.forName("C", true, cl);
60 assertNotNull(C_class);
61 java.lang.reflect.Method m = C_class.getMethod("foo");
62 assertNotNull(m);
63 Integer res = (Integer)m.invoke(null);
64 assertEquals(res.intValue(), 99);
65 } catch (java.lang.reflect.InvocationTargetException e) {
66 fail("Unexpected exception: " + e.getCause());
67 } catch (Throwable e) {
68 fail("Unexpected exception: " + e);
69 } finally {
70 compiler.cleanup();
71 }
72 }
73
74 @Test(groups = "vm_prototype")
75 public void testPrivateMethodCall() {
76 testMethodCallWithFlag(AccessFlag.PRIVATE);
77 }
78
79 @Test(groups = "vm_prototype")
80 public void testStaticMethodCall() {
81 testMethodCallWithFlag(AccessFlag.PUBLIC, AccessFlag.STATIC);
82 }
83
84 @Test(groups = "vm_prototype")
85 public void testPrivateStaticMethodCall() {
86 testMethodCallWithFlag(AccessFlag.PRIVATE, AccessFlag.STATIC);
87 }
88
89 // Test other combos? Protected?
90 }
|
1 /*
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. 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 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.
22 */
54 // Turns I from a class into an interface when loading
55
56 ClassLoader cl = compiler.compile(C, I);
57 try {
58 java.lang.Class<?> C_class =
59 java.lang.Class.forName("C", true, cl);
60 assertNotNull(C_class);
61 java.lang.reflect.Method m = C_class.getMethod("foo");
62 assertNotNull(m);
63 Integer res = (Integer)m.invoke(null);
64 assertEquals(res.intValue(), 99);
65 } catch (java.lang.reflect.InvocationTargetException e) {
66 fail("Unexpected exception: " + e.getCause());
67 } catch (Throwable e) {
68 fail("Unexpected exception: " + e);
69 } finally {
70 compiler.cleanup();
71 }
72 }
73
74 /* excluded: 8187655
75 @Test(groups = "vm_prototype")
76 public void testPrivateMethodCall() {
77 testMethodCallWithFlag(AccessFlag.PRIVATE);
78 }
79 */
80
81 @Test(groups = "vm_prototype")
82 public void testStaticMethodCall() {
83 testMethodCallWithFlag(AccessFlag.PUBLIC, AccessFlag.STATIC);
84 }
85
86 @Test(groups = "vm_prototype")
87 public void testPrivateStaticMethodCall() {
88 testMethodCallWithFlag(AccessFlag.PRIVATE, AccessFlag.STATIC);
89 }
90
91 // Test other combos? Protected?
92 }
|