blob: 9b18104579360a1f1264eb31e3b01d8366906dae [file] [log] [blame]
/*
* 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