1 /*
2 * Copyright (c) 2015, 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 */
98 addExports(cl);
99 } catch (ClassNotFoundException e) {
100 throw new AssertionError(e);
101 }
102 return getMethod(cl, methodName);
103 }
104
105 @BeforeClass
106 public static void beforeClass() {
107 addExports(AsmLoader.class);
108 }
109
110 /**
111 * This test uses some API hidden by the JDK9 module system.
112 */
113 private static void addExports(Class<?> c) {
114 if (!Java8OrEarlier) {
115 Object javaBaseModule = JLModule.fromClass(String.class);
116 Object cModule = JLModule.fromClass(c);
117 uncheckedAddExports(javaBaseModule, "jdk.internal.reflect", cModule);
118 if (Java11OrEarlier)
119 uncheckedAddExports(javaBaseModule, "jdk.internal.misc", cModule);
120 else
121 uncheckedAddExports(javaBaseModule, "jdk.internal.access", cModule);
122 }
123 }
124
125 @Test
126 public void testGetSize() {
127 Object cp = getConstantPoolForObject();
128 test("getSize", cp);
129 }
130
131 @Test
132 public void testGetIntAt() {
133 test("getIntAt");
134 }
135
136 @Test
137 public void testGetLongAt() {
138 test("getLongAt");
139 }
140
141 @Test
|
1 /*
2 * Copyright (c) 2015, 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 */
98 addExports(cl);
99 } catch (ClassNotFoundException e) {
100 throw new AssertionError(e);
101 }
102 return getMethod(cl, methodName);
103 }
104
105 @BeforeClass
106 public static void beforeClass() {
107 addExports(AsmLoader.class);
108 }
109
110 /**
111 * This test uses some API hidden by the JDK9 module system.
112 */
113 private static void addExports(Class<?> c) {
114 if (!Java8OrEarlier) {
115 Object javaBaseModule = JLModule.fromClass(String.class);
116 Object cModule = JLModule.fromClass(c);
117 uncheckedAddExports(javaBaseModule, "jdk.internal.reflect", cModule);
118 if (Java11OrEarlier) {
119 uncheckedAddExports(javaBaseModule, "jdk.internal.misc", cModule);
120 } else {
121 uncheckedAddExports(javaBaseModule, "jdk.internal.access", cModule);
122 }
123 }
124 }
125
126 @Test
127 public void testGetSize() {
128 Object cp = getConstantPoolForObject();
129 test("getSize", cp);
130 }
131
132 @Test
133 public void testGetIntAt() {
134 test("getIntAt");
135 }
136
137 @Test
138 public void testGetLongAt() {
139 test("getLongAt");
140 }
141
142 @Test
|