undefect. CWE-407 — 63 sites patched across 27 ecosystems

Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com

Patches, unit tests, benchmarks, whitepaper, and outreach briefs.
Public domain — no copyright claimed. Use freely.
This commit is contained in:
russell@unturf.com 2026-03-26 17:11:57 -04:00
commit 0a580b313d
70422 changed files with 17213626 additions and 0 deletions

View file

@ -0,0 +1,54 @@
/*
* 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.
*/
/*
* @test
* @bug 8174725
* @summary Throw NoClassDefFoundError if class access_flags have ACC_MODULE set
* @compile BadAccModule.jcod BadAccModInrClss.jcod
* @run main AccModuleTest
*/
// Test that classes with access_flags containing ACC_MODULE cause ClassDefNotFoundErrors.
public class AccModuleTest {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8174725");
try {
Class newClass = Class.forName("BadAccModule");
throw new RuntimeException("Expected NoClassDefFoundError exception not thrown");
} catch (java.lang.NoClassDefFoundError e) {
if (!e.getMessage().contains("BadAccModule is not a class because access_flag ACC_MODULE is set")) {
throw new RuntimeException("Wrong NoClassDefFoundError exception for AccModuleTest: " + e.getMessage());
}
}
try {
Class newClass = Class.forName("BadAccModInrClss");
throw new RuntimeException("Expected NoClassDefFoundError exception not thrown");
} catch (java.lang.NoClassDefFoundError e) {
if (!e.getMessage().contains("BadAccModInrClss is not a class because access_flag ACC_MODULE is set")) {
throw new RuntimeException("Wrong NoClassDefFoundError exception for BadAccModInrClss: " + e.getMessage());
}
}
}
}

View 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 8042041
* @summary Fuzzy-ed RuntimeVisibleAnnotations causes assertion
* @compile badAnnotTag.jcod
* @run main AnnotationTag
*/
// Test that a bad element_tag in an element_value of a RuntimeVisibileAnnotation
// attribute is ignored.
public class AnnotationTag {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8042041");
try {
Class newClass = Class.forName("badAnnotTag");
} catch (java.lang.Throwable e) {
throw new RuntimeException(
"Unexpected exception: " + e.getMessage());
}
}
}

View file

@ -0,0 +1,113 @@
/*
* 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 tests that a class in an InnerClasses attribute with ACC_MODULE set
* causes a NoClassDefFoundError exception to get thrown.
*/
class BadAccModInrClss {
0xCAFEBABE;
0; // minor version
53; // version
[22] { // Constant Pool
; // first element is empty
Field #3 #14; // #1 at 0x0A
Method #4 #15; // #2 at 0x0F
class #16; // #3 at 0x14
class #19; // #4 at 0x17
Utf8 "this$0"; // #5 at 0x1A
Utf8 "La;"; // #6 at 0x23
Utf8 "Synthetic"; // #7 at 0x29
Utf8 "<init>"; // #8 at 0x35
Utf8 "(Ljava/lang/Object;)V"; // #9 at 0x3E
Utf8 "Code"; // #10 at 0x56
Utf8 "LineNumberTable"; // #11 at 0x5D
Utf8 "SourceFile"; // #12 at 0x6F
Utf8 "a.java"; // #13 at 0x7C
NameAndType #5 #6; // #14 at 0x85
NameAndType #8 #20; // #15 at 0x8A
Utf8 "BadAccModInrClss"; // #16 at 0x8F
Utf8 "Loc"; // #17 at 0x9E
Utf8 "InnerClasses"; // #18 at 0xA4
Utf8 "java/lang/Object"; // #19 at 0xB3
Utf8 "()V"; // #20 at 0xC6
Utf8 "EnclosingMethod"; // #21 at 0xCC
} // Constant Pool
0x0000; // access
#3;// this_cpx
#4;// super_cpx
[0] { // Interfaces
} // Interfaces
[1] { // fields
{ // Member at 0xE8
0x0000; // access
#5; // name_cpx
#6; // sig_cpx
[1] { // Attributes
Attr(#7, 0) { // Synthetic at 0xF0
} // end Synthetic
} // Attributes
} // Member
} // fields
[1] { // methods
{ // Member at 0xF8
0x0001; // access
#8; // name_cpx
#20; // sig_cpx
[1] { // Attributes
Attr(#10, 17) { // Code at 0x0100
2; // max_stack
2; // max_locals
Bytes[5]{
0x2AB70002B1;
};
[0] { // Traps
} // end Traps
[0] { // Attributes
} // Attributes
} // end Code
} // Attributes
} // Member
} // methods
[3] { // Attributes
Attr(#12, 2) { // SourceFile at 0x0119
#13;
} // end SourceFile
;
Attr(#18, 10) { // InnerClasses at 0x0121
[1] { // InnerClasses
#3 #0 #17 0x8000; // at 0x0131
}
} // end InnerClasses
;
Attr(#21, 4) { // EnclosingMethod at 0x0131
0x0004000F;
} // end EnclosingMethod
} // Attributes
} // end class BadAccModInrClss

View 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

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2020, 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.
*/
package java/lang;
super public class BadClassPackage
implements java/util/function/Function
version 47:0
{
public Method "<init>":"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method Object."<init>":"()V";
return;
}
} // end Class BadClassPackage

View file

@ -0,0 +1,83 @@
/*
* 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 8130669
* @summary VM prohibits <clinit> methods with return values
* @compile nonvoidClinit.jasm
* @compile clinitNonStatic.jasm
* @compile clinitArg.jasm
* @compile clinitArg51.jasm
* @compile badInit.jasm
* @run main/othervm -Xverify:all BadInitMethod
*/
// Test that non-void <clinit>, non-static <clinit>, and non-void
// <init> methods cause ClassFormatException's to be thrown.
public class BadInitMethod {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8130669");
try {
Class newClass = Class.forName("nonvoidClinit");
throw new RuntimeException(
"Expected ClassFormatError exception for non-void <clinit> not thrown");
} catch (java.lang.ClassFormatError e) {
System.out.println("Test BadInitMethod passed for non-void <clinit>");
}
try {
Class newClass = Class.forName("clinitNonStatic");
throw new RuntimeException(
"Expected ClassFormatError exception for non-static <clinit> not thrown");
} catch (java.lang.ClassFormatError e) {
System.out.println("Test BadInitMethod passed for non-static <clinit>");
}
// <clinit> with args is allowed in class file version < 51.
try {
Class newClass = Class.forName("clinitArg");
} catch (java.lang.ClassFormatError e) {
throw new RuntimeException(
"Unexpected ClassFormatError exception for <clinit> with argument in class file < 51");
}
// <clinit> with args is not allowed in class file version >= 51.
try {
Class newClass = Class.forName("clinitArg51");
throw new RuntimeException(
"Expected ClassFormatError exception for <clinit> with argument not thrown");
} catch (java.lang.ClassFormatError e) {
System.out.println("Test BadInitMethod passed for <clinit> with argument");
}
try {
Class newClass = Class.forName("badInit");
throw new RuntimeException(
"Expected ClassFormatError exception for non-void <init> not thrown");
} catch (java.lang.ClassFormatError e) {
System.out.println("Test BadInitMethod passed for non-void <init>");
}
}
}

View file

@ -0,0 +1,56 @@
/*
* 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 8042660
* @summary Constant pool NameAndType entries must point to non-zero length Utf8 strings
* @compile emptySigUtf8.jcod
* @compile emptyNameUtf8.jcod
* @run main/othervm -Xverify:all BadNameAndType
*/
// Test that a constant pool NameAndType descriptor_index and/or name_index
// that points to a zero length Utf8 string causes a ClassFormatError.
public class BadNameAndType {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8042660");
// Test descriptor_index pointing to zero-length string.
try {
Class newClass = Class.forName("emptySigUtf8");
throw new RuntimeException("Expected ClassFormatError exception not thrown");
} catch (java.lang.ClassFormatError e) {
System.out.println("Test BadNameAndType passed test case emptySigUtf8");
}
// Test name_index pointing to zero-length string.
try {
Class newClass = Class.forName("emptyNameUtf8");
throw new RuntimeException("Expected ClassFormatError exception not thrown");
} catch (java.lang.ClassFormatError e) {
System.out.println("Test BadNameAndType passed test case emptyNameUtf8");
}
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2022, 2024, 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 8288976
* @library /test/lib
* @summary Check that the right message is displayed for NoClassDefFoundError exception.
* @requires vm.flagless
* @modules java.base/jdk.internal.misc
* java.management
* @compile C.java
* @run driver Bad_NCDFE_Msg
*/
import java.io.File;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class Bad_NCDFE_Msg {
public static void main(String args[]) throws Throwable {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-cp", System.getProperty("test.classes") + File.separator + "pkg", "C");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("java.lang.NoClassDefFoundError: C (wrong name: pkg/C");
output.shouldHaveExitValue(1);
}
}

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022, 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.
*/
// class used by test Bad_NCDFE_Msg.java.
package pkg;
public class C { }

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, 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 8148785
* @summary Check that the JVM accepts class files with version 53
* @run main Class53
*/
super public class Class53 version 53:0 {
public Method "<init>":"()V" stack 1 locals 1 {
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
return;
}
public static Method main:"([Ljava/lang/String;)V" stack 0 locals 1 {
return;
}
} // end Class Class53

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, 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 8188870
* @summary Check that the JVM accepts class files with version 54
* @run main Class54
*/
super public class Class54 version 54:0 {
public Method "<init>":"()V" stack 1 locals 1 {
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
return;
}
public static Method main:"([Ljava/lang/String;)V" stack 0 locals 1 {
return;
}
} // end Class Class54

View file

@ -0,0 +1,43 @@
/*
* 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.
*/
/*
* @test
* @bug 8173382
* @summary Check that the JVM accepts class files with version 55
* @run main Class55
*/
super public class Class55 version 55:0 {
public Method "<init>":"()V" stack 1 locals 1 {
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
return;
}
public static Method main:"([Ljava/lang/String;)V" stack 0 locals 1 {
return;
}
} // end Class Class55

View file

@ -0,0 +1,43 @@
/*
* 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 8206022
* @summary Check that the JVM accepts class files with version 56
* @run main Class56
*/
super public class Class56 version 56:0 {
public Method "<init>":"()V" stack 1 locals 1 {
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
return;
}
public static Method main:"([Ljava/lang/String;)V" stack 0 locals 1 {
return;
}
} // end Class Class56

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2014, 2023, 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 8040018
* @library /test/lib
* @summary Check for exception instead of assert.
* @requires vm.flagless
* @modules java.base/jdk.internal.misc
* java.management
* @compile LambdaMath.jcod
* @run driver ClassFileParserBug
*/
import java.io.File;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class ClassFileParserBug {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8040018");
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("LambdaMath");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("java.lang.ClassFormatError: Bad length on BootstrapMethods");
output.shouldHaveExitValue(1);
}
}

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2019, 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 EmptyUnqName version 56:0 {
public Method "<init>":"()V" stack 1 locals 1 {
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
return;
}
public static Method main:"([Ljava/lang/String;)V" stack 2 locals 1 {
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
ldc String "Testing method param types";
invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
return;
}
public static Method func:"(L;)V" stack 0 locals 1 {
return;
}
} // end Class EmptyUnqName

View file

@ -0,0 +1,44 @@
/*
* 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");
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2016, 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 8166304
* @summary Skipping access check for classes generated by core reflection
* @compile fakeMethodAccessor.jasm
* @run main FakeMethodAcc
*/
/*
* Test that trying to create a sub-type of a 'magic' jdk.internal.reflect
* class should fail with an IllegalAccessError exception.
*/
public class FakeMethodAcc {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8166304");
try {
Class newClass = Class.forName("fakeMethodAccessor");
throw new RuntimeException(
"Missing expected IllegalAccessError exception");
} catch (java.lang.IllegalAccessError e) {
}
}
}

