155 lines
4.4 KiB
Plaintext
155 lines
4.4 KiB
Plaintext
|
/*
|
||
|
* 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
|