mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 18:14:38 +02:00
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
Check if ACC_MODULE is set, and if so, throw NoClassDefFoundError exception Reviewed-by: dholmes, alanb, acorn, coleenp, lfoltan, gtriantafill
This commit is contained in:
parent
f5f86b2ed6
commit
90bde9549e
5 changed files with 339 additions and 8 deletions
140
hotspot/test/runtime/classFileParserBug/BadAccModule.jcod
Normal file
140
hotspot/test/runtime/classFileParserBug/BadAccModule.jcod
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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 is a .jcod file for a simple "Hello World" program with ACC_MODULE added
|
||||
// to its access_flags. (See line 67.) This should cause a NoClassDefFoundError
|
||||
// when loading the class.
|
||||
class BadAccModule {
|
||||
0xCAFEBABE;
|
||||
0; // minor version
|
||||
53; // version
|
||||
[32] { // Constant Pool
|
||||
; // first element is empty
|
||||
Method #6 #17; // #1 at 0x0A
|
||||
Field #18 #19; // #2 at 0x0F
|
||||
String #20; // #3 at 0x14
|
||||
Method #21 #22; // #4 at 0x17
|
||||
class #23; // #5 at 0x1C
|
||||
class #24; // #6 at 0x1F
|
||||
Utf8 "<init>"; // #7 at 0x22
|
||||
Utf8 "()V"; // #8 at 0x2B
|
||||
Utf8 "Code"; // #9 at 0x31
|
||||
Utf8 "LineNumberTable"; // #10 at 0x38
|
||||
Utf8 "main"; // #11 at 0x4A
|
||||
Utf8 "([Ljava/lang/String;)V"; // #12 at 0x51
|
||||
Utf8 "Exceptions"; // #13 at 0x6A
|
||||
class #25; // #14 at 0x77
|
||||
Utf8 "SourceFile"; // #15 at 0x7A
|
||||
Utf8 "BadAccModule.java"; // #16 at 0x87
|
||||
NameAndType #7 #8; // #17 at 0x9B
|
||||
class #26; // #18 at 0xA0
|
||||
NameAndType #27 #28; // #19 at 0xA3
|
||||
Utf8 "Hello World"; // #20 at 0xA8
|
||||
class #29; // #21 at 0xB6
|
||||
NameAndType #30 #31; // #22 at 0xB9
|
||||
Utf8 "BadAccModule"; // #23 at 0xBE
|
||||
Utf8 "java/lang/Object"; // #24 at 0xCD
|
||||
Utf8 "java/lang/Throwable"; // #25 at 0xE0
|
||||
Utf8 "java/lang/System"; // #26 at 0xF6
|
||||
Utf8 "out"; // #27 at 0x0109
|
||||
Utf8 "Ljava/io/PrintStream;"; // #28 at 0x010F
|
||||
Utf8 "java/io/PrintStream"; // #29 at 0x0127
|
||||
Utf8 "println"; // #30 at 0x013D
|
||||
Utf8 "(Ljava/lang/String;)V"; // #31 at 0x0147
|
||||
} // Constant Pool
|
||||
|
||||
0x8021; // access Added ACC_MODULE (0x8000) !!!
|
||||
#5;// this_cpx
|
||||
#6;// super_cpx
|
||||
|
||||
[0] { // Interfaces
|
||||
} // Interfaces
|
||||
|
||||
[0] { // fields
|
||||
} // fields
|
||||
|
||||
[2] { // methods
|
||||
{ // Member at 0x016B
|
||||
0x0001; // access
|
||||
#7; // name_cpx
|
||||
#8; // sig_cpx
|
||||
[1] { // Attributes
|
||||
Attr(#9, 29) { // Code at 0x0173
|
||||
1; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[5]{
|
||||
0x2AB70001B1;
|
||||
};
|
||||
[0] { // Traps
|
||||
} // end Traps
|
||||
[1] { // Attributes
|
||||
Attr(#10, 6) { // LineNumberTable at 0x018A
|
||||
[1] { // LineNumberTable
|
||||
0 1; // at 0x0196
|
||||
}
|
||||
} // end LineNumberTable
|
||||
} // Attributes
|
||||
} // end Code
|
||||
} // Attributes
|
||||
} // Member
|
||||
;
|
||||
{ // Member at 0x0196
|
||||
0x0009; // access
|
||||
#11; // name_cpx
|
||||
#12; // sig_cpx
|
||||
[2] { // Attributes
|
||||
Attr(#9, 37) { // Code at 0x019E
|
||||
2; // max_stack
|
||||
1; // max_locals
|
||||
Bytes[9]{
|
||||
0xB200021203B60004;
|
||||
0xB1;
|
||||
};
|
||||
[0] { // Traps
|
||||
} // end Traps
|
||||
[1] { // Attributes
|
||||
Attr(#10, 10) { // LineNumberTable at 0x01B9
|
||||
[2] { // LineNumberTable
|
||||
0 4; // at 0x01C5
|
||||
8 5; // at 0x01C9
|
||||
}
|
||||
} // end LineNumberTable
|
||||
} // Attributes
|
||||
} // end Code
|
||||
;
|
||||
Attr(#13, 4) { // Exceptions at 0x01C9
|
||||
[1] { // Exceptions
|
||||
#14; // at 0x01D3
|
||||
}
|
||||
} // end Exceptions
|
||||
} // Attributes
|
||||
} // Member
|
||||
} // methods
|
||||
|
||||
[1] { // Attributes
|
||||
Attr(#15, 2) { // SourceFile at 0x01D5
|
||||
#16;
|
||||
} // end SourceFile
|
||||
} // Attributes
|
||||
} // end class BadAccModule
|
Loading…
Add table
Add a link
Reference in a new issue