author | psandoz |
Wed, 31 Jan 2018 17:43:46 -0800 | |
changeset 48830 | 11920d5d14a8 |
parent 48826 | c4d9d1b08e2e |
permissions | -rw-r--r-- |
48826 | 1 |
/* |
48830
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
2 |
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
48826 | 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 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 8186046 |
|
27 |
* @summary Test nested dynamic constant declarations that are recursive |
|
48830
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
28 |
* @compile CondyNestedTest_Code.jcod |
48826 | 29 |
* @run testng CondyNestedTest |
30 |
* @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:UseBootstrapCallInfo=3 CondyNestedTest |
|
31 |
*/ |
|
32 |
||
33 |
import org.testng.Assert; |
|
34 |
import org.testng.annotations.BeforeClass; |
|
35 |
import org.testng.annotations.Test; |
|
36 |
||
37 |
import java.lang.reflect.InvocationTargetException; |
|
38 |
import java.lang.reflect.Method; |
|
39 |
||
40 |
public class CondyNestedTest { |
|
41 |
||
42 |
static final Class[] THROWABLES = {InvocationTargetException.class, StackOverflowError.class}; |
|
43 |
||
44 |
Class<?> c; |
|
45 |
||
48830
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
46 |
// Add the following annotations to the test description if uncommenting the |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
47 |
// following code |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
48 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
49 |
// * @library /lib/testlibrary/bytecode |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
50 |
// * @build jdk.experimental.bytecode.BasicClassBuilder |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
51 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
52 |
// static final MethodHandles.Lookup L = MethodHandles.lookup(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
53 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
54 |
// /** |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
55 |
// * Generate class file bytes for a class named CondyNestedTest_Code |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
56 |
// * whose bytes are converted to a jcod file: |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
57 |
// * |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
58 |
// * java -jar asmtools.jar jdec CondyNestedTest_Code.class > |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
59 |
// * CondyNestedTest_Code.jcod |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
60 |
// * |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
61 |
// * which was then edited so that dynamic constant declarations are |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
62 |
// * recursive both for an ldc or invokedynamic (specifically declaring a |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
63 |
// * BSM+attributes whose static argument is a dynamic constant |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
64 |
// * that refers to the same BSM+attributes). |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
65 |
// */ |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
66 |
// public static byte[] generator() throws Exception { |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
67 |
// String genClassName = L.lookupClass().getSimpleName() + "_Code"; |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
68 |
// String bsmDescriptor = MethodType.methodType(Object.class, MethodHandles.Lookup.class, String.class, Object.class, Object.class).toMethodDescriptorString(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
69 |
// String bsmIndyDescriptor = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class, Object.class, Object.class).toMethodDescriptorString(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
70 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
71 |
// byte[] byteArray = new BasicClassBuilder(genClassName, 55, 0) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
72 |
// .withSuperclass("java/lang/Object") |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
73 |
// .withMethod("<init>", "()V", M -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
74 |
// M.withFlags(Flag.ACC_PUBLIC) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
75 |
// .withCode(TypedCodeBuilder::new, C -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
76 |
// C.aload_0().invokespecial("java/lang/Object", "<init>", "()V", false).return_() |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
77 |
// )) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
78 |
// .withMethod("main", "([Ljava/lang/String;)V", M -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
79 |
// M.withFlags(Flag.ACC_PUBLIC, Flag.ACC_STATIC) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
80 |
// .withCode(TypedCodeBuilder::new, C -> { |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
81 |
// C.aload_0().iconst_0().aaload(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
82 |
// C.invokevirtual("java/lang/String", "intern", "()Ljava/lang/String;", false); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
83 |
// C.astore_1(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
84 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
85 |
// C.aload_1(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
86 |
// C.ldc("condy_bsm_condy_bsm"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
87 |
// C.ifcmp(TypeTag.A, MacroCodeBuilder.CondKind.NE, "CASE1"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
88 |
// C.invokestatic(genClassName, "condy_bsm_condy_bsm", "()Ljava/lang/Object;", false).return_(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
89 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
90 |
// C.label("CASE1"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
91 |
// C.aload_1(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
92 |
// C.ldc("indy_bsmIndy_condy_bsm"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
93 |
// C.ifcmp(TypeTag.A, MacroCodeBuilder.CondKind.NE, "CASE2"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
94 |
// C.invokestatic(genClassName, "indy_bsmIndy_condy_bsm", "()Ljava/lang/Object;", false).return_(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
95 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
96 |
// C.label("CASE2"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
97 |
// C.aload_1(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
98 |
// C.ldc("indy_bsm_condy_bsm"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
99 |
// C.ifcmp(TypeTag.A, MacroCodeBuilder.CondKind.NE, "CASE3"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
100 |
// C.invokestatic(genClassName, "indy_bsm_condy_bsm", "()Ljava/lang/Object;", false).return_(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
101 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
102 |
// C.label("CASE3"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
103 |
// C.return_(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
104 |
// })) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
105 |
// .withMethod("bsm", bsmDescriptor, M -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
106 |
// M.withFlags(Flag.ACC_PUBLIC, Flag.ACC_STATIC) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
107 |
// .withCode(TypedCodeBuilder::new, C -> { |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
108 |
// C.aload_2(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
109 |
// C.instanceof_("java/lang/invoke/MethodType"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
110 |
// C.iconst_0(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
111 |
// C.ifcmp(TypeTag.I, MacroCodeBuilder.CondKind.EQ, "CONDY"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
112 |
// C.new_("java/lang/invoke/ConstantCallSite").dup(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
113 |
// C.ldc("java/lang/String", PoolHelper::putClass); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
114 |
// C.aload_1(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
115 |
// C.invokestatic("java/lang/invoke/MethodHandles", "constant", "(Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/invoke/MethodHandle;", false); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
116 |
// C.invokespecial("java/lang/invoke/ConstantCallSite", "<init>", "(Ljava/lang/invoke/MethodHandle;)V", false); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
117 |
// C.areturn(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
118 |
// C.label("CONDY"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
119 |
// C.aload_1().areturn(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
120 |
// })) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
121 |
// .withMethod("bsmIndy", bsmIndyDescriptor, M -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
122 |
// M.withFlags(Flag.ACC_PUBLIC, Flag.ACC_STATIC) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
123 |
// .withCode(TypedCodeBuilder::new, C -> { |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
124 |
// C.new_("java/lang/invoke/ConstantCallSite").dup(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
125 |
// C.ldc("java/lang/String", PoolHelper::putClass); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
126 |
// C.aload_1(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
127 |
// C.invokestatic("java/lang/invoke/MethodHandles", "constant", "(Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/invoke/MethodHandle;", false); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
128 |
// C.invokespecial("java/lang/invoke/ConstantCallSite", "<init>", "(Ljava/lang/invoke/MethodHandle;)V", false); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
129 |
// C.areturn(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
130 |
// })) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
131 |
// .withMethod("condy_bsm_condy_bsm", "()Ljava/lang/Object;", M -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
132 |
// M.withFlags(Flag.ACC_PUBLIC, Flag.ACC_STATIC) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
133 |
// .withCode(TypedCodeBuilder::new, C -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
134 |
// C.ldc("name", "Ljava/lang/String;", genClassName, "bsm", bsmDescriptor, |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
135 |
// S -> S.add(null, (P, v) -> { |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
136 |
// return P.putDynamicConstant("name", "Ljava/lang/String;", genClassName, "bsm", bsmDescriptor, |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
137 |
// S2 -> S2.add("DUMMY_ARG", PoolHelper::putString)); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
138 |
// })) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
139 |
// .areturn())) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
140 |
// .withMethod("indy_bsmIndy_condy_bsm", "()Ljava/lang/Object;", M -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
141 |
// M.withFlags(Flag.ACC_PUBLIC, Flag.ACC_STATIC) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
142 |
// .withCode(TypedCodeBuilder::new, C -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
143 |
// C.invokedynamic("name", "()Ljava/lang/String;", genClassName, "bsmIndy", bsmIndyDescriptor, |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
144 |
// S -> S.add(null, (P, v) -> { |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
145 |
// return P.putDynamicConstant("name", "Ljava/lang/String;", genClassName, "bsm", bsmDescriptor, |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
146 |
// S2 -> S2.add("DUMMY_ARG", PoolHelper::putString)); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
147 |
// })) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
148 |
// .areturn())) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
149 |
// .withMethod("indy_bsm_condy_bsm", "()Ljava/lang/Object;", M -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
150 |
// M.withFlags(Flag.ACC_PUBLIC, Flag.ACC_STATIC) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
151 |
// .withCode(TypedCodeBuilder::new, C -> |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
152 |
// C.invokedynamic("name", "()Ljava/lang/String;", genClassName, "bsm", bsmDescriptor, |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
153 |
// S -> S.add(null, (P, v) -> { |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
154 |
// return P.putDynamicConstant("name", "Ljava/lang/String;", genClassName, "bsm", bsmDescriptor, |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
155 |
// S2 -> S2.add("DUMMY_ARG", PoolHelper::putString)); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
156 |
// })) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
157 |
// .areturn())) |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
158 |
// .build(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
159 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
160 |
// File f = new File(genClassName + ".class"); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
161 |
// if (f.getParentFile() != null) { |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
162 |
// f.getParentFile().mkdirs(); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
163 |
// } |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
164 |
// new FileOutputStream(f).write(byteArray); |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
165 |
// return byteArray; |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
166 |
// |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
167 |
// } |
48826 | 168 |
|
169 |
static void test(Method m, Class<? extends Throwable>... ts) { |
|
170 |
Throwable caught = null; |
|
171 |
try { |
|
172 |
m.invoke(null); |
|
173 |
} |
|
174 |
catch (Throwable t) { |
|
175 |
caught = t; |
|
176 |
} |
|
177 |
||
178 |
if (caught == null) { |
|
179 |
Assert.fail("Throwable expected"); |
|
180 |
} |
|
181 |
||
182 |
String actualMessage = null; |
|
183 |
for (int i = 0; i < ts.length; i++) { |
|
184 |
actualMessage = caught.getMessage(); |
|
185 |
Assert.assertNotNull(caught); |
|
186 |
Assert.assertTrue(ts[i].isAssignableFrom(caught.getClass())); |
|
187 |
caught = caught.getCause(); |
|
188 |
} |
|
189 |
} |
|
190 |
||
191 |
@BeforeClass |
|
48830
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
192 |
public void findClass() throws Exception { |
11920d5d14a8
8196533: Update CondyNestedTest.java to compile jcod file
psandoz
parents:
48826
diff
changeset
|
193 |
c = Class.forName("CondyNestedTest_Code"); |
48826 | 194 |
} |
195 |
||
196 |
/** |
|
197 |
* Testing an ldc of a dynamic constant, C say, with a BSM whose static |
|
198 |
* argument is C. |
|
199 |
*/ |
|
200 |
@Test |
|
201 |
public void testCondyBsmCondyBsm() throws Exception { |
|
202 |
test("condy_bsm_condy_bsm", THROWABLES); |
|
203 |
} |
|
204 |
||
205 |
/** |
|
206 |
* Testing an invokedynamic with a BSM whose static argument is a constant |
|
207 |
* dynamic, C say, with a BSM whose static argument is C. |
|
208 |
*/ |
|
209 |
@Test |
|
210 |
public void testIndyBsmIndyCondyBsm() throws Exception { |
|
211 |
test("indy_bsmIndy_condy_bsm", THROWABLES); |
|
212 |
} |
|
213 |
||
214 |
/** |
|
215 |
* Testing an invokedynamic with a BSM, B say, whose static argument is |
|
216 |
* a dynamic constant, C say, that uses BSM B. |
|
217 |
*/ |
|
218 |
@Test |
|
219 |
public void testIndyBsmCondyBsm() throws Exception { |
|
220 |
test("indy_bsm_condy_bsm", THROWABLES); |
|
221 |
} |
|
222 |
||
223 |
void test(String methodName, Class<? extends Throwable>... ts) throws Exception { |
|
224 |
Method m = c.getMethod(methodName); |
|
225 |
m.setAccessible(true); |
|
226 |
test(m, ts); |
|
227 |
} |
|
228 |
||
229 |
} |