View file

@ -0,0 +1,56 @@
/*
* 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 8139069
* @summary Check that any method named <init> in an interface causes ClassFormatError
* @compile nonvoidinit.jasm voidinit.jasm
* @run main InitInInterface
*/
// Test that an <init> method is not allowed in interfaces.
public class InitInInterface {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8130183");
try {
Class newClass = Class.forName("nonvoidinit");
throw new RuntimeException(
"ClassFormatError not thrown for non-void <init> in an interface");
} catch (java.lang.ClassFormatError e) {
if (!e.getMessage().contains("Interface cannot have a method named <init>")) {
throw new RuntimeException("Unexpected exception nonvoidint: " + e.getMessage());
}
}
try {
Class newClass = Class.forName("voidinit");
throw new RuntimeException(
"ClassFormatError not thrown for void <init> in an interface");
} catch (java.lang.ClassFormatError e) {
if (!e.getMessage().contains("Interface cannot have a method named <init>")) {
throw new RuntimeException("Unexpected exception voidint: " + e.getMessage());
}
}
}
}

View file

@ -0,0 +1,609 @@
/*
* Copyright (c) 2014, 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 BootstrapMethods attribute with a fuzzied
* attribute_length field that is larger than it should be. This
* should cause a java.lang.ClassFormatError exception to be thrown.
*/
class LambdaMath {
0xCAFEBABE;
0; // minor version
52; // version
[162] { // Constant Pool
; // first element is empty
Method #31 #69; // #1 at 0x0A
class #70; // #2 at 0x0F
Method #2 #71; // #3 at 0x12
Method #72 #73; // #4 at 0x17
Field #74 #75; // #5 at 0x1C
String #76; // #6 at 0x21
Method #77 #78; // #7 at 0x24
InvokeDynamic 0s #84; // #8 at 0x29
Method #30 #85; // #9 at 0x2E
String #86; // #10 at 0x33
InvokeDynamic 1s #84; // #11 at 0x36
String #88; // #12 at 0x3B
InvokeDynamic 2s #84; // #13 at 0x3E
String #90; // #14 at 0x43
InvokeDynamic 3s #84; // #15 at 0x46
String #92; // #16 at 0x4B
InvokeDynamic 4s #84; // #17 at 0x4E
InterfaceMethod #94 #95; // #18 at 0x53
InterfaceMethod #96 #97; // #19 at 0x58
InterfaceMethod #96 #98; // #20 at 0x5D
InterfaceMethod #99 #100; // #21 at 0x62
class #101; // #22 at 0x67
Method #22 #69; // #23 at 0x6A
Method #22 #102; // #24 at 0x6F
String #103; // #25 at 0x74
Method #22 #104; // #26 at 0x77
Method #22 #105; // #27 at 0x7C
class #106; // #28 at 0x81
Method #2 #107; // #29 at 0x84
class #108; // #30 at 0x89
class #109; // #31 at 0x8C
Utf8 "<init>"; // #32 at 0x8F
Utf8 "()V"; // #33 at 0x98
Utf8 "Code"; // #34 at 0x9E
Utf8 "LineNumberTable"; // #35 at 0xA5
Utf8 "LocalVariableTable"; // #36 at 0xB7
Utf8 "this"; // #37 at 0xCC
Utf8 "LLambdaMath;"; // #38 at 0xD3
Utf8 "main"; // #39 at 0xE2
Utf8 "([Ljava/lang/String;)V"; // #40 at 0xE9
Utf8 "a"; // #41 at 0x0102
Utf8 "[Ljava/lang/String;"; // #42 at 0x0106
Utf8 "list"; // #43 at 0x011C
Utf8 "Ljava/util/List;"; // #44 at 0x0123
Utf8 "LocalVariableTypeTable"; // #45 at 0x0136
Utf8 "Ljava/util/List<Ljava/lang/Integer;>;"; // #46 at 0x014F
Utf8 "evaluate"; // #47 at 0x0177
Utf8 "(Ljava/util/List;Ljava/util/function/Predicate;)V"; // #48 at 0x0182
Utf8 "n"; // #49 at 0x01B6
Utf8 "Ljava/lang/Integer;"; // #50 at 0x01BA
Utf8 "e"; // #51 at 0x01D0
Utf8 "Ljava/lang/Throwable;"; // #52 at 0x01D4
Utf8 "predicate"; // #53 at 0x01EC
Utf8 "Ljava/util/function/PrediCate;"; // #54 at 0x01F8
Utf8 "Ljava/util/function/Predicate<Ljava/lang/Integer;>;"; // #55 at 0x0219
Utf8 "StackMapTable"; // #56 at 0x024F
class #110; // #57 at 0x025F
class #106; // #58 at 0x0262
Utf8 "Signature"; // #59 at 0x0265
Utf8 "(Ljava/util/List<Ljava/lang/Integer;>;Ljava/util/function/Predicate<Ljava/lang/Integer;>;)V"; // #60 at 0x0271
Utf8 "lambda$main$4"; // #61 at 0x02CF
Utf8 "(Ljava/lang/Integer;)Z"; // #62 at 0x02DF
Utf8 "lambda$main$3"; // #63 at 0x02F8
Utf8 "lambda$main$2"; // #64 at 0x0308
Utf8 "lambda$main$1"; // #65 at 0x0318
Utf8 "lambda$main$0"; // #66 at 0x0328
Utf8 "SourceFile"; // #67 at 0x0338
Utf8 "LambdaMath.java"; // #68 at 0x0345
NameAndType #32 #33; // #69 at 0x0357
Utf8 "java/lang/Integer"; // #70 at 0x035C
NameAndType #111 #112; // #71 at 0x0370
class #113; // #72 at 0x0375
NameAndType #114 #115; // #73 at 0x0378
class #116; // #74 at 0x037D
NameAndType #117 #118; // #75 at 0x0380
Utf8 "Print all numbers:"; // #76 at 0x0385
class #119; // #77 at 0x039A
NameAndType #120 #121; // #78 at 0x039D
Utf8 "BootstrapMethods"; // #79 at 0x03A2
MethodHandle 6b #122; // #80 at 0x03B5
MethodType #123; // #81 at 0x03B9
MethodHandle 6b #124; // #82 at 0x03BC
MethodType #62; // #83 at 0x03C0
NameAndType #125 #126; // #84 at 0x03C3
NameAndType #47 #48; // #85 at 0x03C8
Utf8 "Print no numbers:"; // #86 at 0x03CD
MethodHandle 6b #127; // #87 at 0x03E1
Utf8 "Print even numbers:"; // #88 at 0x03E5
MethodHandle 6b #128; // #89 at 0x03FB
Utf8 "Print odd numbers:"; // #90 at 0x03FF
MethodHandle 6b #129; // #91 at 0x0414
Utf8 "Print numbers greater than 5:"; // #92 at 0x0418
MethodHandle 6b #130; // #93 at 0x0438
class #131; // #94 at 0x043C
NameAndType #132 #133; // #95 at 0x043F
class #110; // #96 at 0x0444
NameAndType #134 #135; // #97 at 0x0447
NameAndType #136 #137; // #98 at 0x044C
class #138; // #99 at 0x0451
NameAndType #125 #123; // #100 at 0x0454
Utf8 "java/lang/StringFuilder"; // #101 at 0x0459
NameAndType #139 #140; // #102 at 0x0473
Utf8 " "; // #103 at 0x0478
NameAndType #139 #141; // #104 at 0x047C
NameAndType #142 #143; // #105 at 0x0481
Utf8 "java/lang/Throwable"; // #106 at 0x0486
NameAndType #144 #145; // #107 at 0x049C
Utf8 "LambdaMath"; // #108 at 0x04A1
Utf8 "java/lang/Object"; // #109 at 0x04AE
Utf8 "java/util/Iterator"; // #110 at 0x04C1
Utf8 "valueOf"; // #111 at 0x04D6
Utf8 "(I)Ljava/lang/Integer;"; // #112 at 0x04E0
Utf8 "java/util/Arrays"; // #113 at 0x04F9
Utf8 "asList"; // #114 at 0x050C
Utf8 "([Ljava/lang/Object;)Ljava/util/List;"; // #115 at 0x0515
Utf8 "java/lang/System"; // #116 at 0x053D
Utf8 "out"; // #117 at 0x0550
Utf8 "Ljava/io/PrintStream;"; // #118 at 0x0556
Utf8 "java/io/PrintStream"; // #119 at 0x056E
Utf8 "println"; // #120 at 0x0584
Utf8 "(Ljava/lang/String;)V"; // #121 at 0x058E
Method #146 #147; // #122 at 0x05A6
Utf8 "(Ljava/lang/Object;)Z"; // #123 at 0x05AB
Method #30 #148; // #124 at 0x05C3
Utf8 "test"; // #125 at 0x05C8
Utf8 "()Ljava/util/function/Predicate;"; // #126 at 0x05CF
Method #30 #149; // #127 at 0x05F2
Method #30 #150; // #128 at 0x05F7
Method #30 #151; // #129 at 0x05FC
Method #30 #152; // #130 at 0x0601
Utf8 "java/util/List"; // #131 at 0x0606
Utf8 "iterator"; // #132 at 0x0617
Utf8 "()Ljava/util/Iterator;"; // #133 at 0x0622
Utf8 "hasNext"; // #134 at 0x063B
Utf8 "()Z"; // #135 at 0x0645
Utf8 "next"; // #136 at 0x064B
Utf8 "()Ljava/lang/Object;"; // #137 at 0x0652
Utf8 "java/util/function/Predicate"; // #138 at 0x0669
Utf8 "append"; // #139 at 0x0688
Utf8 "(Ljava/lang/Object;)Ljava/lang/StringBuilder;"; // #140 at 0x0691
Utf8 "(Ljava/lang/String;)Ljava/lang/StringBuilder;"; // #141 at 0x06C1
Utf8 "toString"; // #142 at 0x06F1
Utf8 "()Ljava/lang/String;"; // #143 at 0x06FC
Utf8 "intValue"; // #144 at 0x0713
Utf8 "()I"; // #145 at 0x071E
class #153; // #146 at 0x0724
NameAndType #154 #158; // #147 at 0x0727
NameAndType #66 #62; // #148 at 0x072C
NameAndType #65 #62; // #149 at 0x0731
NameAndType #64 #62; // #150 at 0x0736
NameAndType #63 #62; // #151 at 0x073B
NameAndType #61 #62; // #152 at 0x0740
Utf8 "java/lang/invoke/LambdaMetafactory"; // #153 at 0x0745
Utf8 "metafactory"; // #154 at 0x076A
class #160; // #155 at 0x0778
Utf8 "Lookup"; // #156 at 0x077B
Utf8 "InnerClasses"; // #157 at 0x0784
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"; // #158 at 0x0793
class #161; // #159 at 0x0862
Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #160 at 0x0865
Utf8 "java/lang/invoke/MethodHandles"; // #161 at 0x088D
} // Constant Pool
0x0021; // access
#30;// this_cpx
#31;// super_cpx
[0] { // Interfaces
} // Interfaces
[0] { // fields
} // fields
[8] { // methods
{ // Member at 0x08BA
0x0001; // access
#32; // name_cpx
#33; // sig_cpx
[1] { // Attributes
Attr(#34, 47) { // Code at 0x08C2
1; // max_stack
1; // max_locals
Bytes[5]{
0x2AB70001B1;
};
[0] { // Traps
} // end Traps
[2] { // Attributes
Attr(#35, 6) { // LineNumberTable at 0x08D9
[1] { // LineNumberTable
0 5; // at 0x08E5
}
} // end LineNumberTable
;
Attr(#36, 12) { // LocalVariableTable at 0x08E5
[1] { // LocalVariableTable
0 5 37 38 0; // at 0x08F7
}
} // end LocalVariableTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x08F7
0x0009; // access
#39; // name_cpx
#40; // sig_cpx
[1] { // Attributes
Attr(#34, 261) { // Code at 0x08FF
4; // max_stack
2; // max_locals
Bytes[147]{
0x1007BD0002590304;
0xB8000353590405B8;
0x000353590506B800;
0x0353590607B80003;
0x53590708B8000353;
0x59081006B8000353;
0x5910061007B80003;
0x53B800044CB20005;
0x1206B600072BBA00;
0x080000B80009B200;
0x05120AB600072BBA;
0x000B0000B80009B2;
0x0005120CB600072B;
0xBA000D0000B80009;
0xB20005120EB60007;
0x2BBA000F0000B800;
0x09B200051210B600;
0x072BBA00110000B8;
0x0009B1;
};
[0] { // Traps
} // end Traps
[3] { // Attributes
Attr(#35, 50) { // LineNumberTable at 0x09A4
[12] { // LineNumberTable
0 9; // at 0x09B0
61 11; // at 0x09B4
69 12; // at 0x09B8
78 14; // at 0x09BC
86 15; // at 0x09C0
95 17; // at 0x09C4
103 18; // at 0x09C8
112 20; // at 0x09CC
120 21; // at 0x09D0
129 23; // at 0x09D4
137 24; // at 0x09D8
146 26; // at 0x09DC
}
} // end LineNumberTable
;
Attr(#36, 22) { // LocalVariableTable at 0x09DC
[2] { // LocalVariableTable
0 147 41 42 0; // at 0x09EE
61 86 43 44 1; // at 0x09F8
}
} // end LocalVariableTable
;
Attr(#45, 12) { // LocalVariableTypeTable at 0x09F8
[1] { // LocalVariableTypeTable
61 86 43 46 1; // at 0x0A0A
}
} // end LocalVariableTypeTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x0A0A
0x0009; // access
#47; // name_cpx
#48; // sig_cpx
[2] { // Attributes
Attr(#34, 224) { // Code at 0x0A12
3; // max_stack
4; // max_locals
Bytes[69]{
0x2AB9001201004D2C;
0xB900130100990033;
0x2CB900140100C200;
0x024E2B2DB9001502;
0x0099001CB20005BB;
0x001659B700172DB6;
0x00181219B6001AB6;
0x001BB60007A7FFCA;
0xA700044DB1;
};
[1] { // Traps
0 64 67 28; // at 0x0A6F
} // end Traps
[4] { // Attributes
Attr(#35, 30) { // LineNumberTable at 0x0A71
[7] { // LineNumberTable
0 30; // at 0x0A7D
26 31; // at 0x0A81
36 32; // at 0x0A85
61 34; // at 0x0A89
64 38; // at 0x0A8D
67 37; // at 0x0A91
68 39; // at 0x0A95
}
} // end LineNumberTable
;
Attr(#36, 42) { // LocalVariableTable at 0x0A95
[4] { // LocalVariableTable
26 35 49 50 3; // at 0x0AA7
68 0 51 52 2; // at 0x0AB1
0 69 43 44 0; // at 0x0ABB
0 69 53 54 1; // at 0x0AC5
}
} // end LocalVariableTable
;
Attr(#45, 22) { // LocalVariableTypeTable at 0x0AC5
[2] { // LocalVariableTypeTable
0 69 43 46 0; // at 0x0AD7
0 69 53 55 1; // at 0x0AE1
}
} // end LocalVariableTypeTable
;
Attr(#56, 17) { // StackMapTable at 0x0AE1
[5] { //
252b, 7, [1]z{7b,57}; // append_frame 1
53b; // same_frame
250b, 2; // chop_frame 1
66b, [1]z{7b,58}; // same_locals_1_stack_item_frame
0b; // same_frame
}
} // end StackMapTable
} // Attributes
} // end Code
;
Attr(#59, 2) { // Signature at 0x0AF8
#60;
} // end Signature
} // Attributes
} // Member
;
{ // Member at 0x0B00
0x100A; // access
#61; // name_cpx
#62; // sig_cpx
[1] { // Attributes
Attr(#34, 67) { // Code at 0x0B08
2; // max_stack
1; // max_locals
Bytes[14]{
0x2AB6001D08A40007;
0x04A7000403AC;
};
[0] { // Traps
} // end Traps
[3] { // Attributes
Attr(#35, 6) { // LineNumberTable at 0x0B28
[1] { // LineNumberTable
0 24; // at 0x0B34
}
} // end LineNumberTable
;
Attr(#36, 12) { // LocalVariableTable at 0x0B34
[1] { // LocalVariableTable
0 14 49 50 0; // at 0x0B46
}
} // end LocalVariableTable
;
Attr(#56, 5) { // StackMapTable at 0x0B46
[2] { //
12b; // same_frame
64b, [1]z{1b}; // same_locals_1_stack_item_frame
}
} // end StackMapTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x0B51
0x100A; // access
#63; // name_cpx
#62; // sig_cpx
[1] { // Attributes
Attr(#34, 69) { // Code at 0x0B59
2; // max_stack
1; // max_locals
Bytes[16]{
0x2AB6001D057004A0;
0x000704A7000403AC;
};
[0] { // Traps
} // end Traps
[3] { // Attributes
Attr(#35, 6) { // LineNumberTable at 0x0B7B
[1] { // LineNumberTable
0 21; // at 0x0B87
}
} // end LineNumberTable
;
Attr(#36, 12) { // LocalVariableTable at 0x0B87
[1] { // LocalVariableTable
0 16 49 50 0; // at 0x0B99
}
} // end LocalVariableTable
;
Attr(#56, 5) { // StackMapTable at 0x0B99
[2] { //
14b; // same_frame
64b, [1]z{1b}; // same_locals_1_stack_item_frame
}
} // end StackMapTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x0BA4
0x100A; // access
#64; // name_cpx
#62; // sig_cpx
[1] { // Attributes
Attr(#34, 68) { // Code at 0x0BAC
2; // max_stack
1; // max_locals
Bytes[15]{
0x2AB6001D05709A00;
0x0704A7000403AC;
};
[0] { // Traps
} // end Traps
[3] { // Attributes
Attr(#35, 6) { // LineNumberTable at 0x0BCD
[1] { // LineNumberTable
0 18; // at 0x0BD9
}
} // end LineNumberTable
;
Attr(#36, 12) { // LocalVariableTable at 0x0BD9
[1] { // LocalVariableTable
0 15 49 50 0; // at 0x0BEB
}
} // end LocalVariableTable
;
Attr(#56, 5) { // StackMapTable at 0x0BEB
[2] { //
13b; // same_frame
64b, [1]z{1b}; // same_locals_1_stack_item_frame
}
} // end StackMapTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x0BF6
0x100A; // access
#65; // name_cpx
#62; // sig_cpx
[1] { // Attributes
Attr(#34, 44) { // Code at 0x0BFE
1; // max_stack
1; // max_locals
Bytes[2]{
0x03AC;
};
[0] { // Traps
} // end Traps
[2] { // Attributes
Attr(#35, 6) { // LineNumberTable at 0x0C12
[1] { // LineNumberTable
0 15; // at 0x0C1E
}
} // end LineNumberTable
;
Attr(#36, 12) { // LocalVariableTable at 0x0C1E
[1] { // LocalVariableTable
0 2 49 50 0; // at 0x0C30
}
} // end LocalVariableTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x0C30
0x100A; // access
#66; // name_cpx
#62; // sig_cpx
[1] { // Attributes
Attr(#34, 44) { // Code at 0x0C38
1; // max_stack
1; // max_locals
Bytes[2]{
0x04AC;
};
[0] { // Traps
} // end Traps
[2] { // Attributes
Attr(#35, 6) { // LineNumberTable at 0x0C4C
[1] { // LineNumberTable
0 12; // at 0x0C58
}
} // end LineNumberTable
;
Attr(#36, 12) { // LocalVariableTable at 0x0C58
[1] { // LocalVariableTable
0 2 49 50 0; // at 0x0C6A
}
} // end LocalVariableTable
} // Attributes
} // end Code
} // Attributes
} // Member
} // methods
[3] { // Attributes
Attr(#67, 2) { // SourceFile at 0x0C6C
#68;
} // end SourceFile
;
Attr(#157, 10) { // InnerClasses at 0x0C74
[1] { // InnerClasses
#155 #159 #156 25; // at 0x0C84
}
} // end InnerClasses
;
Attr(#79, 52) { // BootstrapMethods at 0x0C84
[5] { // bootstrap_methods
{ // bootstrap_method
#80; // bootstrap_method_ref
[3] { // bootstrap_arguments
#81; // at 0x0C92
#82; // at 0x0C94
#83; // at 0x0C96
} // bootstrap_arguments
} // bootstrap_method
;
{ // bootstrap_method
#80; // bootstrap_method_ref
[3] { // bootstrap_arguments
#81; // at 0x0C9C
#87; // at 0x0C9E
#83; // at 0x0CA0
} // bootstrap_arguments
} // bootstrap_method
;
{ // bootstrap_method
#80; // bootstrap_method_ref
[3] { // bootstrap_arguments
#81; // at 0x0CA6
#89; // at 0x0CA8
#83; // at 0x0CAA
} // bootstrap_arguments
} // bootstrap_method
;
{ // bootstrap_method
#80; // bootstrap_method_ref
[3] { // bootstrap_arguments
#81; // at 0x0CB0
#91; // at 0x0CB2
#83; // at 0x0CB4
} // bootstrap_arguments
} // bootstrap_method
;
{ // bootstrap_method
#80; // bootstrap_method_ref
[1] { // bootstrap_arguments
#81; // at 0x0CBA
} // bootstrap_arguments
} // bootstrap_method
}
// ======== attribute array started at 0x0C84 has 4 bytes more:
0x005D0053;
} // end BootstrapMethods
} // Attributes
} // end class LambdaMath

View file

@ -0,0 +1,68 @@
/*
* Copyright (c) 2021, 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 8268720
* @summary Constant pool NameAndType entries with valid but incompatible method
* name and signature shouldn't cause an exception until referenced by
* a method_ref.
* @compile nonVoidInitSig.jcod
* @run main/othervm -Xverify:remote NameAndTypeSig
*/
// Test constant pool NameAndType descriptors with valid but incompatible method
// names and signatures.
public class NameAndTypeSig {
public static void main(String args[]) throws Throwable {
// Test that an unreferenced NameAndType with a valid name and signature
// is allowed even for name and signature pairs such as <init>()D.
Class newClass = Class.forName("nonVoidInitSig");
// Test that a NameAndType with a valid name and signature is allowed for
// name and signature pairs such as <init>()D, but not allowed by a cp
// Method_ref.
try {
Class newClass2 = Class.forName("nonVoidInitSigCFE");
throw new RuntimeException("Expected ClassFormatError exception not thrown");
} catch (java.lang.ClassFormatError e) {
if (!e.getMessage().contains("Method \"<init>\" in class nonVoidInitSigCFE has illegal signature")) {
throw new RuntimeException("Wrong ClassFormatError exception: " + e.getMessage());
}
}
// Test that a NameAndType with a valid name and invalid signature throws a
// ClassFormatError exception with a message containing the name <init> and
// the bad signature.
try {
Class newClass2 = Class.forName("voidInitBadSig");
throw new RuntimeException("Expected ClassFormatError exception not thrown");
} catch (java.lang.ClassFormatError e) {
if (!e.getMessage().contains("Method \"<init>\" in class voidInitBadSig has illegal signature \"()))V\"")) {
throw new RuntimeException("Wrong ClassFormatError exception: " + e.getMessage());
}
}
System.out.println("Test NameAndTypeSig passed.");
}
}

View file

@ -0,0 +1,68 @@
/*
* Copyright (c) 2016, 2019, 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 8158297 8218939
* @summary Constant pool utf8 entry for class name cannot have empty qualified name '//'
* @compile p1/BadInterface1.jcod
* @compile p1/BadInterface2.jcod
* @compile UseBadInterface1.jcod
* @compile UseBadInterface2.jcod
* @run main/othervm -Xverify:all TestBadClassName
*/
public class TestBadClassName {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8042660");
// Test class name with p1//BadInterface1
String expected = "Illegal class name \"p1//BadInterface1\" in class file UseBadInterface1";
try {
Class newClass = Class.forName("UseBadInterface1");
throw new RuntimeException("Expected ClassFormatError exception not thrown");
} catch (java.lang.ClassFormatError e) {
check(e, expected);
System.out.println("Test UseBadInterface1 passed test case with illegal class name");
}
// Test class name with p1/BadInterface2/
expected = "Illegal class name \"p1/BadInterface2/\" in class file UseBadInterface2";
try {
Class newClass = Class.forName("UseBadInterface2");
throw new RuntimeException("Expected ClassFormatError exception not thrown");
} catch (java.lang.ClassFormatError e) {
check(e, expected);
System.out.println("Test UseBadInterface2 passed test case with illegal class name");
}
}
static void check(ClassFormatError c, String expected) {
if (!c.getMessage().equals(expected)) {
throw new RuntimeException("Wrong ClassFormatError - expected: \"" +
expected + "\", got \"" +
c.getMessage() + "\"");
}
}
}

View file

@ -0,0 +1,67 @@
/*
* Copyright (c) 2020, 2023, 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 8245487
* @summary Check that if the VM rejects classes from packages starting with "java/", it will exit
* cleanly after InstanceKlass::verify_on(), and not leave freed memory in _local_interfaces.
* @requires vm.flagless
* @library /test/lib
* @compile BadClassPackage.jasm
* @run driver TestBadPackageWithInterface
*/
import java.io.InputStream;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
public class TestBadPackageWithInterface {
public static void main(String args[]) throws Throwable {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-cp", System.getProperty("test.classes"),
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+VerifyBeforeExit", MyLoader.class.getName());
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
oa.shouldHaveExitValue(0);
}
static class MyLoader extends ClassLoader {
public static void main(String args[]) throws Throwable {
try {
ClassLoader loader = TestBadPackageWithInterface.class.getClassLoader();
InputStream in = loader.getResourceAsStream("java/lang/BadClassPackage.class");
byte[] bytes = in.readAllBytes();
MyLoader myLoader = new MyLoader();
myLoader.defineClass(bytes, 0, bytes.length);
}
catch (SecurityException expected) {
System.out.println("Expected ==================================================");
expected.printStackTrace(System.out);
System.out.println("==================================================");
}
}
}
}

View file

@ -0,0 +1,85 @@
/*
* Copyright (c) 2014, 2025, 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 TestEmptyBootstrapMethodsAttr
* @bug 8041918
* @library /test/lib
* @summary Test empty bootstrap_methods table within BootstrapMethods attribute
* @requires vm.flagless
* @modules java.base/jdk.internal.misc
* java.management
* @compile emptynumbootstrapmethods1.jcod emptynumbootstrapmethods2.jcod
* @run driver TestEmptyBootstrapMethodsAttr
*/
import java.io.File;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class TestEmptyBootstrapMethodsAttr {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8041918");
// Test case #1:
// Try loading class with empty bootstrap_methods table where no
// other attributes are following BootstrapMethods in attribute table.
String className = "emptynumbootstrapmethods1";
// ======= execute test case #1
// Expect a lack of main method, this implies that the class loaded correctly
// with an empty bootstrap_methods and did not generate a ClassFormatError.
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-Duser.language=en", "-Duser.country=US", className);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotContain("java.lang.ClassFormatError");
output.shouldHaveExitValue(1);
boolean vthreadMode = pb.command().toString().contains("test.thread.factory=Virtual");
if (vthreadMode) {
output.shouldContain("java.lang.NoSuchMethodException: " + className + ".main");
} else {
output.shouldContain("Main method not found in class " + className);
}
// Test case #2:
// Try loading class with empty bootstrap_methods table where an
// AnnotationDefault attribute follows the BootstrapMethods in the attribute table.
className = "emptynumbootstrapmethods2";
// ======= execute test case #2
// Expect a lack of main method, this implies that the class loaded correctly
// with an empty bootstrap_methods and did not generate ClassFormatError.
pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-Duser.language=en", "-Duser.country=US", className);
output = new OutputAnalyzer(pb.start());
output.shouldNotContain("java.lang.ClassFormatError");
output.shouldHaveExitValue(1);
vthreadMode = pb.command().toString().contains("test.thread.factory=Virtual");
if (vthreadMode) {
output.shouldContain("java.lang.NoSuchMethodException: " + className + ".main");
} else {
output.shouldContain("Main method not found in class " + className);
}
}
}

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2019, 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 8225789
* @summary Test that an unqualified name of "L;" causes a ClassFormatError exception.
* @compile EmptyUnqName.jasm
* @run main/othervm -Xverify:remote TestEmptyUnqName
*/
public class TestEmptyUnqName {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8225789");
try {
Class newClass = Class.forName("EmptyUnqName");
throw new RuntimeException("Expected ClassFormatError exception not thrown");
} catch (java.lang.ClassFormatError e) {
if (!e.getMessage().contains("Class name is empty or contains illegal character")) {
throw new RuntimeException("Wrong ClassFormatError: " + e.getMessage());
}
}
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright (c) 2021, 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 8276241
* @summary Throw ClassFormatError exception for an old class file whose name ends in a '/'.
* @run main/othervm -Xverify:remote TrailingSlashTest
*/
public class TrailingSlashTest extends ClassLoader {
@Override
public Class findClass(String fileName) throws ClassNotFoundException {
return defineClass(null, oldSlashClass, 0, oldSlashClass.length);
}
public static void main(String args[]) throws Throwable {
try {
TrailingSlashTest cl = new TrailingSlashTest();
cl.findClass("oldSlashClass");
throw new RuntimeException("Expected exception not thrown");
} catch (ClassFormatError e) {
if (!e.getMessage().contains("Illegal class name")) {
throw new RuntimeException("Wrong ClassFormatError exception: " + e.getMessage());
}
}
}
// This byte array comprises the compiled bytes of the following class. Note that the class's
// name ends in a '/' and has a class file version of 45.3.
/*
package has;
public class slashe/ { }
*/
public static byte[] oldSlashClass = {
(byte) 0xca, (byte) 0xfe, (byte) 0xba, (byte) 0xbe, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x2d,
(byte) 0x0, (byte) 0xd, (byte) 0xa, (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x3, (byte) 0x7,
(byte) 0x0, (byte) 0x4, (byte) 0xc, (byte) 0x0, (byte) 0x5, (byte) 0x0, (byte) 0x6, (byte) 0x1,
(byte) 0x0, (byte) 0x10, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c,
(byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x4f, (byte) 0x62, (byte) 0x6a, (byte) 0x65,
(byte) 0x63, (byte) 0x74, (byte) 0x1, (byte) 0x0, (byte) 0x6, (byte) 0x3c, (byte) 0x69, (byte) 0x6e,
(byte) 0x69, (byte) 0x74, (byte) 0x3e, (byte) 0x1, (byte) 0x0, (byte) 0x3, (byte) 0x28, (byte) 0x29,
(byte) 0x56, (byte) 0x7, (byte) 0x0, (byte) 0x8, (byte) 0x1, (byte) 0x0, (byte) 0xb, (byte) 0x68,
(byte) 0x61, (byte) 0x73, (byte) 0x2f, (byte) 0x73, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x68,
(byte) 0x65, (byte) 0x2f, (byte) 0x1, (byte) 0x0, (byte) 0x4, (byte) 0x43, (byte) 0x6f, (byte) 0x64,
(byte) 0x65, (byte) 0x1, (byte) 0x0, (byte) 0xf, (byte) 0x4c, (byte) 0x69, (byte) 0x6e, (byte) 0x65,
(byte) 0x4e, (byte) 0x75, (byte) 0x6d, (byte) 0x62, (byte) 0x65, (byte) 0x72, (byte) 0x54, (byte) 0x61,
(byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0x1, (byte) 0x0, (byte) 0xa, (byte) 0x53, (byte) 0x6f,
(byte) 0x75, (byte) 0x72, (byte) 0x63, (byte) 0x65, (byte) 0x46, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
(byte) 0x1, (byte) 0x0, (byte) 0xc, (byte) 0x73, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x68,
(byte) 0x65, (byte) 0x73, (byte) 0x2e, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x0,
(byte) 0x21, (byte) 0x0, (byte) 0x7, (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0,
(byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x5, (byte) 0x0,
(byte) 0x6, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x9, (byte) 0x0, (byte) 0x0, (byte) 0x0,
(byte) 0x1d, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0,
(byte) 0x5, (byte) 0x2a, (byte) 0xb7, (byte) 0x0, (byte) 0x1, (byte) 0xb1, (byte) 0x0, (byte) 0x0,
(byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0xa, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x6,
(byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x1,
(byte) 0x0, (byte) 0xb, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0xc,
};
}

View file

@ -0,0 +1,102 @@
/*
* 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 class has an unknown attribute called UnknownAttr.Added. The
// attribute should be ignored by the JVM.
//
class UnknownAttr {
0xCAFEBABE;
0; // minor version
55; // version
[] { // Constant Pool
; // first element is empty
class #2; // #1
Utf8 "UnknownAttr"; // #2
class #4; // #3
Utf8 "java/lang/Object"; // #4
Utf8 "<init>"; // #5
Utf8 "()V"; // #6
Utf8 "Code"; // #7
Method #3 #9; // #8
NameAndType #5 #6; // #9
Utf8 "main"; // #10
Utf8 "([Ljava/lang/String;)V"; // #11
Utf8 "UnknownAttr.Added"; // #12
} // Constant Pool
0x0021; // access
#1;// this_cpx
#3;// super_cpx
[] { // Interfaces
} // Interfaces
[] { // fields
} // fields
[] { // methods
{ // Member
0x0001; // access
#5; // name_cpx
#6; // sig_cpx
[] { // Attributes
Attr(#7) { // Code
1; // max_stack
1; // max_locals
Bytes[]{
0x2AB70008B1;
}
[] { // Traps
} // end Traps
[] { // Attributes
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member
0x0009; // access
#10; // name_cpx
#11; // 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(#12) { // UnknownAttr.Added
0x00;
} // end UnknownAttr.Added
} // Attributes
} // end class UnknownAttr

View file

@ -0,0 +1,44 @@
/*
* 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 8207944
* @summary Unknown attribute erroneously causes ClassFormatError exception.
* @compile UnknownAttr.jcod
* @run main UnknownAttrTest
*/
// Test that an unknown class attribute is ignored and no exception is thrown.
public class UnknownAttrTest {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8207944");
try {
Class newClass = Class.forName("UnknownAttr");
} catch (java.lang.Throwable e) {
throw new RuntimeException(
"Unexpected exception: " + e.getMessage());
}
}
}

View file

@ -0,0 +1,120 @@
/*
* Copyright (c) 2016, 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.
*
*/
// jcod file for UseBadInterface1.java
// class UseBadInterface1 implements p1.BadInterface1 {
// int i;
// UseBadInterface1() {}
// public static void main(java.lang.String[] unused) { }
// }
class UseBadInterface1 {
0xCAFEBABE;
0; // minor version
53; // version
[] { // Constant Pool
; // first element is empty
Method #3 #10; // #1
Utf8 "UseBadInterface1.java"; // #2
class #4; // #3
Utf8 "java/lang/Object"; // #4
class #8; // #5
Utf8 "([Ljava/lang/String;)V"; // #6
class #11; // #7
Utf8 "UseBadInterface1"; // #8
Utf8 "main"; // #9
NameAndType #17 #13; // #10
Utf8 "p1//BadInterface1"; // #11
Utf8 "SourceFile"; // #12
Utf8 "()V"; // #13
Utf8 "I"; // #14
Utf8 "Code"; // #15
Utf8 "i"; // #16
Utf8 "<init>"; // #17
} // Constant Pool
0x0020; // access
#5;// this_cpx
#3;// super_cpx
[] { // Interfaces
#7;
} // Interfaces
[] { // fields
{ // Member
0x0000; // access
#16; // name_cpx
#14; // sig_cpx
[] { // Attributes
} // Attributes
} // Member
} // fields
[] { // methods
{ // Member
0x0000; // access
#17; // name_cpx
#13; // sig_cpx
[] { // Attributes
Attr(#15) { // Code
1; // max_stack
1; // max_locals
Bytes[]{
0x2AB70001B1;
};
[] { // Traps
} // end Traps
[] { // Attributes
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member
0x0009; // access
#9; // name_cpx
#6; // sig_cpx
[] { // Attributes
Attr(#15) { // Code
0; // max_stack
1; // max_locals
Bytes[]{
0xB1;
};
[] { // Traps
} // end Traps
[] { // Attributes
} // Attributes
} // end Code
} // Attributes
} // Member
} // methods
[] { // Attributes
Attr(#12) { // SourceFile
#2;
} // end SourceFile
} // Attributes
} // end class UseBadInterface1

View file

@ -0,0 +1,120 @@
/*
* Copyright (c) 2016, 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.
*
*/
// jcod file for UseBadInterface2.java
// class UseBadInterface2 implements p1.BadInterface2 {
// int i;
// UseBadInterface2() {}
// public static void main(java.lang.String[] unused) { }
// }
class UseBadInterface2 {
0xCAFEBABE;
0; // minor version
53; // version
[] { // Constant Pool
; // first element is empty
Method #3 #10; // #1
Utf8 "UseBadInterface2.java"; // #2
class #4; // #3
Utf8 "java/lang/Object"; // #4
class #8; // #5
Utf8 "([Ljava/lang/String;)V"; // #6
class #11; // #7
Utf8 "UseBadInterface2"; // #8
Utf8 "main"; // #9
NameAndType #17 #13; // #10
Utf8 "p1/BadInterface2/"; // #11
Utf8 "SourceFile"; // #12
Utf8 "()V"; // #13
Utf8 "I"; // #14
Utf8 "Code"; // #15
Utf8 "i"; // #16
Utf8 "<init>"; // #17
} // Constant Pool
0x0020; // access
#5;// this_cpx
#3;// super_cpx
[] { // Interfaces
#7;
} // Interfaces
[] { // fields
{ // Member
0x0000; // access
#16; // name_cpx
#14; // sig_cpx
[] { // Attributes
} // Attributes
} // Member
} // fields
[] { // methods
{ // Member
0x0000; // access
#17; // name_cpx
#13; // sig_cpx
[] { // Attributes
Attr(#15) { // Code
1; // max_stack
1; // max_locals
Bytes[]{
0x2AB70001B1;
};
[] { // Traps
} // end Traps
[] { // Attributes
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member
0x0009; // access
#9; // name_cpx
#6; // sig_cpx
[] { // Attributes
Attr(#15) { // Code
0; // max_stack
1; // max_locals
Bytes[]{
0xB1;
};
[] { // Traps
} // end Traps
[] { // Attributes
} // Attributes
} // end Code
} // Attributes
} // Member
} // methods
[] { // Attributes
Attr(#12) { // SourceFile
#2;
} // end SourceFile
} // Attributes
} // end class UseBadInterface2

View file

@ -0,0 +1,129 @@
/*
* 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.
*
*/
// This class contains a bad element_tag in an element_value structure for a
// RuntimeVisibleAnnotation at line 91. The bad element tag should be ignored
// by the class file parser.
class badAnnotTag {
0xCAFEBABE;
0; // minor version
52; // version
[19] { // Constant Pool
; // first element is empty
class #16; // #1 at 0x0A
class #17; // #2 at 0x0D
class #18; // #3 at 0x10
Utf8 "value"; // #4 at 0x13
Utf8 "()Ljava/lang/String;"; // #5 at 0x1B
Utf8 "SourceFile"; // #6 at 0x32
Utf8 "badAnnotTag.java"; // #7 at 0x3F
Utf8 "RuntimeVisibleAnnotations"; // #8 at 0x50
Utf8 "Ljava/lang/annotation/Target;"; // #9 at 0x6C
Utf8 "Ljava/lang/annotation/ElementType;"; // #10 at 0x8C
Utf8 "TYPE_USE"; // #11 at 0xB1
Utf8 "TYPE_PARAMETER"; // #12 at 0xBC
Utf8 "Ljava/lang/annotation/Retention;"; // #13 at 0xCD
Utf8 "Ljava/lang/annotation/RetentionPolicy;"; // #14 at 0xF0
Utf8 "RUNTIME"; // #15 at 0x0119
Utf8 "badAnnotTag"; // #16 at 0x0123
Utf8 "java/lang/Object"; // #17 at 0x0127
Utf8 "java/lang/annotation/Annotation"; // #18 at 0x013A
} // Constant Pool
0x2600; // access
#1;// this_cpx
#2;// super_cpx
[1] { // Interfaces
#3;
} // Interfaces
[0] { // fields
} // fields
[1] { // methods
{ // Member at 0x016A
0x0401; // access
#4; // name_cpx
#5; // sig_cpx
[0] { // Attributes
} // Attributes
} // Member
} // methods
[2] { // Attributes
Attr(#6, 2) { // SourceFile at 0x0174
#7;
} // end SourceFile
;
Attr(#8, 32) { // RuntimeVisibleAnnotations at 0x017C
[2] { // annotations
{ // annotation
#9;
[1] { // element_value_pairs
{ // element value pair
#4;
{ // element_value
'[';
[2] { // array_value
{ // element_value
'd'; // * illegal value *, correct value is 'e'
{ // enum_const_value
#10;
#11;
} // enum_const_value
} // element_value
;
{ // element_value
'e';
{ // enum_const_value
#10;
#12;
} // enum_const_value
} // element_value
} // array_value
} // element_value
} // element value pair
} // element_value_pairs
} // annotation
;
{ // annotation
#13;
[1] { // element_value_pairs
{ // element value pair
#4;
{ // element_value
'e';
{ // enum_const_value
#14;
#15;
} // enum_const_value
} // element_value
} // element value pair
} // element_value_pairs
} // annotation
}
} // end RuntimeVisibleAnnotations
} // Attributes
} // end class badAnnotTag

View 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

View file

@ -0,0 +1,47 @@
/*
* 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.
*
*/
super public class badInit
version 52:0
{
// This <init> method has a non-void signature. It should cause a
// ClassFormatError exception.
Method "<init>":"(I)I"
stack 1 locals 2
{
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
iconst_4;
ireturn;
}
public static Method main:"([Ljava/lang/String;)V"
stack 0 locals 1
{
return;
}
} // end Class badInit

View file

@ -0,0 +1,39 @@
/*
* 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.
*
*/
// This class contains a <clinit> method with signature: (I)V. The JVM should
// not throw ClassFormatError because methods named <clinit> that have arguments
// are not illegal in class file versions < 51.
public class clinitArg version 50:0
{
public static Method "<clinit>":"(I)V"
stack 1 locals 1
{
iconst_0;
return;
}
} // end Class clinitArg

View file

@ -0,0 +1,39 @@
/*
* 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.
*
*/
// This class contains a <clinit> method with signature: (I)V. The JVM should
// throw ClassFormatError because methods named <clinit> that have arguments
// are illegal in class file version >= 51.
public class clinitArg51 version 51:0
{
public static Method "<clinit>":"(I)V"
stack 1 locals 1
{
iconst_0;
return;
}
} // end Class clinitArg51

View file

@ -0,0 +1,39 @@
/*
* 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.
*
*/
// This class contains a non-static <clinit> method. The JVM should
// throw ClassFormatError because methods named <clinit> must be static
// in class file versions >= 51.
public class clinitNonStatic version 51:0
{
public Method "<clinit>":"()V"
stack 1 locals 1
{
iconst_0;
return;
}
} // end Class clinitNonStatic

View file

@ -0,0 +1,131 @@
/*
* 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.
*
*/
// This class has an illegal NameAndType at constant pool #4. It's illegal because
// the Utf8 that it points to at #27 is a zero length string which is not a valid
// name. Loading this class should cause a ClassFormatError exception.
class emptyNameUtf8 {
0xCAFEBABE;
0; // minor version
52; // version
[29] { // Constant Pool
; // first element is empty
Method #6 #15; // #1 at 0x0A
Field #16 #17; // #2 at 0x0F
String #18; // #3 at 0x14
NameAndType #27 #28; // #4 at 0x9F
class #21; // #5 at 0x1C
class #22; // #6 at 0x1F
Utf8 "<init>"; // #7 at 0x22
Utf8 "()V"; // #8 at 0x2B
Utf8 "Code"; // #9 at 0x2E
Utf8 "LineNumberTable"; // #10 at 0x35
Utf8 "main"; // #11 at 0x47
Utf8 "([Ljava/lang/String;)V"; // #12 at 0x4E
Utf8 "SourceFile"; // #13 at 0x67
Utf8 "emptyNameUtf8.java"; // #14 at 0x74
NameAndType #7 #8; // #15 at 0x81
class #23; // #16 at 0x86
NameAndType #24 #25; // #17 at 0x89
Utf8 "Hello World"; // #18 at 0x8E
class #26; // #19 at 0x9C
Method #19 #4; // #20 at 0x17
Utf8 "emptyNameUtf8"; // #21 at 0xA4
Utf8 "java/lang/Object"; // #22 at 0xAC
Utf8 "java/lang/System"; // #23 at 0xBF
Utf8 "out"; // #24 at 0xD2
Utf8 "Ljava/io/PrintStream;"; // #25 at 0xD8
Utf8 "java/io/PrintStream"; // #26 at 0xF0
Utf8 ""; // #27 at 0x0106
Utf8 "()V"; // #28 at 0x0110
} // Constant Pool
0x0021; // access
#5;// this_cpx
#6;// super_cpx
[0] { // Interfaces
} // Interfaces
[0] { // fields
} // fields
[2] { // methods
{ // Member at 0x0134
0x0001; // access
#7; // name_cpx
#8; // sig_cpx
[1] { // Attributes
Attr(#9, 29) { // Code at 0x013C
1; // max_stack
1; // max_locals
Bytes[5]{
0x2AB70001B1;
};
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#10, 6) { // LineNumberTable at 0x0153
[1] { // LineNumberTable
0 2; // at 0x015F
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x015F
0x0009; // access
#11; // name_cpx
#12; // sig_cpx
[1] { // Attributes
Attr(#9, 37) { // Code at 0x0167
2; // max_stack
1; // max_locals
Bytes[9]{
0xB200021203B60004;
0xB1;
};
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#10, 10) { // LineNumberTable at 0x0182
[2] { // LineNumberTable
0 4; // at 0x018E
8 5; // at 0x0192
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
} // methods
[1] { // Attributes
Attr(#13, 2) { // SourceFile at 0x0194
#14;
} // end SourceFile
} // Attributes
} // end class emptyNameUtf8

View file

@ -0,0 +1,131 @@
/*
* 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.
*
*/
// This class has an illegal NameAndType at constant pool #4. It's illegal because
// the type that it points to at #28 is a zero length Utf8 string which is not a
// valid signature. Loading this class should cause a ClassFormatError exception.
class emptySigUtf8 {
0xCAFEBABE;
0; // minor version
52; // version
[29] { // Constant Pool
; // first element is empty
Method #6 #15; // #1 at 0x0A
Field #16 #17; // #2 at 0x0F
String #18; // #3 at 0x14
NameAndType #27 #28; // #4 at 0x9F
class #21; // #5 at 0x1C
class #22; // #6 at 0x1F
Utf8 "<init>"; // #7 at 0x22
Utf8 "()V"; // #8 at 0x2B
Utf8 "Code"; // #9 at 0x2E
Utf8 "LineNumberTable"; // #10 at 0x35
Utf8 "main"; // #11 at 0x47
Utf8 "([Ljava/lang/String;)V"; // #12 at 0x4E
Utf8 "SourceFile"; // #13 at 0x67
Utf8 "emptySigUtf8.java"; // #14 at 0x74
NameAndType #7 #8; // #15 at 0x81
class #23; // #16 at 0x86
NameAndType #24 #25; // #17 at 0x89
Utf8 "Hello World"; // #18 at 0x8E
class #26; // #19 at 0x9C
Method #19 #4; // #20 at 0x17
Utf8 "emptySigUtf8"; // #21 at 0xA4
Utf8 "java/lang/Object"; // #22 at 0xAC
Utf8 "java/lang/System"; // #23 at 0xBF
Utf8 "out"; // #24 at 0xD2
Utf8 "Ljava/io/PrintStream;"; // #25 at 0xD8
Utf8 "java/io/PrintStream"; // #26 at 0xF0
Utf8 "hi"; // #27 at 0x0106
Utf8 ""; // #28 at 0x0110
} // Constant Pool
0x0021; // access
#5;// this_cpx
#6;// super_cpx
[0] { // Interfaces
} // Interfaces
[0] { // fields
} // fields
[2] { // methods
{ // Member at 0x0134
0x0001; // access
#7; // name_cpx
#8; // sig_cpx
[1] { // Attributes
Attr(#9, 29) { // Code at 0x013C
1; // max_stack
1; // max_locals
Bytes[5]{
0x2AB70001B1;
};
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#10, 6) { // LineNumberTable at 0x0153
[1] { // LineNumberTable
0 2; // at 0x015F
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x015F
0x0009; // access
#11; // name_cpx
#12; // sig_cpx
[1] { // Attributes
Attr(#9, 37) { // Code at 0x0167
2; // max_stack
1; // max_locals
Bytes[9]{
0xB200021203B60004;
0xB1;
};
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#10, 10) { // LineNumberTable at 0x0182
[2] { // LineNumberTable
0 4; // at 0x018E
8 5; // at 0x0192
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
} // methods
[1] { // Attributes
Attr(#13, 2) { // SourceFile at 0x0194
#14;
} // end SourceFile
} // Attributes
} // end class emptySigUtf8

View file

@ -0,0 +1,68 @@
/*
* Copyright (c) 2014, 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 BootstrapMethods attribute with an empty
* bootstrap_methods table. This yields a BootstrapMethods
* attribute length of 2 and should not cause a
* java.lang.ClassFormatError to be thrown.
*/
class emptynumbootstrapmethods1 {
0xCAFEBABE;
0; // minor version
51; // version
[12] { // Constant Pool
; // first element is empty
class #2; // #1 at 0x0A
Utf8 "emptynumbootstrapmethods1"; // #2 at 0x0D
class #4; // #3 at 0x1F
Utf8 "java/lang/Object"; // #4 at 0x22
MethodHandle 5b #9; // #5 at 0x35
NameAndType #7 #8; // #6 at 0x39
Utf8 "equals"; // #7 at 0x3E
Utf8 "(Ljava/lang/Object;)Z"; // #8 at 0x47
Method #3 #6; // #9 at 0x5F
Utf8 "equalsx"; // #10 at 0x3E
Utf8 "BootstrapMethods"; // #11 at 0x69
} // Constant Pool
0x0001; // access
#1;// this_cpx
#3;// super_cpx
[0] { // Interfaces
} // Interfaces
[0] { // fields
} // fields
[0] { // methods
} // methods
[1] { // Attributes
Attr(#11, 2) { // BootstrapMethods at 0x8A
[0] { // bootstrap_methods
}
} // end BootstrapMethods
} // Attributes
} // end class atrbsm00101m10p

View file

@ -0,0 +1,89 @@
/*
* Copyright (c) 2014, 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 BootstrapMethods attribute with an empty
* bootstrap_methods table. This yields a BootstrapMethods
* attribute length of 2 and should not cause a
* java.lang.ClassFormatError to be thrown. To ensure that an empty
* bootstrap_methods table is parsed correctly, another attribute,
* AnnotationDefault, follows the BootstrapMethods attribute in
* the attribute table.
*/
class emptynumbootstrapmethods2 {
0xCAFEBABE;
0; // minor version
51; // version
[14] { // Constant Pool
; // first element is empty
class #2; // #1 at 0x0A
Utf8 "emptynumbootstrapmethods2"; // #2 at 0x0D
class #4; // #3 at 0x1F
Utf8 "java/lang/Object"; // #4 at 0x22
MethodHandle 5b #9; // #5 at 0x35
NameAndType #7 #8; // #6 at 0x39
Utf8 "equals"; // #7 at 0x3E
Utf8 "(Ljava/lang/Object;)Z"; // #8 at 0x47
Method #3 #6; // #9 at 0x5F
Utf8 "equalsx"; // #10 at 0x3E
Utf8 "BootstrapMethods"; // #11 at 0x69
Utf8 "AnnotationDefault"; // #12
Utf8 "LAnnotationDefaultI;"; // #13
} // Constant Pool
0x0001; // access
#1;// this_cpx
#3;// super_cpx
[0] { // Interfaces
} // Interfaces
[0] { // fields
} // fields
[0] { // methods
} // methods
[2] { // Attributes
Attr(#11, 2) { // BootstrapMethods at 0x8A
[0] { // bootstrap_methods
}
} // end BootstrapMethods
;
Attr(#12) { // AnnotationDefault
[] { // type annotations
{ // type annotation
0x00; // target_type
0x00; // type_parameter_index
[]b { // type_path
}
#13; // type_index
[] { // element_value_pairs
} // element_value_pairs
} // type annotation
} // type annotations
} // end AnnotationDefault
} // Attributes
} // end class atrbsm00101m10p

View file

@ -0,0 +1,71 @@
/*
* Copyright (c) 2016, 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 the Java representation of the below jasm code. The test tries
// to create a sub-type of jdk.internal.reflect.MethodAccessorImpl in order
// to bypass Reflection.getCallerClass. That should fail with an IAE.
//
class fakeMethodAccessor extends jdk.internal.reflect.MethodAccessorImpl {
public static void main(String[] a) throws Exception {
fakeMethodAccessor f = new fakeMethodAccessor();
System.out.println(String.class.getModule()
.isExported("jdk.internal.misc", fakeMethodAccessor.class.getModule()));
}
}
*/
super class fakeMethodAccessor
extends jdk/internal/reflect/MethodAccessorImpl
version 53:0
{
Method "<init>":"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method jdk/internal/reflect/MethodAccessorImpl."<init>":"()V";
return;
}
public static Method main:"([Ljava/lang/String;)V"
throws java/lang/Exception
stack 4 locals 2
{
new class FakeMethodAccessor;
dup;
invokespecial Method "<init>":"()V";
astore_1;
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
ldc class java/lang/String;
invokevirtual Method java/lang/Class.getModule:"()Ljava/lang/Module;";
ldc String "jdk.internal.misc";
ldc class FakeMethodAccessor;
invokevirtual Method java/lang/Class.getModule:"()Ljava/lang/Module;";
invokevirtual Method java/lang/Module.isExported:"(Ljava/lang/String;Ljava/lang/Module;)Z";
invokevirtual Method java/io/PrintStream.println:"(Z)V";
return;
}
} // end Class FakeMethodAccessor

View file

@ -0,0 +1,346 @@
/*
* Copyright (c) 2021, 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.
*/
// The constant pool in this class contains an unused NameAndType entry (#20)
// that points to method <init> and signature ()D. This is a valid NameAndType
// because <init> is a valid method name and ()D is a valid method signature.
class nonVoidInitSig {
0xCAFEBABE;
0; // minor version
62; // version
[21] { // Constant Pool
; // first element is empty
Method #2 #3; // #1 at 0x0A
class #4; // #2 at 0x0F
NameAndType #5 #6; // #3 at 0x12
Utf8 "java/lang/Object"; // #4 at 0x17
Utf8 "<init>"; // #5 at 0x2A
Utf8 "()V"; // #6 at 0x33
class #8; // #7 at 0x39
Utf8 "nonVoidInitSig"; // #8 at 0x3C
Method #7 #3; // #9 at 0x47
Utf8 "Code"; // #10 at 0x4C
Utf8 "LineNumberTable"; // #11 at 0x53
Utf8 "func"; // #12 at 0x65
Utf8 "([Ljava/lang/String;)V"; // #13 at 0x6C
Utf8 "Exceptions"; // #14 at 0x85
class #16; // #15 at 0x92
Utf8 "java/lang/Throwable"; // #16 at 0x95
Utf8 "SourceFile"; // #17 at 0xAB
Utf8 "nonVoidInitSig.java"; // #18 at 0xB8
Utf8 "()D"; // #19
NameAndType #5 #19; // #20 // Unused, points to <init>()D.
} // Constant Pool
0x0021; // access [ ACC_PUBLIC ACC_SUPER ]
#7;// this_cpx
#2;// super_cpx
[0] { // Interfaces
} // Interfaces
[0] { // Fields
} // Fields
[2] { // Methods
{ // method at 0xD4
0x0001; // access
#5; // name_index : <init>
#6; // descriptor_index : ()V
[1] { // Attributes
Attr(#10, 29) { // Code at 0xDC
1; // max_stack
1; // max_locals
Bytes[5]{
0x2AB70001B1;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#11, 6) { // LineNumberTable at 0xF3
[1] { // line_number_table
0 1; // at 0xFF
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
}
;
{ // method at 0xFF
0x0009; // access
#12; // name_index : func
#13; // descriptor_index : ([Ljava/lang/String;)V
[2] { // Attributes
Attr(#10, 37) { // Code at 0x0107
2; // max_stack
2; // max_locals
Bytes[9]{
0xBB000759B700094C;
0xB1;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#11, 10) { // LineNumberTable at 0x0122
[2] { // line_number_table
0 4; // at 0x012E
8 5; // at 0x0132
}
} // end LineNumberTable
} // Attributes
} // end Code
;
Attr(#14, 4) { // Exceptions at 0x0132
[1] { // Exceptions
#15; // at 0x013C
}
} // end Exceptions
} // Attributes
}
} // Methods
[1] { // Attributes
Attr(#17, 2) { // SourceFile at 0x013E
#18;
} // end SourceFile
} // Attributes
} // end class nonVoidInitSig
// The constant pool in this class contains a cp NameAndType entry (#3) that
// points to method <init> and signature ()D. This is a valid NameAndType
// because <init> is a valid method name and ()D is a valid method signature.
// But, a cp Methodref (#1) that points to NameAndType with a method named
// <init> and a non-void return type, is invalid.
class nonVoidInitSigCFE {
0xCAFEBABE;
0; // minor version
62; // version
[20] { // Constant Pool
; // first element is empty
Method #2 #3; // #1 at 0x0A
class #4; // #2 at 0x0F
NameAndType #5 #19; // #3 at 0x12
Utf8 "java/lang/Object"; // #4 at 0x17
Utf8 "<init>"; // #5 at 0x2A
Utf8 "()V"; // #6 at 0x33
class #8; // #7 at 0x39
Utf8 "nonVoidInitSigCFE"; // #8 at 0x3C
Method #7 #3; // #9 at 0x47
Utf8 "Code"; // #10 at 0x4C
Utf8 "LineNumberTable"; // #11 at 0x53
Utf8 "func"; // #12 at 0x65
Utf8 "([Ljava/lang/String;)V"; // #13 at 0x6C
Utf8 "Exceptions"; // #14 at 0x85
class #16; // #15 at 0x92
Utf8 "java/lang/Throwable"; // #16 at 0x95
Utf8 "SourceFile"; // #17 at 0xAB
Utf8 "nonVoidInitSigCFE.java"; // #18 at 0xB8
Utf8 "()D"; // #19
} // Constant Pool
0x0021; // access [ ACC_PUBLIC ACC_SUPER ]
#7;// this_cpx
#2;// super_cpx
[0] { // Interfaces
} // Interfaces
[0] { // Fields
} // Fields
[2] { // Methods
{ // method at 0xD4
0x0001; // access
#5; // name_index : <init>
#6; // descriptor_index : ()V
[1] { // Attributes
Attr(#10, 29) { // Code at 0xDC
1; // max_stack
1; // max_locals
Bytes[5]{
0x2AB70001B1;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#11, 6) { // LineNumberTable at 0xF3
[1] { // line_number_table
0 1; // at 0xFF
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
}
;
{ // method at 0xFF
0x0009; // access
#12; // name_index : func
#13; // descriptor_index : ([Ljava/lang/String;)V
[2] { // Attributes
Attr(#10, 37) { // Code at 0x0107
2; // max_stack
2; // max_locals
Bytes[9]{
0xBB000759B700094C;
0xB1;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#11, 10) { // LineNumberTable at 0x0122
[2] { // line_number_table
0 4; // at 0x012E
8 5; // at 0x0132
}
} // end LineNumberTable
} // Attributes
} // end Code
;
Attr(#14, 4) { // Exceptions at 0x0132
[1] { // Exceptions
#15; // at 0x013C
}
} // end Exceptions
} // Attributes
}
} // Methods
[1] { // Attributes
Attr(#17, 2) { // SourceFile at 0x013E
#18;
} // end SourceFile
} // Attributes
} // end class nonVoidInitSigCFE
// The constant pool in this class contains a cp NameAndType entry (#20) that
// points to method <init> and signature ()))V. This is an invalid NameAndType
// entry and should throw a ClassFormatError exception, with a message containing
// the name <init> and the bad signature, even thought the NameAndType is not
// referenced by a cp Methodref.
class voidInitBadSig {
0xCAFEBABE;
0; // minor version
62; // version
[21] { // Constant Pool
; // first element is empty
Method #2 #3; // #1 at 0x0A
class #4; // #2 at 0x0F
NameAndType #5 #6; // #3 at 0x12
Utf8 "java/lang/Object"; // #4 at 0x17
Utf8 "<init>"; // #5 at 0x2A
Utf8 "()V"; // #6 at 0x33
class #8; // #7 at 0x39
Utf8 "voidInitBadSig"; // #8 at 0x3C
Method #7 #3; // #9 at 0x47
Utf8 "Code"; // #10 at 0x4C
Utf8 "LineNumberTable"; // #11 at 0x53
Utf8 "func"; // #12 at 0x65
Utf8 "([Ljava/lang/String;)V"; // #13 at 0x6C
Utf8 "Exceptions"; // #14 at 0x85
class #16; // #15 at 0x92
Utf8 "java/lang/Throwable"; // #16 at 0x95
Utf8 "SourceFile"; // #17 at 0xAB
Utf8 "voidInitBadSig.java"; // #18 at 0xB8
Utf8 "()))V"; // #19
NameAndType #5 #19; // #20 // Unused, points to <init>()))V.
} // Constant Pool
0x0021; // access [ ACC_PUBLIC ACC_SUPER ]
#7;// this_cpx
#2;// super_cpx
[0] { // Interfaces
} // Interfaces
[0] { // Fields
} // Fields
[2] { // Methods
{ // method at 0xD4
0x0001; // access
#5; // name_index : <init>
#6; // descriptor_index : ()V
[1] { // Attributes
Attr(#10, 29) { // Code at 0xDC
1; // max_stack
1; // max_locals
Bytes[5]{
0x2AB70001B1;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#11, 6) { // LineNumberTable at 0xF3
[1] { // line_number_table
0 1; // at 0xFF
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
}
;
{ // method at 0xFF
0x0009; // access
#12; // name_index : func
#13; // descriptor_index : ([Ljava/lang/String;)V
[2] { // Attributes
Attr(#10, 37) { // Code at 0x0107
2; // max_stack
2; // max_locals
Bytes[9]{
0xBB000759B700094C;
0xB1;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#11, 10) { // LineNumberTable at 0x0122
[2] { // line_number_table
0 4; // at 0x012E
8 5; // at 0x0132
}
} // end LineNumberTable
} // Attributes
} // end Code
;
Attr(#14, 4) { // Exceptions at 0x0132
[1] { // Exceptions
#15; // at 0x013C
}
} // end Exceptions
} // Attributes
}
} // Methods
[1] { // Attributes
Attr(#17, 2) { // SourceFile at 0x013E
#18;
} // end SourceFile
} // Attributes
} // end class voidInitBadSig

View file

@ -0,0 +1,39 @@
/*
* 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.
*
*/
// This class contains a <clinit> method with signature: ()I. The JVM should
// throw ClassFormatError because methods named <clinit> that are not void
// are illegal.
public class nonvoidClinit version 51:0
{
public static Method "<clinit>":"()I"
stack 1 locals 1
{
iconst_0;
ireturn;
}
} // end Class nonvoidClinit

View file

@ -0,0 +1,31 @@
/*
* 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.
*
*/
// Interface containing non-void <init> method.
public interface nonvoidinit version 50:0
{
public abstract Method "<init>":"()I";
} // end Class nonvoidinit

View file

@ -0,0 +1,62 @@
/*
* Copyright (c) 2016, 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.
*
*/
// Interface that should get a ClassFormatException for the "//" in the name
// package p1;
// public interface cls1 {}
class p1//BadInterface1 {
0xCAFEBABE;
0; // minor version
53; // version
[] { // Constant Pool
; // first element is empty
class #5; // #1
class #6; // #2
Utf8 "SourceFile"; // #3
Utf8 "BadInterface1.java"; // #4
Utf8 "p1//BadInterface1"; // #5
Utf8 "java/lang/Object"; // #6
} // Constant Pool
0x0601; // access
#1;// this_cpx
#2;// super_cpx
[] { // Interfaces
} // Interfaces
[] { // fields
} // fields
[] { // methods
} // methods
[] { // Attributes
Attr(#3) { // SourceFile
#4;
} // end SourceFile
} // Attributes
} // end class p1//BadInterface1

View file

@ -0,0 +1,62 @@
/*
* Copyright (c) 2016, 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.
*
*/
// Interface that should get a ClassFormatException for the trailing "/" in the name
// package p1;
// public interface cls1 {}
class p1/BadInterface2/ {
0xCAFEBABE;
0; // minor version
53; // version
[] { // Constant Pool
; // first element is empty
class #5; // #1
class #6; // #2
Utf8 "SourceFile"; // #3
Utf8 "BadInterface2.java"; // #4
Utf8 "p1/BadInterface2/"; // #5
Utf8 "java/lang/Object"; // #6
} // Constant Pool
0x0601; // access
#1;// this_cpx
#2;// super_cpx
[] { // Interfaces
} // Interfaces
[] { // fields
} // fields
[] { // methods
} // methods
[] { // Attributes
Attr(#3) { // SourceFile
#4;
} // end SourceFile
} // Attributes
} // end class p1/BadInterface2

View file

@ -0,0 +1,31 @@
/*
* 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.
*
*/
// Interface containing void <init> method.
public interface voidinit version 50:0
{
public abstract Method "<init>":"()V";
} // end Class voidinit