ADDITIONAL SYSTEM INFORMATION :
ADDITIONAL SYSTEM INFORMATION :
```
OS:
Operating System Name: Windows 11
Operating System Architecture: amd64
Operating System Version: 10.0
```
OpenJDK version:
```
java version "1.8.0_451"
Java(TM) SE Runtime Environment (build 1.8.0_451-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.451-b10, mixed mode)
java version "11.0.27" 2025-04-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.27+8-LTS-232)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.27+8-LTS-232, mixed mode)
openjdk version "1.8.0_452"
IBM Semeru Runtime Open Edition (build 1.8.0_452-b09)
Eclipse OpenJ9 VM (build openj9-0.51.0, JRE 1.8.0 Windows 11 amd64-64-Bit Compressed References 20250504_1243 (JIT enabled, AOT enabled)
OpenJ9 - 31cf5538b0
OMR - 9bcff94a2
JCL - a00de86921 based on jdk8u452-b09)
openjdk version "11.0.27" 2025-04-15
IBM Semeru Runtime Open Edition 11.0.27.0 (build 11.0.27+6)
Eclipse OpenJ9 VM 11.0.27.0 (build openj9-0.51.0, JRE 11 Windows 11 amd64-64-Bit Compressed References 20250504_1192 (JIT enabled, AOT enabled)
OpenJ9 - 31cf5538b0
OMR - 9bcff94a2
JCL - 3e17c0897e based on jdk-11.0.27+6)
```
Output from `java -version`.
A DESCRIPTION OF THE PROBLEM :
Given a test case, we found that the execution results of this test case on different JVMs are different, the simplified test case can be found below. In summary, HotSpot threw
IllegalAccessError while J9 threw NoSuchMethodError.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Repoduce:
```
>>> path_to_jdk/hotspot/1.8.0_451/bin/java -cp . TestLauncher
>>> path_to_jdk/hotspot/11.0.27/bin/java -cp . TestLauncher
>>> path_to_jdk/openj9/1.8.0_452/bin/java -cp . TestLauncher
>>> path_to_jdk/openj9/11.0.27/bin/java -cp . TestLauncher
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After reviewing the code of java/lang/Class based on the above results, we found that there is no constructor of the form java/lang/Class.<init>(Ljava/lang/String;)V. Therefore, HotSpot should throw a NoSuchMethodError instead of an IllegalAccess Error.
ACTUAL -
The output is as follows:
hotspot(1.8.0_451):
```
Exception in thread "main" java.lang.IllegalAccessError: java.lang.Class
at TestLauncher.main(Unknown Source)
```
hotspot(11.0.27):
```
Exception in thread "main" java.lang.IllegalAccessError: java.lang.Class
at TestLauncher.main(Unknown Source)
```
j9(1.8.0_452):
```
Exception in thread "main" java.lang.NoSuchMethodError: java/lang/Class.<init>(Ljava/lang/String;)V (loaded from D:\download\jdk\openj9\jdk-8u452-b09\jre\lib\rt.jar by <Bootstrap Loader>) called from class TestLauncher (loaded from file:/D:/Lab/TestJDoc/reduce/your_dir/ by sun.misc.Launcher$AppClassLoader@599f5fea).
at TestLauncher.main(Unknown Source)
```
j9(11.0.27):
```
Exception in thread "main" java.lang.NoSuchMethodError: java/lang/Class.<init>(Ljava/lang/String;)V (loaded from jrt:/java.base by <Bootstrap Lo
ader>) called from class TestLauncher (loaded from file:/D:/Lab/TestJDoc/reduce/your_dir/ by jdk.internal.loader.ClassLoaders$AppClassLoader@a53766fe).
at TestLauncher.main(Unknown Source)
```
---------- BEGIN SOURCE ----------
The following code can be used to generate the test cases(.class file) that reproduces the above process:
```java
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class BytecodeUtil {
public static void main(String args[]) {
// create package
String baseDir = "./your_dir"; // your base dir
File baseDirFile = new File(baseDir);
baseDirFile.mkdirs();
String BoundaryInterface_bytecodeInStr = "CAFEBABE000000340009010011426F756E64617279496E746572666163650700010100106A6176612F6C616E672F4F626A65637407000301000A496E746572666163653107000501000A496E7465726661636533070007060100020004000200060008000000000000" ;
String interface1_bytecodeInStr = "CAFEBABE00000034000701000A496E74657266616365310700010100106A6176612F6C616E672F4F626A6563740700030100076D6574686F643101000328295606010002000400000000000104010005000600000000" ;
String interface2_bytecodeInStr = "CAFEBABE00000034000701000A496E74657266616365320700010100106A6176612F6C616E672F4F626A6563740700030100076D6574686F643201000328295606010002000400000000000104010005000600000000" ;
String interface3_bytecodeInStr = "CAFEBABE00000034000701000A496E74657266616365330700010100106A6176612F6C616E672F4F626A6563740700030100076D6574686F643101000328295606010002000400000000000104010005000600000000" ;
String interface4_bytecodeInStr = "CAFEBABE00000034000701000A496E74657266616365340700010100106A6176612F6C616E672F4F626A6563740700030100076D6574686F64310100042849295606010002000400000000000104010005000600000000" ;
String InvalidInterface_bytecodeInStr = "CAFEBABE000000340009010010496E76616C6964496E746572666163650700010100106A6176612F6C616E672F4F626A65637407000301000A496E746572666163653107000501000A496E7465726661636534070007060100020004000200060008000000000000" ;
String ValidInterface_bytecodeInStr = "CAFEBABE00000034000901000E56616C6964496E746572666163650700010100106A6176612F6C616E672F4F626A65637407000301000A496E746572666163653107000501000A496E7465726661636532070007060100020004000200060008000000000000" ;
String TestLauncher_bytecodeInStr = "CAFEBABE00000034002501000C546573744C61756E636865720700010100106A6176612F6C616E672F4F626A6563740700030100046D61696E010016285B4C6A6176612F6C616E672F537472696E673B295601000F6A6176612F6C616E672F436C61737307000701000E56616C6964496E746572666163650800090100063C696E69743E010015284C6A6176612F6C616E672F537472696E673B29560C000B000C0A0008000D0100106A6176612F6C616E672F53797374656D07000F0100036F75740100154C6A6176612F696F2F5072696E7453747265616D3B0C00110012090010001301002356616C6964496E74657266616365206C6F61646564207375636365737366756C6C792E0800150100136A6176612F696F2F5072696E7453747265616D0700170100077072696E746C6E0C0019000C0A0018001A010011426F756E64617279496E7465726661636508001C010026426F756E64617279496E74657266616365206C6F61646564207375636365737366756C6C792E08001E010010496E76616C6964496E74657266616365080020010046496E76616C6964496E74657266616365206C6F6164206661696C3A20496E636F6E73697374656E74206D6574686F642064657363726970746F7220666F72206D6574686F6431080022010004436F646500210002000400000000000100090005000600010024000000400005000100000034BB000859120AB7000EB200141216B6001BBB000859121DB7000EB20014121FB6001BBB0008591221B7000EB200141223B6001BB1000000000000" ;
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "BoundaryInterface.class")) {
byte[] BoundaryInterface_bytecode = hexStringToByteArray(BoundaryInterface_bytecodeInStr);
fos.write(BoundaryInterface_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "interface1.class")) {
byte[] interface1_bytecode = hexStringToByteArray(interface1_bytecodeInStr);
fos.write(interface1_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "interface2.class")) {
byte[] interface2_bytecode = hexStringToByteArray(interface2_bytecodeInStr);
fos.write(interface2_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "interface3.class")) {
byte[] interface3_bytecode = hexStringToByteArray(interface3_bytecodeInStr);
fos.write(interface3_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "interface4.class")) {
byte[] interface4_bytecode = hexStringToByteArray(interface4_bytecodeInStr);
fos.write(interface4_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "InvalidInterface.class")) {
byte[] InvalidInterface_bytecode = hexStringToByteArray(InvalidInterface_bytecodeInStr);
fos.write(InvalidInterface_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "ValidInterface.class")) {
byte[] ValidInterface_bytecode = hexStringToByteArray(ValidInterface_bytecodeInStr);
fos.write(ValidInterface_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "TestLauncher.class")) {
byte[] TestLauncher_bytecode = hexStringToByteArray(TestLauncher_bytecodeInStr);
fos.write(TestLauncher_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
}
public static byte[] hexStringToByteArray(String hexString) {
int length = hexString.length();
byte[] byteArray = new byte[length / 2];
for (int i = 0; i < length; i += 2) {
int byteValue = Integer.parseInt(hexString.substring(i, i + 2), 16);
byteArray[i / 2] = (byte) byteValue;
}
return byteArray;
}
}
```
Note: modify the paths according to your needs.
After obtaining the test cases, you can derive the following test cases through decompilation:
```java
public interface BoundaryInterface extends Interface1, Interface3 {
}
```
```java
public interface Interface1 {
void method1();
}
```
```java
public interface Interface2 {
void method2();
}
```
```java
public interface Interface3 {
void method1();
}
```
```java
public interface Interface4 {
void method1(int var1);
}
```
```java
public interface InvalidInterface extends Interface1, Interface4 {
}
```
```java
public class TestLauncher {
public static void main(String[] var0) {
new Class("ValidInterface");
System.out.println("ValidInterface loaded successfully.");
new Class("BoundaryInterface");
System.out.println("BoundaryInterface loaded successfully.");
new Class("InvalidInterface");
System.out.println("InvalidInterface load fail: Inconsistent method descriptor for method1");
}
}
```
```java
public interface ValidInterface extends Interface1, Interface2 {
}
```
---------- END SOURCE ----------
ADDITIONAL SYSTEM INFORMATION :
```
OS:
Operating System Name: Windows 11
Operating System Architecture: amd64
Operating System Version: 10.0
```
OpenJDK version:
```
java version "1.8.0_451"
Java(TM) SE Runtime Environment (build 1.8.0_451-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.451-b10, mixed mode)
java version "11.0.27" 2025-04-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.27+8-LTS-232)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.27+8-LTS-232, mixed mode)
openjdk version "1.8.0_452"
IBM Semeru Runtime Open Edition (build 1.8.0_452-b09)
Eclipse OpenJ9 VM (build openj9-0.51.0, JRE 1.8.0 Windows 11 amd64-64-Bit Compressed References 20250504_1243 (JIT enabled, AOT enabled)
OpenJ9 - 31cf5538b0
OMR - 9bcff94a2
JCL - a00de86921 based on jdk8u452-b09)
openjdk version "11.0.27" 2025-04-15
IBM Semeru Runtime Open Edition 11.0.27.0 (build 11.0.27+6)
Eclipse OpenJ9 VM 11.0.27.0 (build openj9-0.51.0, JRE 11 Windows 11 amd64-64-Bit Compressed References 20250504_1192 (JIT enabled, AOT enabled)
OpenJ9 - 31cf5538b0
OMR - 9bcff94a2
JCL - 3e17c0897e based on jdk-11.0.27+6)
```
Output from `java -version`.
A DESCRIPTION OF THE PROBLEM :
Given a test case, we found that the execution results of this test case on different JVMs are different, the simplified test case can be found below. In summary, HotSpot threw
IllegalAccessError while J9 threw NoSuchMethodError.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Repoduce:
```
>>> path_to_jdk/hotspot/1.8.0_451/bin/java -cp . TestLauncher
>>> path_to_jdk/hotspot/11.0.27/bin/java -cp . TestLauncher
>>> path_to_jdk/openj9/1.8.0_452/bin/java -cp . TestLauncher
>>> path_to_jdk/openj9/11.0.27/bin/java -cp . TestLauncher
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After reviewing the code of java/lang/Class based on the above results, we found that there is no constructor of the form java/lang/Class.<init>(Ljava/lang/String;)V. Therefore, HotSpot should throw a NoSuchMethodError instead of an IllegalAccess Error.
ACTUAL -
The output is as follows:
hotspot(1.8.0_451):
```
Exception in thread "main" java.lang.IllegalAccessError: java.lang.Class
at TestLauncher.main(Unknown Source)
```
hotspot(11.0.27):
```
Exception in thread "main" java.lang.IllegalAccessError: java.lang.Class
at TestLauncher.main(Unknown Source)
```
j9(1.8.0_452):
```
Exception in thread "main" java.lang.NoSuchMethodError: java/lang/Class.<init>(Ljava/lang/String;)V (loaded from D:\download\jdk\openj9\jdk-8u452-b09\jre\lib\rt.jar by <Bootstrap Loader>) called from class TestLauncher (loaded from file:/D:/Lab/TestJDoc/reduce/your_dir/ by sun.misc.Launcher$AppClassLoader@599f5fea).
at TestLauncher.main(Unknown Source)
```
j9(11.0.27):
```
Exception in thread "main" java.lang.NoSuchMethodError: java/lang/Class.<init>(Ljava/lang/String;)V (loaded from jrt:/java.base by <Bootstrap Lo
ader>) called from class TestLauncher (loaded from file:/D:/Lab/TestJDoc/reduce/your_dir/ by jdk.internal.loader.ClassLoaders$AppClassLoader@a53766fe).
at TestLauncher.main(Unknown Source)
```
---------- BEGIN SOURCE ----------
The following code can be used to generate the test cases(.class file) that reproduces the above process:
```java
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class BytecodeUtil {
public static void main(String args[]) {
// create package
String baseDir = "./your_dir"; // your base dir
File baseDirFile = new File(baseDir);
baseDirFile.mkdirs();
String BoundaryInterface_bytecodeInStr = "CAFEBABE000000340009010011426F756E64617279496E746572666163650700010100106A6176612F6C616E672F4F626A65637407000301000A496E746572666163653107000501000A496E7465726661636533070007060100020004000200060008000000000000" ;
String interface1_bytecodeInStr = "CAFEBABE00000034000701000A496E74657266616365310700010100106A6176612F6C616E672F4F626A6563740700030100076D6574686F643101000328295606010002000400000000000104010005000600000000" ;
String interface2_bytecodeInStr = "CAFEBABE00000034000701000A496E74657266616365320700010100106A6176612F6C616E672F4F626A6563740700030100076D6574686F643201000328295606010002000400000000000104010005000600000000" ;
String interface3_bytecodeInStr = "CAFEBABE00000034000701000A496E74657266616365330700010100106A6176612F6C616E672F4F626A6563740700030100076D6574686F643101000328295606010002000400000000000104010005000600000000" ;
String interface4_bytecodeInStr = "CAFEBABE00000034000701000A496E74657266616365340700010100106A6176612F6C616E672F4F626A6563740700030100076D6574686F64310100042849295606010002000400000000000104010005000600000000" ;
String InvalidInterface_bytecodeInStr = "CAFEBABE000000340009010010496E76616C6964496E746572666163650700010100106A6176612F6C616E672F4F626A65637407000301000A496E746572666163653107000501000A496E7465726661636534070007060100020004000200060008000000000000" ;
String ValidInterface_bytecodeInStr = "CAFEBABE00000034000901000E56616C6964496E746572666163650700010100106A6176612F6C616E672F4F626A65637407000301000A496E746572666163653107000501000A496E7465726661636532070007060100020004000200060008000000000000" ;
String TestLauncher_bytecodeInStr = "CAFEBABE00000034002501000C546573744C61756E636865720700010100106A6176612F6C616E672F4F626A6563740700030100046D61696E010016285B4C6A6176612F6C616E672F537472696E673B295601000F6A6176612F6C616E672F436C61737307000701000E56616C6964496E746572666163650800090100063C696E69743E010015284C6A6176612F6C616E672F537472696E673B29560C000B000C0A0008000D0100106A6176612F6C616E672F53797374656D07000F0100036F75740100154C6A6176612F696F2F5072696E7453747265616D3B0C00110012090010001301002356616C6964496E74657266616365206C6F61646564207375636365737366756C6C792E0800150100136A6176612F696F2F5072696E7453747265616D0700170100077072696E746C6E0C0019000C0A0018001A010011426F756E64617279496E7465726661636508001C010026426F756E64617279496E74657266616365206C6F61646564207375636365737366756C6C792E08001E010010496E76616C6964496E74657266616365080020010046496E76616C6964496E74657266616365206C6F6164206661696C3A20496E636F6E73697374656E74206D6574686F642064657363726970746F7220666F72206D6574686F6431080022010004436F646500210002000400000000000100090005000600010024000000400005000100000034BB000859120AB7000EB200141216B6001BBB000859121DB7000EB20014121FB6001BBB0008591221B7000EB200141223B6001BB1000000000000" ;
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "BoundaryInterface.class")) {
byte[] BoundaryInterface_bytecode = hexStringToByteArray(BoundaryInterface_bytecodeInStr);
fos.write(BoundaryInterface_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "interface1.class")) {
byte[] interface1_bytecode = hexStringToByteArray(interface1_bytecodeInStr);
fos.write(interface1_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "interface2.class")) {
byte[] interface2_bytecode = hexStringToByteArray(interface2_bytecodeInStr);
fos.write(interface2_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "interface3.class")) {
byte[] interface3_bytecode = hexStringToByteArray(interface3_bytecodeInStr);
fos.write(interface3_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "interface4.class")) {
byte[] interface4_bytecode = hexStringToByteArray(interface4_bytecodeInStr);
fos.write(interface4_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "InvalidInterface.class")) {
byte[] InvalidInterface_bytecode = hexStringToByteArray(InvalidInterface_bytecodeInStr);
fos.write(InvalidInterface_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "ValidInterface.class")) {
byte[] ValidInterface_bytecode = hexStringToByteArray(ValidInterface_bytecodeInStr);
fos.write(ValidInterface_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(baseDir + "/" + "TestLauncher.class")) {
byte[] TestLauncher_bytecode = hexStringToByteArray(TestLauncher_bytecodeInStr);
fos.write(TestLauncher_bytecode);
} catch (IOException e) {
e.printStackTrace();
}
}
public static byte[] hexStringToByteArray(String hexString) {
int length = hexString.length();
byte[] byteArray = new byte[length / 2];
for (int i = 0; i < length; i += 2) {
int byteValue = Integer.parseInt(hexString.substring(i, i + 2), 16);
byteArray[i / 2] = (byte) byteValue;
}
return byteArray;
}
}
```
Note: modify the paths according to your needs.
After obtaining the test cases, you can derive the following test cases through decompilation:
```java
public interface BoundaryInterface extends Interface1, Interface3 {
}
```
```java
public interface Interface1 {
void method1();
}
```
```java
public interface Interface2 {
void method2();
}
```
```java
public interface Interface3 {
void method1();
}
```
```java
public interface Interface4 {
void method1(int var1);
}
```
```java
public interface InvalidInterface extends Interface1, Interface4 {
}
```
```java
public class TestLauncher {
public static void main(String[] var0) {
new Class("ValidInterface");
System.out.println("ValidInterface loaded successfully.");
new Class("BoundaryInterface");
System.out.println("BoundaryInterface loaded successfully.");
new Class("InvalidInterface");
System.out.println("InvalidInterface load fail: Inconsistent method descriptor for method1");
}
}
```
```java
public interface ValidInterface extends Interface1, Interface2 {
}
```
---------- END SOURCE ----------
- relates to
-
JDK-4328479 newInstance should throw IllegalAccessException when constructor is inaccessible
-
- Closed
-