8186211: Negative tests for CONSTANT_Dynamic
Additional negative tests for poorly formed CONSTANT_Dynamic_info constant pool structures. Reviewed-by: hseigel, psandoz
This commit is contained in:
parent
a0c0b250cd
commit
1da7dc6296
59
test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java
Normal file
59
test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8186211
|
||||
* @summary CONSTANT_Dynamic_info structure's tries to use a BSM index whose signature is for an invokedynamic and vice versa.
|
||||
* @requires os.arch != "sparcv9"
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib
|
||||
* @compile CondyUsesIndyBSM.jcod
|
||||
* @compile IndyUsesCondyBSM.jcod
|
||||
* @run main/othervm -Xverify:all BadBSMUseTest
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.compiler.InMemoryJavaCompiler;
|
||||
|
||||
// BootstrapMethodError expected in each test case below.
|
||||
public class BadBSMUseTest {
|
||||
public static void main(String args[]) throws Throwable {
|
||||
// 1. Test a CONSTANT_Dynamic_info's bootstrap_method_attr_index points
|
||||
// at a BSM meant for a CONSTANT_InvokeDynamic_info
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("CondyUsesIndyBSM");
|
||||
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
|
||||
oa.shouldContain("In Indybsm target CallSite method foo");
|
||||
oa.shouldContain("BootstrapMethodError: bootstrap method initialization exception");
|
||||
oa.shouldHaveExitValue(1);
|
||||
|
||||
// 2. Test a CONSTANT_InvokeDynamic_info's bootstrap_method_attr_index points
|
||||
// at a BSM meant for a CONSTANT_Dynamic_info
|
||||
pb = ProcessTools.createJavaProcessBuilder("IndyUsesCondyBSM");
|
||||
oa = new OutputAnalyzer(pb.start());
|
||||
oa.shouldContain("In Condybsm");
|
||||
oa.shouldContain("BootstrapMethodError: bootstrap method initialization exception");
|
||||
oa.shouldHaveExitValue(1);
|
||||
}
|
||||
}
|
81
test/hotspot/jtreg/runtime/condy/CondyBadBSMArrayTest.java
Normal file
81
test/hotspot/jtreg/runtime/condy/CondyBadBSMArrayTest.java
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8186211
|
||||
* @summary CONSTANT_Dynamic_info structure present with various bad BSM index, BSM array attribute checks.
|
||||
* @requires os.arch != "sparcv9"
|
||||
* @compile CondyBadBSMIndex.jcod
|
||||
* @compile CondyEmptyBSMArray1.jcod
|
||||
* @compile CondyNoBSMArray.jcod
|
||||
* @run main/othervm -Xverify:all CondyBadBSMArrayTest
|
||||
*/
|
||||
|
||||
// Test that a CONSTANT_Dynamic_info structure present with the following issues:
|
||||
// 1. The CONSTANT_Dynamic_info structure's bootstrap_method_attr_index value is
|
||||
// an index outside of the array size.
|
||||
// 2. An empty BootstrapMethods Attribute array
|
||||
// 3. No BootstrapMethods Attribute array present.
|
||||
public class CondyBadBSMArrayTest {
|
||||
public static void main(String args[]) throws Throwable {
|
||||
// 1. The CONSTANT_Dynamic_info structure's bootstrap_method_attr_index is outside the array size
|
||||
try {
|
||||
Class newClass = Class.forName("CondyBadBSMIndex");
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
} catch (java.lang.ClassFormatError e) {
|
||||
if (!e.getMessage().contains("Short length on BootstrapMethods in class file")) {
|
||||
throw new RuntimeException("ClassFormatError thrown, incorrect message");
|
||||
}
|
||||
System.out.println("Test CondyBadBSMIndex passed: " + e.getMessage());
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
}
|
||||
|
||||
// 2. An empty BootstrapMethods Attribute array - contains zero elements
|
||||
try {
|
||||
Class newClass = Class.forName("CondyEmptyBSMArray1");
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
} catch (java.lang.ClassFormatError e) {
|
||||
if (!e.getMessage().contains("Short length on BootstrapMethods in class file")) {
|
||||
throw new RuntimeException("ClassFormatError thrown, incorrect message");
|
||||
}
|
||||
System.out.println("Test CondyEmptyBSMArray1 passed: " + e.getMessage());
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
}
|
||||
|
||||
// 3. No BootstrapMethods Attribute array present`
|
||||
try {
|
||||
Class newClass = Class.forName("CondyNoBSMArray");
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
} catch (java.lang.ClassFormatError e) {
|
||||
if (!e.getMessage().contains("Missing BootstrapMethods attribute in class file")) {
|
||||
throw new RuntimeException("ClassFormatError thrown, incorrect message");
|
||||
}
|
||||
System.out.println("Test CondyNoBSMArray passed: " + e.getMessage());
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
}
|
||||
}
|
||||
}
|
154
test/hotspot/jtreg/runtime/condy/CondyBadBSMIndex.jcod
Normal file
154
test/hotspot/jtreg/runtime/condy/CondyBadBSMIndex.jcod
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains a CONSTANT_Dynamic_info whose bootstrap_method_attr_index is bogus.
|
||||
* ClassFormatError expected.
|
||||
*/
|
||||
|
||||
/*
|
||||
class CondyBadBSMIndex {
|
||||
CondyBadBSMIndex() { }
|
||||
public static Object m() {
|
||||
// ldc Dynamic where the CONSTANT_Dynamic_info bootstrap_method_attr_index points at slot #5
|
||||
// in the bootstrap_methods array, however, the bootstrap_methods array is composed of only 1 slot.
|
||||
// Outcome -> java.lang.ClassFormatError: Short length on BootstrapMethods in class file CondyBadBSMIndex
|
||||
return of ldc's Object;
|
||||
public static void main(String[] args) { return; }
|
||||
}
|
||||
*/
|
||||
|
||||
class CondyBadBSMIndex {
|
||||
0xCAFEBABE;
|
||||
0; // minor version
|
||||
55; // version
|
||||
[] { // Constant Pool
|
||||
; // first element is empty
|
||||
Utf8 "java/lang/Object"; // #1
|
||||
class #1; // #2
|
||||
Utf8 "<init>"; // #3
|
||||
Utf8 "()V"; // #4
|
||||
NameAndType #3 #4; // #5
|
||||
Method #2 #5; // #6
|
||||
Utf8 "Code"; // #7
|
||||
Utf8 "CondyBadBSMIndex"; // #8
|
||||
class #8; // #9
|
||||
Utf8 "bsm"; // #10
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;"; // #11
|
||||
NameAndType #10 #11; // #12
|
||||
Method #9 #12; // #13
|
||||
MethodHandle 6b #13; // #14
|
||||
Utf8 "name"; // #15
|
||||
Utf8 "Ljava/lang/Object;"; // #16
|
||||
NameAndType #15 #16; // #17
|
||||
Dynamic 5s #17; // #18
|
||||
Utf8 "m"; // #19
|
||||
Utf8 "()Ljava/lang/Object;"; // #20
|
||||
Utf8 "main"; // #21
|
||||
Utf8 "([Ljava/lang/String;)V"; // #22
|
||||
Utf8 "BootstrapMethods"; // #23
|
||||
Utf8 "CondyBadBSMIndex"; // #24
|
||||
class #24; // #25
|
||||
} // Constant Pool
|
||||
|
||||
0x0000; // access
|
||||
#25;// this_cpx
|
||||
#2;// super_cpx
|
||||
|
||||
[] { // Interfaces
|
||||
} // Interfaces
|
||||
|
||||
[] { // fields
|
||||
} // fields
|
||||
|
||||
[] { // methods
|
||||
{ // Member
|
||||
0x0001; // access
|
||||
#3; // name_cpx
|
||||
#4; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0x2AB70006B1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#19; // name_cpx
|
||||
#20; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[]{
|
||||
0x1212B0;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#21; // name_cpx
|
||||
#22; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
0; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0xB1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
} // methods
|
||||
|
||||
[] { // Attributes
|
||||
Attr(#23) { // BootstrapMethods
|
||||
[] { // bootstrap_methods
|
||||
{ // bootstrap_method
|
||||
#14; // bootstrap_method_ref
|
||||
[] { // bootstrap_arguments
|
||||
} // bootstrap_arguments
|
||||
} // bootstrap_method
|
||||
}
|
||||
} // end BootstrapMethods
|
||||
} // Attributes
|
||||
} // end class CondyBadBSMIndex
|
254
test/hotspot/jtreg/runtime/condy/CondyBadLDC.jasm
Normal file
254
test/hotspot/jtreg/runtime/condy/CondyBadLDC.jasm
Normal file
@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains a incorrect ldc instruction of a condy whose loadable
|
||||
* constant is a double. VerifyError expected.
|
||||
*/
|
||||
|
||||
class CondyBadLDC
|
||||
version 55:0
|
||||
{
|
||||
|
||||
|
||||
public Method "<init>":"()V"
|
||||
stack 1 locals 1
|
||||
{
|
||||
aload_0;
|
||||
invokespecial Method java/lang/Object."<init>":"()V";
|
||||
return;
|
||||
}
|
||||
|
||||
public static Method intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;"
|
||||
throws java/lang/Throwable
|
||||
stack 4 locals 6
|
||||
{
|
||||
aload_1;
|
||||
astore 4;
|
||||
iconst_m1;
|
||||
istore 5;
|
||||
aload 4;
|
||||
invokevirtual Method java/lang/String.hashCode:"()I";
|
||||
lookupswitch{ //11
|
||||
-2001159796: L238;
|
||||
-1538095928: L272;
|
||||
-891985903: L255;
|
||||
66: L108;
|
||||
67: L124;
|
||||
68: L140;
|
||||
70: L156;
|
||||
73: L172;
|
||||
74: L188;
|
||||
83: L204;
|
||||
90: L221;
|
||||
default: L286 };
|
||||
L108: stack_frame_type append;
|
||||
locals_map class java/lang/String, int;
|
||||
aload 4;
|
||||
ldc String "B";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_0;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L124: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "C";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_1;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L140: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "D";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_2;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L156: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "F";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_3;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L172: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "I";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_4;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L188: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "J";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_5;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L204: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "S";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 6;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L221: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "Z";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 7;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L238: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "nullRef";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 8;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L255: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "string";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 9;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L272: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "stringArray";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 10;
|
||||
istore 5;
|
||||
L286: stack_frame_type same;
|
||||
iload 5;
|
||||
tableswitch{ //0 to 10
|
||||
0: L348;
|
||||
1: L354;
|
||||
2: L360;
|
||||
3: L366;
|
||||
4: L372;
|
||||
5: L377;
|
||||
6: L383;
|
||||
7: L389;
|
||||
8: L402;
|
||||
9: L404;
|
||||
10: L407;
|
||||
default: L422 };
|
||||
L348: stack_frame_type same;
|
||||
iload_3;
|
||||
i2b;
|
||||
invokestatic Method java/lang/Byte.valueOf:"(B)Ljava/lang/Byte;";
|
||||
areturn;
|
||||
L354: stack_frame_type same;
|
||||
iload_3;
|
||||
i2c;
|
||||
invokestatic Method java/lang/Character.valueOf:"(C)Ljava/lang/Character;";
|
||||
areturn;
|
||||
L360: stack_frame_type same;
|
||||
iload_3;
|
||||
i2d;
|
||||
invokestatic Method java/lang/Double.valueOf:"(D)Ljava/lang/Double;";
|
||||
areturn;
|
||||
L366: stack_frame_type same;
|
||||
iload_3;
|
||||
i2f;
|
||||
invokestatic Method java/lang/Float.valueOf:"(F)Ljava/lang/Float;";
|
||||
areturn;
|
||||
L372: stack_frame_type same;
|
||||
iload_3;
|
||||
invokestatic Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;";
|
||||
areturn;
|
||||
L377: stack_frame_type same;
|
||||
iload_3;
|
||||
i2l;
|
||||
invokestatic Method java/lang/Long.valueOf:"(J)Ljava/lang/Long;";
|
||||
areturn;
|
||||
L383: stack_frame_type same;
|
||||
iload_3;
|
||||
i2s;
|
||||
invokestatic Method java/lang/Short.valueOf:"(S)Ljava/lang/Short;";
|
||||
areturn;
|
||||
L389: stack_frame_type same;
|
||||
iload_3;
|
||||
ifle L397;
|
||||
iconst_1;
|
||||
goto L398;
|
||||
L397: stack_frame_type same;
|
||||
iconst_0;
|
||||
L398: stack_frame_type stack1;
|
||||
stack_map int;
|
||||
invokestatic Method java/lang/Boolean.valueOf:"(Z)Ljava/lang/Boolean;";
|
||||
areturn;
|
||||
L402: stack_frame_type same;
|
||||
aconst_null;
|
||||
areturn;
|
||||
L404: stack_frame_type same;
|
||||
ldc String "string";
|
||||
areturn;
|
||||
L407: stack_frame_type same;
|
||||
iconst_2;
|
||||
anewarray class java/lang/String;
|
||||
dup;
|
||||
iconst_0;
|
||||
ldc String "string";
|
||||
aastore;
|
||||
dup;
|
||||
iconst_1;
|
||||
ldc String "string";
|
||||
aastore;
|
||||
areturn;
|
||||
L422: stack_frame_type same;
|
||||
new class java/lang/BootstrapMethodError;
|
||||
dup;
|
||||
ldc String "Failure to generate a dynamic constant";
|
||||
invokespecial Method java/lang/BootstrapMethodError."<init>":"(Ljava/lang/String;)V";
|
||||
athrow;
|
||||
}
|
||||
|
||||
public static Method D:"()D"
|
||||
stack 2 locals 0
|
||||
{
|
||||
// ldc of a double will yield a VerifyError, should be an ldc2_w instruction
|
||||
ldc Dynamic REF_invokeStatic:CondyBadLDC.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":D:"D" int 2147483647;
|
||||
dreturn;
|
||||
}
|
||||
|
||||
public static Method main:"([Ljava/lang/String;)V"
|
||||
stack 2 locals 1
|
||||
{
|
||||
invokestatic Method D:"()D";
|
||||
return;
|
||||
}
|
||||
|
||||
} // end Class CondyBadLDC
|
252
test/hotspot/jtreg/runtime/condy/CondyBadLDC2_W.jasm
Normal file
252
test/hotspot/jtreg/runtime/condy/CondyBadLDC2_W.jasm
Normal file
@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains a ldc2_w instruction of a condy which returns a loadable float
|
||||
* constant. VerifyError expected.
|
||||
*/
|
||||
class CondyBadLDC2_W
|
||||
version 55:0
|
||||
{
|
||||
|
||||
public Method "<init>":"()V"
|
||||
stack 1 locals 1
|
||||
{
|
||||
aload_0;
|
||||
invokespecial Method java/lang/Object."<init>":"()V";
|
||||
return;
|
||||
}
|
||||
|
||||
public static Method intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;"
|
||||
throws java/lang/Throwable
|
||||
stack 4 locals 6
|
||||
{
|
||||
aload_1;
|
||||
astore 4;
|
||||
iconst_m1;
|
||||
istore 5;
|
||||
aload 4;
|
||||
invokevirtual Method java/lang/String.hashCode:"()I";
|
||||
lookupswitch{ //11
|
||||
-2001159796: L238;
|
||||
-1538095928: L272;
|
||||
-891985903: L255;
|
||||
66: L108;
|
||||
67: L124;
|
||||
68: L140;
|
||||
70: L156;
|
||||
73: L172;
|
||||
74: L188;
|
||||
83: L204;
|
||||
90: L221;
|
||||
default: L286 };
|
||||
L108: stack_frame_type append;
|
||||
locals_map class java/lang/String, int;
|
||||
aload 4;
|
||||
ldc String "B";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_0;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L124: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "C";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_1;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L140: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "D";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_2;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L156: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "F";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_3;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L172: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "I";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_4;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L188: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "J";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_5;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L204: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "S";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 6;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L221: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "Z";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 7;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L238: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "nullRef";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 8;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L255: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "string";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 9;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L272: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "stringArray";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 10;
|
||||
istore 5;
|
||||
L286: stack_frame_type same;
|
||||
iload 5;
|
||||
tableswitch{ //0 to 10
|
||||
0: L348;
|
||||
1: L354;
|
||||
2: L360;
|
||||
3: L366;
|
||||
4: L372;
|
||||
5: L377;
|
||||
6: L383;
|
||||
7: L389;
|
||||
8: L402;
|
||||
9: L404;
|
||||
10: L407;
|
||||
default: L422 };
|
||||
L348: stack_frame_type same;
|
||||
iload_3;
|
||||
i2b;
|
||||
invokestatic Method java/lang/Byte.valueOf:"(B)Ljava/lang/Byte;";
|
||||
areturn;
|
||||
L354: stack_frame_type same;
|
||||
iload_3;
|
||||
i2c;
|
||||
invokestatic Method java/lang/Character.valueOf:"(C)Ljava/lang/Character;";
|
||||
areturn;
|
||||
L360: stack_frame_type same;
|
||||
iload_3;
|
||||
i2d;
|
||||
invokestatic Method java/lang/Double.valueOf:"(D)Ljava/lang/Double;";
|
||||
areturn;
|
||||
L366: stack_frame_type same;
|
||||
iload_3;
|
||||
i2f;
|
||||
invokestatic Method java/lang/Float.valueOf:"(F)Ljava/lang/Float;";
|
||||
areturn;
|
||||
L372: stack_frame_type same;
|
||||
iload_3;
|
||||
invokestatic Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;";
|
||||
areturn;
|
||||
L377: stack_frame_type same;
|
||||
iload_3;
|
||||
i2l;
|
||||
invokestatic Method java/lang/Long.valueOf:"(J)Ljava/lang/Long;";
|
||||
areturn;
|
||||
L383: stack_frame_type same;
|
||||
iload_3;
|
||||
i2s;
|
||||
invokestatic Method java/lang/Short.valueOf:"(S)Ljava/lang/Short;";
|
||||
areturn;
|
||||
L389: stack_frame_type same;
|
||||
iload_3;
|
||||
ifle L397;
|
||||
iconst_1;
|
||||
goto L398;
|
||||
L397: stack_frame_type same;
|
||||
iconst_0;
|
||||
L398: stack_frame_type stack1;
|
||||
stack_map int;
|
||||
invokestatic Method java/lang/Boolean.valueOf:"(Z)Ljava/lang/Boolean;";
|
||||
areturn;
|
||||
L402: stack_frame_type same;
|
||||
aconst_null;
|
||||
areturn;
|
||||
L404: stack_frame_type same;
|
||||
ldc String "string";
|
||||
areturn;
|
||||
L407: stack_frame_type same;
|
||||
iconst_2;
|
||||
anewarray class java/lang/String;
|
||||
dup;
|
||||
iconst_0;
|
||||
ldc String "string";
|
||||
aastore;
|
||||
dup;
|
||||
iconst_1;
|
||||
ldc String "string";
|
||||
aastore;
|
||||
areturn;
|
||||
L422: stack_frame_type same;
|
||||
new class java/lang/BootstrapMethodError;
|
||||
dup;
|
||||
ldc String "Failure to generate a dynamic constant";
|
||||
invokespecial Method java/lang/BootstrapMethodError."<init>":"(Ljava/lang/String;)V";
|
||||
athrow;
|
||||
}
|
||||
|
||||
public static Method F:"()F"
|
||||
stack 1 locals 0
|
||||
{
|
||||
// VerifyError, ldc2_w of a float, should be ldc
|
||||
ldc2_w Dynamic REF_invokeStatic:CondyBadLDC2_W.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":F:"F" int 2147483647;
|
||||
freturn;
|
||||
}
|
||||
|
||||
public static Method main:"([Ljava/lang/String;)V"
|
||||
stack 1 locals 1
|
||||
{
|
||||
invokestatic Method F:"()F";
|
||||
return;
|
||||
}
|
||||
|
||||
} // end Class CondyBadLDC2_W
|
154
test/hotspot/jtreg/runtime/condy/CondyBadNameType.jcod
Normal file
154
test/hotspot/jtreg/runtime/condy/CondyBadNameType.jcod
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains a CONSTANT_Dynamic_info structure whose name_and_type_index
|
||||
* does not point at a CONSTANT_NameAndType_info structure. ClassFormatError expected.
|
||||
*/
|
||||
|
||||
/*
|
||||
class CondyBadNameType {
|
||||
CondyBadNameType() { }
|
||||
public static Object m() {
|
||||
// ldc Dynamic where the CONSTANT_Dynamic_info name_and_type_index erroneously points
|
||||
// at a Utf8 instead of the expected CONSTANT_NameAndType.
|
||||
// Outcome -> java.lang.ClassFormatError: Invalid constant pool index 16 in class file CondyBadNameType
|
||||
return of ldc's Object;
|
||||
public static void main(String[] args) { return; }
|
||||
}
|
||||
*/
|
||||
|
||||
class CondyBadNameType {
|
||||
0xCAFEBABE;
|
||||
0; // minor version
|
||||
55; // version
|
||||
[] { // Constant Pool
|
||||
; // first element is empty
|
||||
Utf8 "java/lang/Object"; // #1
|
||||
class #1; // #2
|
||||
Utf8 "<init>"; // #3
|
||||
Utf8 "()V"; // #4
|
||||
NameAndType #3 #4; // #5
|
||||
Method #2 #5; // #6
|
||||
Utf8 "Code"; // #7
|
||||
Utf8 "CondyBadNameType"; // #8
|
||||
class #8; // #9
|
||||
Utf8 "bsm"; // #10
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;"; // #11
|
||||
NameAndType #10 #11; // #12
|
||||
Method #9 #12; // #13
|
||||
MethodHandle 6b #13; // #14
|
||||
Utf8 "name"; // #15
|
||||
Utf8 "Ljava/lang/Object;"; // #16
|
||||
NameAndType #15 #16; // #17
|
||||
Dynamic 0s #16; // #18
|
||||
Utf8 "m"; // #19
|
||||
Utf8 "()Ljava/lang/Object;"; // #20
|
||||
Utf8 "main"; // #21
|
||||
Utf8 "([Ljava/lang/String;)V"; // #22
|
||||
Utf8 "BootstrapMethods"; // #23
|
||||
Utf8 "CondyBadNameType"; // #24
|
||||
class #24; // #25
|
||||
} // Constant Pool
|
||||
|
||||
0x0000; // access
|
||||
#25;// this_cpx
|
||||
#2;// super_cpx
|
||||
|
||||
[] { // Interfaces
|
||||
} // Interfaces
|
||||
|
||||
[] { // fields
|
||||
} // fields
|
||||
|
||||
[] { // methods
|
||||
{ // Member
|
||||
0x0001; // access
|
||||
#3; // name_cpx
|
||||
#4; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0x2AB70006B1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#19; // name_cpx
|
||||
#20; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[]{
|
||||
0x1212B0;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#21; // name_cpx
|
||||
#22; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
0; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0xB1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
} // methods
|
||||
|
||||
[] { // Attributes
|
||||
Attr(#23) { // BootstrapMethods
|
||||
[] { // bootstrap_methods
|
||||
{ // bootstrap_method
|
||||
#14; // bootstrap_method_ref
|
||||
[] { // bootstrap_arguments
|
||||
} // bootstrap_arguments
|
||||
} // bootstrap_method
|
||||
}
|
||||
} // end BootstrapMethods
|
||||
} // Attributes
|
||||
} // end class CondyBadNameType
|
49
test/hotspot/jtreg/runtime/condy/CondyBadNameTypeTest.java
Normal file
49
test/hotspot/jtreg/runtime/condy/CondyBadNameTypeTest.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8186211
|
||||
* @summary CONSTANT_Dynamic_info structure's name_and_type_index item does not point at CONSANT_NameAndType_info
|
||||
* @requires os.arch != "sparcv9"
|
||||
* @compile CondyBadNameType.jcod
|
||||
* @run main/othervm -Xverify:all CondyBadNameTypeTest
|
||||
*/
|
||||
|
||||
// Test a CONSTANT_Dynamic_info structure's name_and_type_index points at a
|
||||
// constant pool NameAndType_info structure.
|
||||
public class CondyBadNameTypeTest {
|
||||
public static void main(String args[]) throws Throwable {
|
||||
try {
|
||||
Class newClass = Class.forName("CondyBadNameType");
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
} catch (java.lang.ClassFormatError e) {
|
||||
if (!e.getMessage().contains("Invalid constant pool index")) {
|
||||
throw new RuntimeException("ClassFormatError thrown, incorrect message");
|
||||
}
|
||||
System.out.println("Test CondyBadNameTypeTest passed: " + e.getMessage());
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
}
|
||||
}
|
||||
}
|
152
test/hotspot/jtreg/runtime/condy/CondyCFVCheck.jcod
Normal file
152
test/hotspot/jtreg/runtime/condy/CondyCFVCheck.jcod
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains a CONSTANT_Dynamic_info structure in a version 54 class file.
|
||||
*/
|
||||
|
||||
/*
|
||||
class CondyCFVCheck {
|
||||
CondyCondyCFVCheck() {}
|
||||
public static Object m() {
|
||||
// ldc Dynamic
|
||||
// Outcome -> java.lang.ClassFormatError: Class file version does not support constant tag 17 in class file CondyCFVCheck
|
||||
return of ldc's Object;
|
||||
public static void main(String[] args) { return; }
|
||||
}
|
||||
*/
|
||||
|
||||
class CondyCFVCheck {
|
||||
0xCAFEBABE;
|
||||
0; // minor version
|
||||
54; // version
|
||||
[] { // Constant Pool
|
||||
; // first element is empty
|
||||
Utf8 "java/lang/Object"; // #1
|
||||
class #1; // #2
|
||||
Utf8 "<init>"; // #3
|
||||
Utf8 "()V"; // #4
|
||||
NameAndType #3 #4; // #5
|
||||
Method #2 #5; // #6
|
||||
Utf8 "Code"; // #7
|
||||
Utf8 "CondyCFVCheck"; // #8
|
||||
class #8; // #9
|
||||
Utf8 "bsm"; // #10
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;"; // #11
|
||||
NameAndType #10 #11; // #12
|
||||
Method #9 #12; // #13
|
||||
MethodHandle 6b #13; // #14
|
||||
Utf8 "name"; // #15
|
||||
Utf8 "Ljava/lang/Object;"; // #16
|
||||
NameAndType #15 #16; // #17
|
||||
Dynamic 0s #17; // #18
|
||||
Utf8 "m"; // #19
|
||||
Utf8 "()Ljava/lang/Object;"; // #20
|
||||
Utf8 "main"; // #21
|
||||
Utf8 "([Ljava/lang/String;)V"; // #22
|
||||
Utf8 "BootstrapMethods"; // #23
|
||||
Utf8 "CondyCFVCheck"; // #24
|
||||
class #24; // #25
|
||||
} // Constant Pool
|
||||
|
||||
0x0000; // access
|
||||
#25;// this_cpx
|
||||
#2;// super_cpx
|
||||
|
||||
[] { // Interfaces
|
||||
} // Interfaces
|
||||
|
||||
[] { // fields
|
||||
} // fields
|
||||
|
||||
[] { // methods
|
||||
{ // Member
|
||||
0x0001; // access
|
||||
#3; // name_cpx
|
||||
#4; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0x2AB70006B1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#19; // name_cpx
|
||||
#20; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[]{
|
||||
0x1212B0;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#21; // name_cpx
|
||||
#22; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
0; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0xB1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
} // methods
|
||||
|
||||
[] { // Attributes
|
||||
Attr(#23) { // BootstrapMethods
|
||||
[] { // bootstrap_methods
|
||||
{ // bootstrap_method
|
||||
#14; // bootstrap_method_ref
|
||||
[] { // bootstrap_arguments
|
||||
} // bootstrap_arguments
|
||||
} // bootstrap_method
|
||||
}
|
||||
} // end BootstrapMethods
|
||||
} // Attributes
|
||||
} // end class CondyCFVCheck
|
49
test/hotspot/jtreg/runtime/condy/CondyCFVCheckTest.java
Normal file
49
test/hotspot/jtreg/runtime/condy/CondyCFVCheckTest.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8186211
|
||||
* @summary CONSTANT_Dynamic_info structure present within an unsupported class file version.
|
||||
* @requires os.arch != "sparcv9"
|
||||
* @compile CondyCFVCheck.jcod
|
||||
* @run main/othervm -Xverify:all CondyCFVCheckTest
|
||||
*/
|
||||
|
||||
// Test a CONSTANT_Dynamic_info structure present within an unsupported class file version
|
||||
// yields a ClassFormatError.
|
||||
public class CondyCFVCheckTest {
|
||||
public static void main(String args[]) throws Throwable {
|
||||
try {
|
||||
Class newClass = Class.forName("CondyCFVCheck");
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
} catch (java.lang.ClassFormatError e) {
|
||||
if (!e.getMessage().contains("Class file version does not support constant tag 17 in class file")) {
|
||||
throw new RuntimeException("ClassFormatError thrown, incorrect message");
|
||||
}
|
||||
System.out.println("Test CondyCFVCheckTest passed: " + e.getMessage());
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||
}
|
||||
}
|
||||
}
|
149
test/hotspot/jtreg/runtime/condy/CondyEmptyBSMArray1.jcod
Normal file
149
test/hotspot/jtreg/runtime/condy/CondyEmptyBSMArray1.jcod
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains a CONSTANT_Dynamic_info structure, but the BootstrapMethods Attribute
|
||||
* contains bootstrap_methods array with 0 elements. ClassFormatError expected.
|
||||
*/
|
||||
|
||||
/*
|
||||
class CondyEmptyBSMArray1 {
|
||||
CondyEmptyBSMArray1() {}
|
||||
public static Object m() {
|
||||
// ldc Dynamic where the CONSTANT_Dynamic_info bootstrap_method_attr_index points to slot #0
|
||||
// in the bootstrap_methods array, however the BootstrapMethods array is empty.
|
||||
// Outcome -> java.lang.ClassFormatError: Short length on BootstrapMethods in class file CondyEmptyBSMArray1
|
||||
return of ldc's Object;
|
||||
public static void main(String[] args) { return; }
|
||||
}
|
||||
*/
|
||||
|
||||
class CondyEmptyBSMArray1 {
|
||||
0xCAFEBABE;
|
||||
0; // minor version
|
||||
55; // version
|
||||
[] { // Constant Pool
|
||||
; // first element is empty
|
||||
Utf8 "java/lang/Object"; // #1
|
||||
class #1; // #2
|
||||
Utf8 "<init>"; // #3
|
||||
Utf8 "()V"; // #4
|
||||
NameAndType #3 #4; // #5
|
||||
Method #2 #5; // #6
|
||||
Utf8 "Code"; // #7
|
||||
Utf8 "CondyEmptyBSMArray1"; // #8
|
||||
class #8; // #9
|
||||
Utf8 "bsm"; // #10
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;"; // #11
|
||||
NameAndType #10 #11; // #12
|
||||
Method #9 #12; // #13
|
||||
MethodHandle 6b #13; // #14
|
||||
Utf8 "name"; // #15
|
||||
Utf8 "Ljava/lang/Object;"; // #16
|
||||
NameAndType #15 #16; // #17
|
||||
Dynamic 0s #17; // #18
|
||||
Utf8 "m"; // #19
|
||||
Utf8 "()Ljava/lang/Object;"; // #20
|
||||
Utf8 "main"; // #21
|
||||
Utf8 "([Ljava/lang/String;)V"; // #22
|
||||
Utf8 "BootstrapMethods"; // #23
|
||||
Utf8 "CondyEmptyBSMArray1"; // #24
|
||||
class #24; // #25
|
||||
} // Constant Pool
|
||||
|
||||
0x0000; // access
|
||||
#25;// this_cpx
|
||||
#2;// super_cpx
|
||||
|
||||
[] { // Interfaces
|
||||
} // Interfaces
|
||||
|
||||
[] { // fields
|
||||
} // fields
|
||||
|
||||
[] { // methods
|
||||
{ // Member
|
||||
0x0001; // access
|
||||
#3; // name_cpx
|
||||
#4; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0x2AB70006B1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#19; // name_cpx
|
||||
#20; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[]{
|
||||
0x1212B0;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#21; // name_cpx
|
||||
#22; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
0; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0xB1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
} // methods
|
||||
|
||||
[] { // Attributes
|
||||
Attr(#23) { // BootstrapMethods
|
||||
[0] { // bootstrap_methods
|
||||
}
|
||||
} // end BootstrapMethods
|
||||
} // Attributes
|
||||
} // end class CondyEmptyBSMArray1
|
66
test/hotspot/jtreg/runtime/condy/CondyLDCTest.java
Normal file
66
test/hotspot/jtreg/runtime/condy/CondyLDCTest.java
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8186211
|
||||
* @summary Tests various ldc, ldc_w, ldc2_w instructions of CONSTANT_Dynamic.
|
||||
* @requires os.arch != "sparcv9"
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib
|
||||
* @compile CondyUseLDC_W.jasm
|
||||
* @compile CondyBadLDC2_W.jasm
|
||||
* @compile CondyBadLDC.jasm
|
||||
* @run main/othervm -Xverify:all CondyLDCTest
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.compiler.InMemoryJavaCompiler;
|
||||
|
||||
public class CondyLDCTest {
|
||||
public static void main(String args[]) throws Throwable {
|
||||
// 1. Test a ldc_w instruction can be used with condy's which generate
|
||||
// loadable constants of the following types: byte, char, short, float, integer, boolean.
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("CondyUseLDC_W");
|
||||
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
|
||||
oa.shouldNotContain("VerifyError");
|
||||
oa.shouldHaveExitValue(0);
|
||||
|
||||
// 2. Test ldc2_w of a condy which returns a dynamically generated
|
||||
// float constant, generates a VerifyError.
|
||||
pb = ProcessTools.createJavaProcessBuilder("CondyBadLDC2_W");
|
||||
oa = new OutputAnalyzer(pb.start());
|
||||
oa.shouldContain("java.lang.VerifyError: Illegal type at constant pool entry");
|
||||
oa.shouldContain("CondyBadLDC2_W.F()F @0: ldc2_w");
|
||||
oa.shouldHaveExitValue(1);
|
||||
|
||||
// 3. Test a ldc of a condy which returns a dynamically generated
|
||||
// double constant, generates a VerifyError.
|
||||
pb = ProcessTools.createJavaProcessBuilder("CondyBadLDC");
|
||||
oa = new OutputAnalyzer(pb.start());
|
||||
oa.shouldContain("java.lang.VerifyError: Illegal type at constant pool entry");
|
||||
oa.shouldContain("CondyBadLDC.D()D @0: ldc");
|
||||
oa.shouldHaveExitValue(1);
|
||||
}
|
||||
}
|
48
test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecial.jasm
Normal file
48
test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecial.jasm
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
super public class CondyNewInvokeSpecial
|
||||
version 55:0
|
||||
{
|
||||
|
||||
public Method "<init>":"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)V"
|
||||
stack 3 locals 4
|
||||
{
|
||||
aload_0;
|
||||
invokespecial Method java/lang/Object."<init>":"()V";
|
||||
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
|
||||
ldc String "In CondyNewInvokeSpecial <init> method";
|
||||
invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
|
||||
return;
|
||||
}
|
||||
|
||||
public static Method main:"([Ljava/lang/String;)V"
|
||||
stack 3 locals 1
|
||||
{
|
||||
new class CondyNewInvokeSpecial;
|
||||
dup;
|
||||
ldc Dynamic REF_newInvokeSpecial:CondyNewInvokeSpecial."<init>":"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)V":CondyNewInvokeSpecial:"Ljava/lang/Object;";
|
||||
return;
|
||||
}
|
||||
|
||||
} // end Class CondyNewInvokeSpecial
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8186211
|
||||
* @summary Test CONSTANT_Dynamic where the BSM is invoked via a REF_newInvokeSpecial.
|
||||
* @requires os.arch != "sparcv9"
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib
|
||||
* @compile CondyNewInvokeSpecial.jasm
|
||||
* @run main/othervm -Xverify:all CondyNewInvokeSpecialTest
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.compiler.InMemoryJavaCompiler;
|
||||
|
||||
public class CondyNewInvokeSpecialTest {
|
||||
public static void main(String args[]) throws Throwable {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("CondyNewInvokeSpecial");
|
||||
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
|
||||
oa.shouldContain("In CondyNewInvokeSpecial <init> method");
|
||||
oa.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
145
test/hotspot/jtreg/runtime/condy/CondyNoBSMArray.jcod
Normal file
145
test/hotspot/jtreg/runtime/condy/CondyNoBSMArray.jcod
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains a CONSTANT_Dynamic_info structure but the class file contains
|
||||
* no BootstrapMethods Attribute array. ClassFormatError expected.
|
||||
*/
|
||||
|
||||
/*
|
||||
class CondyNoBSMArray {
|
||||
CondyNoBSMArray() {}
|
||||
public static Object m() {
|
||||
// ldc Dynamic where the CONSTANT_Dynamic_info bootstrap_method_attr_index points to slot #0
|
||||
// in the bootstrap_methods array, however the BootstrapMethods array is non-existent.
|
||||
// Outcome -> java.lang.ClassFormatError: Missing BootstrapMethods attribute in class file CondyNoBSMArray
|
||||
return of ldc's Object;
|
||||
public static void main(String[] args) { return; }
|
||||
}
|
||||
*/
|
||||
|
||||
class CondyNoBSMArray {
|
||||
0xCAFEBABE;
|
||||
0; // minor version
|
||||
55; // version
|
||||
[] { // Constant Pool
|
||||
; // first element is empty
|
||||
Utf8 "java/lang/Object"; // #1
|
||||
class #1; // #2
|
||||
Utf8 "<init>"; // #3
|
||||
Utf8 "()V"; // #4
|
||||
NameAndType #3 #4; // #5
|
||||
Method #2 #5; // #6
|
||||
Utf8 "Code"; // #7
|
||||
Utf8 "CondyNoBSMArray"; // #8
|
||||
class #8; // #9
|
||||
Utf8 "bsm"; // #10
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;"; // #11
|
||||
NameAndType #10 #11; // #12
|
||||
Method #9 #12; // #13
|
||||
MethodHandle 6b #13; // #14
|
||||
Utf8 "name"; // #15
|
||||
Utf8 "Ljava/lang/Object;"; // #16
|
||||
NameAndType #15 #16; // #17
|
||||
Dynamic 0s #17; // #18
|
||||
Utf8 "m"; // #19
|
||||
Utf8 "()Ljava/lang/Object;"; // #20
|
||||
Utf8 "main"; // #21
|
||||
Utf8 "([Ljava/lang/String;)V"; // #22
|
||||
Utf8 "BootstrapMethods"; // #23
|
||||
Utf8 "CondyNoBSMArray"; // #24
|
||||
class #24; // #25
|
||||
} // Constant Pool
|
||||
|
||||
0x0000; // access
|
||||
#25;// this_cpx
|
||||
#2;// super_cpx
|
||||
|
||||
[] { // Interfaces
|
||||
} // Interfaces
|
||||
|
||||
[] { // fields
|
||||
} // fields
|
||||
|
||||
[] { // methods
|
||||
{ // Member
|
||||
0x0001; // access
|
||||
#3; // name_cpx
|
||||
#4; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0x2AB70006B1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#19; // name_cpx
|
||||
#20; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[]{
|
||||
0x1212B0;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#21; // name_cpx
|
||||
#22; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
0; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0xB1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
} // methods
|
||||
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end class CondyNoBSMArray
|
307
test/hotspot/jtreg/runtime/condy/CondyUseLDC_W.jasm
Normal file
307
test/hotspot/jtreg/runtime/condy/CondyUseLDC_W.jasm
Normal file
@ -0,0 +1,307 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains ldc_w instructions of condy's who generate dynamic constants
|
||||
* of the following types: byte, char, short, int, float, boolean.
|
||||
*/
|
||||
class CondyUseLDC_W
|
||||
version 55:0
|
||||
{
|
||||
|
||||
public Method "<init>":"()V"
|
||||
stack 1 locals 1
|
||||
{
|
||||
aload_0;
|
||||
invokespecial Method java/lang/Object."<init>":"()V";
|
||||
return;
|
||||
}
|
||||
|
||||
public static Method intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;"
|
||||
throws java/lang/Throwable
|
||||
stack 4 locals 6
|
||||
{
|
||||
aload_1;
|
||||
astore 4;
|
||||
iconst_m1;
|
||||
istore 5;
|
||||
aload 4;
|
||||
invokevirtual Method java/lang/String.hashCode:"()I";
|
||||
lookupswitch{ //11
|
||||
-2001159796: L238;
|
||||
-1538095928: L272;
|
||||
-891985903: L255;
|
||||
66: L108;
|
||||
67: L124;
|
||||
68: L140;
|
||||
70: L156;
|
||||
73: L172;
|
||||
74: L188;
|
||||
83: L204;
|
||||
90: L221;
|
||||
default: L286 };
|
||||
L108: stack_frame_type append;
|
||||
locals_map class java/lang/String, int;
|
||||
aload 4;
|
||||
ldc String "B";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_0;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L124: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "C";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_1;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L140: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "D";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_2;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L156: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "F";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_3;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L172: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "I";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_4;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L188: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "J";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
iconst_5;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L204: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "S";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 6;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L221: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "Z";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 7;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L238: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "nullRef";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 8;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L255: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "string";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 9;
|
||||
istore 5;
|
||||
goto L286;
|
||||
L272: stack_frame_type same;
|
||||
aload 4;
|
||||
ldc String "stringArray";
|
||||
invokevirtual Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
|
||||
ifeq L286;
|
||||
bipush 10;
|
||||
istore 5;
|
||||
L286: stack_frame_type same;
|
||||
iload 5;
|
||||
tableswitch{ //0 to 10
|
||||
0: L348;
|
||||
1: L354;
|
||||
2: L360;
|
||||
3: L366;
|
||||
4: L372;
|
||||
5: L377;
|
||||
6: L383;
|
||||
7: L389;
|
||||
8: L402;
|
||||
9: L404;
|
||||
10: L407;
|
||||
default: L422 };
|
||||
L348: stack_frame_type same;
|
||||
iload_3;
|
||||
i2b;
|
||||
invokestatic Method java/lang/Byte.valueOf:"(B)Ljava/lang/Byte;";
|
||||
areturn;
|
||||
L354: stack_frame_type same;
|
||||
iload_3;
|
||||
i2c;
|
||||
invokestatic Method java/lang/Character.valueOf:"(C)Ljava/lang/Character;";
|
||||
areturn;
|
||||
L360: stack_frame_type same;
|
||||
iload_3;
|
||||
i2d;
|
||||
invokestatic Method java/lang/Double.valueOf:"(D)Ljava/lang/Double;";
|
||||
areturn;
|
||||
L366: stack_frame_type same;
|
||||
iload_3;
|
||||
i2f;
|
||||
invokestatic Method java/lang/Float.valueOf:"(F)Ljava/lang/Float;";
|
||||
areturn;
|
||||
L372: stack_frame_type same;
|
||||
iload_3;
|
||||
invokestatic Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;";
|
||||
areturn;
|
||||
L377: stack_frame_type same;
|
||||
iload_3;
|
||||
i2l;
|
||||
invokestatic Method java/lang/Long.valueOf:"(J)Ljava/lang/Long;";
|
||||
areturn;
|
||||
L383: stack_frame_type same;
|
||||
iload_3;
|
||||
i2s;
|
||||
invokestatic Method java/lang/Short.valueOf:"(S)Ljava/lang/Short;";
|
||||
areturn;
|
||||
L389: stack_frame_type same;
|
||||
iload_3;
|
||||
ifle L397;
|
||||
iconst_1;
|
||||
goto L398;
|
||||
L397: stack_frame_type same;
|
||||
iconst_0;
|
||||
L398: stack_frame_type stack1;
|
||||
stack_map int;
|
||||
invokestatic Method java/lang/Boolean.valueOf:"(Z)Ljava/lang/Boolean;";
|
||||
areturn;
|
||||
L402: stack_frame_type same;
|
||||
aconst_null;
|
||||
areturn;
|
||||
L404: stack_frame_type same;
|
||||
ldc String "string";
|
||||
areturn;
|
||||
L407: stack_frame_type same;
|
||||
iconst_2;
|
||||
anewarray class java/lang/String;
|
||||
dup;
|
||||
iconst_0;
|
||||
ldc String "string";
|
||||
aastore;
|
||||
dup;
|
||||
iconst_1;
|
||||
ldc String "string";
|
||||
aastore;
|
||||
areturn;
|
||||
L422: stack_frame_type same;
|
||||
new class java/lang/BootstrapMethodError;
|
||||
dup;
|
||||
ldc String "Failure to generate a dynamic constant";
|
||||
invokespecial Method java/lang/BootstrapMethodError."<init>":"(Ljava/lang/String;)V";
|
||||
athrow;
|
||||
}
|
||||
|
||||
public static Method B:"()B"
|
||||
stack 1 locals 0
|
||||
{
|
||||
ldc_w Dynamic REF_invokeStatic:CondyUseLDC_W.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":B:"B" int 127;
|
||||
ireturn;
|
||||
}
|
||||
|
||||
public static Method C:"()C"
|
||||
stack 1 locals 0
|
||||
{
|
||||
ldc_w Dynamic REF_invokeStatic:CondyUseLDC_W.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":C:"C" int 65535;
|
||||
ireturn;
|
||||
}
|
||||
|
||||
public static Method F:"()F"
|
||||
stack 1 locals 0
|
||||
{
|
||||
ldc_w Dynamic REF_invokeStatic:CondyUseLDC_W.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":F:"F" int 2147483647;
|
||||
freturn;
|
||||
}
|
||||
|
||||
public static Method F_AsType:"()F"
|
||||
stack 1 locals 0
|
||||
{
|
||||
ldc_w Dynamic REF_invokeStatic:CondyUseLDC_W.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":I:"F" int 2147483647;
|
||||
freturn;
|
||||
}
|
||||
|
||||
public static Method I:"()I"
|
||||
stack 1 locals 0
|
||||
{
|
||||
ldc_w Dynamic REF_invokeStatic:CondyUseLDC_W.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":I:"I" int 2147483647;
|
||||
ireturn;
|
||||
}
|
||||
|
||||
public static Method S:"()S"
|
||||
stack 1 locals 0
|
||||
{
|
||||
ldc_w Dynamic REF_invokeStatic:CondyUseLDC_W.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":S:"S" int 32767;
|
||||
ireturn;
|
||||
}
|
||||
|
||||
public static Method Z_F:"()Z"
|
||||
stack 1 locals 0
|
||||
{
|
||||
ldc_w Dynamic REF_invokeStatic:CondyUseLDC_W.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":Z:"Z" int 0;
|
||||
ireturn;
|
||||
}
|
||||
|
||||
public static Method Z_T:"()Z"
|
||||
stack 1 locals 0
|
||||
{
|
||||
ldc_w Dynamic REF_invokeStatic:CondyUseLDC_W.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":Z:"Z" int 1;
|
||||
ireturn;
|
||||
}
|
||||
|
||||
public static Method main:"([Ljava/lang/String;)V"
|
||||
stack 8 locals 1
|
||||
{
|
||||
invokestatic Method B:"()B";
|
||||
invokestatic Method C:"()C";
|
||||
invokestatic Method S:"()S";
|
||||
invokestatic Method F:"()F";
|
||||
invokestatic Method F_AsType:"()F";
|
||||
invokestatic Method Z_F:"()Z";
|
||||
invokestatic Method Z_T:"()Z";
|
||||
invokestatic Method I:"()I";
|
||||
return;
|
||||
}
|
||||
|
||||
} // end Class CondyUseLDC_W
|
332
test/hotspot/jtreg/runtime/condy/CondyUsesIndyBSM.jcod
Normal file
332
test/hotspot/jtreg/runtime/condy/CondyUsesIndyBSM.jcod
Normal file
@ -0,0 +1,332 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains a CONSTANT_Dynamic_info structure whose bootstrap_method_attr_index
|
||||
* points to a BSM for an invokedynamic. Both the condy & indy point at element 0 in the
|
||||
* bootstrap methods array. BootstrapMethodError expected.
|
||||
*/
|
||||
|
||||
/*
|
||||
class CondyUsesIndyBSM {
|
||||
CondyUsesIndyBSM() { }
|
||||
public static Object Condybsm(java.lang.invoke.MethodHandles$Lookup, java.lang.String, java.lang.Class) {
|
||||
System.out.println("In Condybsm");
|
||||
return String(0);
|
||||
}
|
||||
public static int foo() {
|
||||
System.out.println("In Indybsm target CallSite method foo");
|
||||
return 100;
|
||||
}
|
||||
public static MethodHandle MH_foo() {
|
||||
// Constructs a MethodHandle for foo
|
||||
Lookup lookup = MethodHandles.lookup();
|
||||
MethodType mt = MethodType.methodType(int.class);
|
||||
return lookup.findStatic(CondyUsesIndyBSM.class, "foo", mt);
|
||||
}
|
||||
public static CallSite Indybsm(java.lang.invoke.MethodHandles$Lookup, java.lang.String, java.lang.invoke.MethodType) {
|
||||
return new CallSite(CondyUsesIndyBSM.MH_foo());
|
||||
}
|
||||
public static Object m() {
|
||||
// invokedynamic where the BSM = slot #0 in the BootstrapMethods array is CondyUsesIndyBSM.Indybsm() -> succeeds
|
||||
// ldc_w dynamic where the BSM = slot #0 in the BootstrapMethods array is CondyUsesIndyBSM.Indybsm() -> receives a BootstrapMethodError
|
||||
return of ldc's Object;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
CondyUsesIndyBSM.m();
|
||||
return;
|
||||
}
|
||||
|
||||
BootstrapMethods:
|
||||
0: #70 REF_invokeStatic CondyUsesIndyBSM.Indybsm:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
|
||||
Method arguments:
|
||||
1: #75 REF_invokeStatic CondyUsesIndyBSM.Condybsm:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;
|
||||
Method arguments:
|
||||
}
|
||||
*/
|
||||
|
||||
class CondyUsesIndyBSM {
|
||||
0xCAFEBABE;
|
||||
0; // minor version
|
||||
55; // version
|
||||
[] { // Constant Pool
|
||||
; // first element is empty
|
||||
Utf8 "java/lang/Object"; // #1
|
||||
class #1; // #2
|
||||
Utf8 "<init>"; // #3
|
||||
Utf8 "()V"; // #4
|
||||
NameAndType #3 #4; // #5
|
||||
Method #2 #5; // #6
|
||||
Utf8 "Code"; // #7
|
||||
Utf8 "java/lang/System"; // #8
|
||||
class #8; // #9
|
||||
Utf8 "out"; // #10
|
||||
Utf8 "Ljava/io/PrintStream;"; // #11
|
||||
NameAndType #10 #11; // #12
|
||||
Field #9 #12; // #13
|
||||
Utf8 "In Condybsm"; // #14
|
||||
String #14; // #15
|
||||
Utf8 "java/io/PrintStream"; // #16
|
||||
class #16; // #17
|
||||
Utf8 "println"; // #18
|
||||
Utf8 "(Ljava/lang/String;)V"; // #19
|
||||
NameAndType #18 #19; // #20
|
||||
Method #17 #20; // #21
|
||||
Utf8 "0"; // #22
|
||||
String #22; // #23
|
||||
Utf8 "Condybsm"; // #24
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;"; // #25
|
||||
Utf8 "In Indybsm target CallSite method foo"; // #26
|
||||
String #26; // #27
|
||||
Utf8 "foo"; // #28
|
||||
Utf8 "()I"; // #29
|
||||
Utf8 "java/lang/invoke/MethodHandles"; // #30
|
||||
class #30; // #31
|
||||
Utf8 "lookup"; // #32
|
||||
Utf8 "()Ljava/lang/invoke/MethodHandles$Lookup;"; // #33
|
||||
NameAndType #32 #33; // #34
|
||||
Method #31 #34; // #35
|
||||
Utf8 "CondyUsesIndyBSM"; // #36
|
||||
class #36; // #37
|
||||
String #28; // #38
|
||||
Utf8 "java/lang/Integer"; // #39
|
||||
class #39; // #40
|
||||
Utf8 "TYPE"; // #41
|
||||
Utf8 "Ljava/lang/Class;"; // #42
|
||||
NameAndType #41 #42; // #43
|
||||
Field #40 #43; // #44
|
||||
Utf8 "java/lang/invoke/MethodType"; // #45
|
||||
class #45; // #46
|
||||
Utf8 "methodType"; // #47
|
||||
Utf8 "(Ljava/lang/Class;)Ljava/lang/invoke/MethodType;"; // #48
|
||||
NameAndType #47 #48; // #49
|
||||
Method #46 #49; // #50
|
||||
Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #51
|
||||
class #51; // #52
|
||||
Utf8 "findStatic"; // #53
|
||||
Utf8 "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MethodHandle;"; // #54
|
||||
NameAndType #53 #54; // #55
|
||||
Method #52 #55; // #56
|
||||
Utf8 "MH_foo"; // #57
|
||||
Utf8 "()Ljava/lang/invoke/MethodHandle;"; // #58
|
||||
Utf8 "java/lang/invoke/ConstantCallSite"; // #59
|
||||
class #59; // #60
|
||||
NameAndType #57 #58; // #61
|
||||
Method #37 #61; // #62
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandle;)V"; // #63
|
||||
NameAndType #3 #63; // #64
|
||||
Method #60 #64; // #65
|
||||
Utf8 "Indybsm"; // #66
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"; // #67
|
||||
NameAndType #66 #67; // #68
|
||||
Method #37 #68; // #69
|
||||
MethodHandle 6b #69; // #70
|
||||
NameAndType #28 #29; // #71
|
||||
InvokeDynamic 0s #71; // #72
|
||||
NameAndType #24 #25; // #73
|
||||
Method #37 #73; // #74
|
||||
MethodHandle 6b #74; // #75
|
||||
Utf8 "name"; // #76
|
||||
Utf8 "Ljava/lang/Object;"; // #77
|
||||
NameAndType #76 #77; // #78
|
||||
Dynamic 0s #78; // #79
|
||||
Utf8 "m"; // #80
|
||||
Utf8 "()Ljava/lang/Object;"; // #81
|
||||
NameAndType #80 #81; // #82
|
||||
Method #37 #82; // #83
|
||||
Utf8 "main"; // #84
|
||||
Utf8 "([Ljava/lang/String;)V"; // #85
|
||||
Utf8 "BootstrapMethods"; // #86
|
||||
Utf8 "CondyUsesIndyBSM"; // #87
|
||||
class #87; // #88
|
||||
} // Constant Pool
|
||||
|
||||
0x0000; // access
|
||||
#88;// this_cpx
|
||||
#2;// super_cpx
|
||||
|
||||
[] { // Interfaces
|
||||
} // Interfaces
|
||||
|
||||
[] { // fields
|
||||
} // fields
|
||||
|
||||
[] { // methods
|
||||
{ // Member
|
||||
0x0001; // access
|
||||
#3; // name_cpx
|
||||
#4; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0x2AB70006B1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#24; // name_cpx
|
||||
#25; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
2; // max_stack
|
||||
3; // max_locals
|
||||
Bytes[]{
|
||||
0xB2000D120FB60015;
|
||||
0x1217B0;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#28; // name_cpx
|
||||
#29; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
2; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[]{
|
||||
0xB2000D121BB60015;
|
||||
0x1064AC;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#57; // name_cpx
|
||||
#58; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
4; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[]{
|
||||
0xB8002312251226B2;
|
||||
0x002CB80032B60038;
|
||||
0xB0;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#66; // name_cpx
|
||||
#67; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
3; // max_stack
|
||||
3; // max_locals
|
||||
Bytes[]{
|
||||
0xBB003C59B8003EB7;
|
||||
0x0041B0;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#80; // name_cpx
|
||||
#81; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
2; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[]{
|
||||
0xBA0048000013004F;
|
||||
0xB0;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member
|
||||
0x0009; // access
|
||||
#84; // name_cpx
|
||||
#85; // sig_cpx
|
||||
[] { // Attributes
|
||||
Attr(#7) { // Code
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[]{
|
||||
0xB80053B1;
|
||||
}
|
||||
[] { // Traps
|
||||
} // end Traps
|
||||
[] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
} // methods
|
||||
|
||||
[] { // Attributes
|
||||
Attr(#86) { // BootstrapMethods
|
||||
[] { // bootstrap_methods
|
||||
{ // bootstrap_method
|
||||
#70; // bootstrap_method_ref
|
||||
[] { // bootstrap_arguments
|
||||
} // bootstrap_arguments
|
||||
} // bootstrap_method
|
||||
;
|
||||
{ // bootstrap_method
|
||||
#75; // bootstrap_method_ref
|
||||
[] { // bootstrap_arguments
|
||||
} // bootstrap_arguments
|
||||
} // bootstrap_method
|
||||
}
|
||||
} // end BootstrapMethods
|
||||
} // Attributes
|
||||
} // end class CondyUsesIndyBSM
|
335
test/hotspot/jtreg/runtime/condy/IndyUsesCondyBSM.jcod
Normal file
335
test/hotspot/jtreg/runtime/condy/IndyUsesCondyBSM.jcod
Normal file
@ -0,0 +1,335 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test contains a CONSTANT_InvokeDynamic_info structure whose bootstrap_method_attr_index
|
||||
* points to a BSM for an CONSTANT_Dynamic. Both the condy & indy point at element 0 in the
|
||||
* bootstrap methods array. BootstrapMethodError expected.
|
||||
*/
|
||||
|
||||
/*
|
||||
class IndyUsesCondyBSM {
|
||||
IndyUsesCondyBSM() { }
|
||||
public static Object Condybsm(java.lang.invoke.MethodHandles$Lookup, java.lang.String, java.lang.Class) {
|
||||
System.out.println("In Condybsm");
|
||||
return String(0);
|
||||
}
|
||||
public static int foo() {
|
||||
System.out.println("In Indybsm target CallSite method foo");
|
||||
return 100;
|
||||
}
|
||||
public static MethodHandle MH_foo() {
|
||||
// Constructs a MethodHandle for foo
|
||||
Lookup lookup = MethodHandles.lookup();
|
||||
MethodType mt = MethodType.methodType(int.class);
|
||||
return lookup.findStatic(IndyUsesCondyBSM.class, "foo", mt);
|
||||
}
|
||||
public static CallSite Indybsm(java.lang.invoke.MethodHandles$Lookup, java.lang.String, java.lang.invoke.MethodType) {
|
||||
return new CallSite(IndyUsesCondyBSM.MH_foo());
|
||||
}
|
||||
public static int m() {
|
||||
// ldc_w dynamic where the BSM = slot #0 in the BootstrapMethods array is IndyUsesCondyBSM.Condybsm() -> succeeds
|
||||
// invokedynamic where the BSM = slot #0 in the BootstrapMethods array is IndyUsesCondyBSM.Condybsm() -> receives a BootstrapMethodError
|
||||
return Callsite.foo();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
IndyUsesCondyBSM.m();
|
||||
return;
|
||||
}
|
||||
|
||||
BootstrapMethods:
|
||||
0: #65 REF_invokeStatic IndyUsesCondyBSM.Condybsm:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;
|
||||
Method arguments:
|
||||
1: #74 REF_invokeStatic IndyUsesCondyBSM.Indybsm:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
|
||||
Method arguments:
|
||||
}
|
||||
*/
|
||||
|
||||
class IndyUsesCondyBSM {
|
||||
0xCAFEBABE;
|
||||
0; // minor version
|
||||
55; // version
|
||||
[88] { // Constant Pool
|
||||
; // first element is empty
|
||||
String #48; // #1 at 0x0A
|
||||
String #49; // #2 at 0x0D
|
||||
String #56; // #3 at 0x10
|
||||
String #58; // #4 at 0x13
|
||||
class #51; // #5 at 0x16
|
||||
Method #62 #20; // #6 at 0x19
|
||||
InvokeDynamic 0s #53; // #7 at 0x1E
|
||||
Method #5 #71; // #8 at 0x23
|
||||
Method #26 #47; // #9 at 0x28
|
||||
Field #21 #86; // #10 at 0x2D
|
||||
Method #28 #75; // #11 at 0x32
|
||||
Field #61 #82; // #12 at 0x37
|
||||
Method #18 #36; // #13 at 0x3C
|
||||
Method #29 #46; // #14 at 0x41
|
||||
Method #57 #87; // #15 at 0x46
|
||||
Method #5 #73; // #16 at 0x4B
|
||||
Dynamic 0s #23; // #17 at 0x50
|
||||
class #80; // #18 at 0x55
|
||||
Utf8 "java/io/PrintStream"; // #19 at 0x58
|
||||
NameAndType #81 #59; // #20 at 0x6E
|
||||
class #85; // #21 at 0x73
|
||||
Utf8 "java/lang/invoke/MethodType"; // #22 at 0x76
|
||||
NameAndType #31 #77; // #23 at 0x94
|
||||
Utf8 "m"; // #24 at 0x99
|
||||
Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #25 at 0x9D
|
||||
class #19; // #26 at 0xC5
|
||||
Utf8 "SourceFile"; // #27 at 0xC8
|
||||
class #22; // #28 at 0xD5
|
||||
class #25; // #29 at 0xD8
|
||||
Utf8 "IndyUsesCondyBSM.jasm"; // #30 at 0xDB
|
||||
Utf8 "name"; // #31 at 0xF3
|
||||
Utf8 "Indybsm"; // #32 at 0xFA
|
||||
Utf8 "findStatic"; // #33 at 0x0104
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;"; // #34 at 0x0111
|
||||
Utf8 "()Ljava/lang/invoke/MethodHandles$Lookup;"; // #35 at 0x0172
|
||||
NameAndType #81 #66; // #36 at 0x019E
|
||||
Utf8 "MH_foo"; // #37 at 0x01A3
|
||||
Method #5 #84; // #38 at 0x01AC
|
||||
Utf8 "Code"; // #39 at 0x01B1
|
||||
Utf8 "lookup"; // #40 at 0x01B8
|
||||
Utf8 "([Ljava/lang/String;)V"; // #41 at 0x01C1
|
||||
Utf8 "out"; // #42 at 0x01DA
|
||||
Utf8 "BootstrapMethods"; // #43 at 0x01E0
|
||||
Utf8 "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MethodHandle;"; // #44 at 0x01F3
|
||||
Utf8 "Ljava/lang/Class;"; // #45 at 0x0257
|
||||
NameAndType #33 #44; // #46 at 0x026B
|
||||
NameAndType #52 #63; // #47 at 0x0270
|
||||
Utf8 "0"; // #48 at 0x0275
|
||||
Utf8 "In Condybsm"; // #49 at 0x0279
|
||||
Utf8 "java/lang/invoke/MethodHandles"; // #50 at 0x0287
|
||||
Utf8 "IndyUsesCondyBSM"; // #51 at 0x02A8
|
||||
Utf8 "println"; // #52 at 0x02BB
|
||||
NameAndType #58 #67; // #53 at 0x02C5
|
||||
Utf8 "java/lang/Object"; // #54 at 0x02CA
|
||||
Utf8 "java/lang/System"; // #55 at 0x02DD
|
||||
Utf8 "In Indybsm target CallSite method foo"; // #56 at 0x02F0
|
||||
class #50; // #57 at 0x0318
|
||||
Utf8 "foo"; // #58 at 0x031B
|
||||
Utf8 "()V"; // #59 at 0x0321
|
||||
Utf8 "()Ljava/lang/invoke/MethodHandle;"; // #60 at 0x0327
|
||||
class #55; // #61 at 0x034B
|
||||
class #54; // #62 at 0x034E
|
||||
Utf8 "(Ljava/lang/String;)V"; // #63 at 0x0351
|
||||
Utf8 "main"; // #64 at 0x0369
|
||||
MethodHandle 6b #79; // #65 at 0x0370
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandle;)V"; // #66 at 0x0374
|
||||
Utf8 "()I"; // #67 at 0x0399
|
||||
Utf8 "(Ljava/lang/Class;)Ljava/lang/invoke/MethodType;"; // #68 at 0x039F
|
||||
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"; // #69 at 0x03D2
|
||||
Utf8 "Condybsm"; // #70 at 0x0448
|
||||
NameAndType #37 #60; // #71 at 0x0453
|
||||
NameAndType #70 #34; // #72 at 0x0458
|
||||
NameAndType #24 #67; // #73 at 0x045D
|
||||
MethodHandle 6b #38; // #74 at 0x0462
|
||||
NameAndType #78 #68; // #75 at 0x0466
|
||||
Utf8 "Ljava/io/PrintStream;"; // #76 at 0x046B
|
||||
Utf8 "Ljava/lang/Object;"; // #77 at 0x0483
|
||||
Utf8 "methodType"; // #78 at 0x0498
|
||||
Method #5 #72; // #79 at 0x04A5
|
||||
Utf8 "java/lang/invoke/ConstantCallSite"; // #80 at 0x04AA
|
||||
Utf8 "<init>"; // #81 at 0x04CE
|
||||
NameAndType #42 #76; // #82 at 0x04D7
|
||||
Utf8 "TYPE"; // #83 at 0x04DC
|
||||
NameAndType #32 #69; // #84 at 0x04E3
|
||||
Utf8 "java/lang/Integer"; // #85 at 0x04E8
|
||||
NameAndType #83 #45; // #86 at 0x04FC
|
||||
NameAndType #40 #35; // #87 at 0x0501
|
||||
} // Constant Pool
|
||||
|
||||
0x0000; // access [ ]
|
||||
#5;// this_cpx
|
||||
#62;// super_cpx
|
||||
|
||||
[0] { // Interfaces
|
||||
} // Interfaces
|
||||
|
||||
[0] { // fields
|
||||
} // fields
|
||||
|
||||
[7] { // methods
|
||||
{ // Member at 0x0512
|
||||
0x0001; // access
|
||||
#81; // name_cpx
|
||||
#59; // sig_cpx
|
||||
[1] { // Attributes
|
||||
Attr(#39, 17) { // Code at 0x051A
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[5]{
|
||||
0x2AB70006B1;
|
||||
}
|
||||
[0] { // Traps
|
||||
} // end Traps
|
||||
[0] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member at 0x0531
|
||||
0x0009; // access
|
||||
#70; // name_cpx
|
||||
#34; // sig_cpx
|
||||
[1] { // Attributes
|
||||
Attr(#39, 23) { // Code at 0x0539
|
||||
2; // max_stack
|
||||
3; // max_locals
|
||||
Bytes[11]{
|
||||
0xB2000C1202B60009;
|
||||
0x1201B0;
|
||||
}
|
||||
[0] { // Traps
|
||||
} // end Traps
|
||||
[0] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member at 0x0556
|
||||
0x0009; // access
|
||||
#58; // name_cpx
|
||||
#67; // sig_cpx
|
||||
[1] { // Attributes
|
||||
Attr(#39, 23) { // Code at 0x055E
|
||||
2; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[11]{
|
||||
0xB2000C1203B60009;
|
||||
0x1064AC;
|
||||
}
|
||||
[0] { // Traps
|
||||
} // end Traps
|
||||
[0] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member at 0x057B
|
||||
0x0009; // access
|
||||
#37; // name_cpx
|
||||
#60; // sig_cpx
|
||||
[1] { // Attributes
|
||||
Attr(#39, 29) { // Code at 0x0583
|
||||
4; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[17]{
|
||||
0xB8000F12051204B2;
|
||||
0x000AB8000BB6000E;
|
||||
0xB0;
|
||||
}
|
||||
[0] { // Traps
|
||||
} // end Traps
|
||||
[0] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member at 0x05A6
|
||||
0x0009; // access
|
||||
#32; // name_cpx
|
||||
#69; // sig_cpx
|
||||
[1] { // Attributes
|
||||
Attr(#39, 23) { // Code at 0x05AE
|
||||
3; // max_stack
|
||||
3; // max_locals
|
||||
Bytes[11]{
|
||||
0xBB001259B80008B7;
|
||||
0x000DB0;
|
||||
}
|
||||
[0] { // Traps
|
||||
} // end Traps
|
||||
[0] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member at 0x05CB
|
||||
0x0009; // access
|
||||
#24; // name_cpx
|
||||
#67; // sig_cpx
|
||||
[1] { // Attributes
|
||||
Attr(#39, 21) { // Code at 0x05D3
|
||||
2; // max_stack
|
||||
0; // max_locals
|
||||
Bytes[9]{
|
||||
0x130011BA00070000;
|
||||
0xAC;
|
||||
}
|
||||
[0] { // Traps
|
||||
} // end Traps
|
||||
[0] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member at 0x05EE
|
||||
0x0009; // access
|
||||
#64; // name_cpx
|
||||
#41; // sig_cpx
|
||||
[1] { // Attributes
|
||||
Attr(#39, 16) { // Code at 0x05F6
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[4]{
|
||||
0xB80010B1;
|
||||
}
|
||||
[0] { // Traps
|
||||
} // end Traps
|
||||
[0] { // Attributes
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
} // methods
|
||||
|
||||
[2] { // Attributes
|
||||
Attr(#27, 2) { // SourceFile at 0x060E
|
||||
#30;
|
||||
} // end SourceFile
|
||||
;
|
||||
Attr(#43, 10) { // BootstrapMethods at 0x0616
|
||||
[2] { // bootstrap_methods
|
||||
{ // bootstrap_method
|
||||
#65; // bootstrap_method_ref
|
||||
[0] { // bootstrap_arguments
|
||||
} // bootstrap_arguments
|
||||
} // bootstrap_method
|
||||
;
|
||||
{ // bootstrap_method
|
||||
#74; // bootstrap_method_ref
|
||||
[0] { // bootstrap_arguments
|
||||
} // bootstrap_arguments
|
||||
} // bootstrap_method
|
||||
}
|
||||
} // end BootstrapMethods
|
||||
} // Attributes
|
||||
} // end class IndyUsesCondyBSM
|
Loading…
Reference in New Issue
Block a user