mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8130183: InnerClasses: VM permits wrong inner_class_info_index value of zero
Throw ClassFormatError if InnerClasses attribute's inner_class_info_index is 0 Reviewed-by: acorn, lfoltan
This commit is contained in:
parent
48ed80d136
commit
00da567d15
3 changed files with 106 additions and 2 deletions
|
@ -2692,7 +2692,6 @@ u2 ClassFileParser::parse_classfile_inner_classes_attribute(u1* inner_classes_at
|
||||||
// Inner class index
|
// Inner class index
|
||||||
u2 inner_class_info_index = cfs->get_u2_fast();
|
u2 inner_class_info_index = cfs->get_u2_fast();
|
||||||
check_property(
|
check_property(
|
||||||
inner_class_info_index == 0 ||
|
|
||||||
valid_klass_reference_at(inner_class_info_index),
|
valid_klass_reference_at(inner_class_info_index),
|
||||||
"inner_class_info_index %u has bad constant type in class file %s",
|
"inner_class_info_index %u has bad constant type in class file %s",
|
||||||
inner_class_info_index, CHECK_0);
|
inner_class_info_index, CHECK_0);
|
||||||
|
|
45
hotspot/test/runtime/classFileParserBug/EnclosingMethod.java
Normal file
45
hotspot/test/runtime/classFileParserBug/EnclosingMethod.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, 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 8130183
|
||||||
|
* @summary For InnerClasses attribute, VM permits inner_class_info_index value of zero
|
||||||
|
* @compile badEnclMthd.jcod
|
||||||
|
* @run main/othervm -Xverify:all EnclosingMethod
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Test that an EnclosingMethod attribute with the value of 0 causes a ClassFormatError.
|
||||||
|
public class EnclosingMethod {
|
||||||
|
public static void main(String args[]) throws Throwable {
|
||||||
|
|
||||||
|
System.out.println("Regression test for bug 8130183");
|
||||||
|
try {
|
||||||
|
Class newClass = Class.forName("badEnclMthd");
|
||||||
|
throw new RuntimeException("Expected ClassFormatError exception not thrown");
|
||||||
|
} catch (java.lang.ClassFormatError e) {
|
||||||
|
System.out.println("Test EnclosingMethod passed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
hotspot/test/runtime/classFileParserBug/badEnclMthd.jcod
Normal file
60
hotspot/test/runtime/classFileParserBug/badEnclMthd.jcod
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Source: badEnclMthd
|
||||||
|
class badEnclMthd {
|
||||||
|
0xCAFEBABE;
|
||||||
|
0; // minor version
|
||||||
|
50; // major version
|
||||||
|
[] { // Constant Pool
|
||||||
|
; // first element is empty
|
||||||
|
Utf8 "badEnclMthd"; // #1
|
||||||
|
class #1; // #2
|
||||||
|
Utf8 "java/lang/Object"; // #3
|
||||||
|
class #3; // #4
|
||||||
|
Utf8 "InnerClasses"; // #5
|
||||||
|
Utf8 "badEnclMthd"; // #6
|
||||||
|
class #6; // #7
|
||||||
|
Utf8 "badEnclMthd"; // #8
|
||||||
|
class #8; // #9
|
||||||
|
} // Constant Pool
|
||||||
|
0x0001; // access public
|
||||||
|
#2;// this_cpx
|
||||||
|
#4;// super_cpx
|
||||||
|
[] { // interfaces
|
||||||
|
} // interfaces
|
||||||
|
[] { // fields
|
||||||
|
} // fields
|
||||||
|
[] { // methods
|
||||||
|
} // methods
|
||||||
|
[] { // attributes
|
||||||
|
Attr(#5) { // InnerClasses
|
||||||
|
[] { // InnerClasses
|
||||||
|
#0 #2 #6 1; // Bad inner_class_info_index of 0 !!!
|
||||||
|
#9 #0 #8 1;
|
||||||
|
}
|
||||||
|
} // end InnerClasses
|
||||||
|
;
|
||||||
|
} // attributes
|
||||||
|
} // end class badEnclMthd
|
Loading…
Add table
Add a link
Reference in a new issue