The code in:
test/langtools/tools/javac/jvm/ClassRefDupInConstantPoolTest.java
attempts to read class-file bytes from the compiled test JAR via:
----
ClassModel cls = ClassFile.of().parse(
ClassRefDupInConstantPoolTest.class
.getResourceAsStream("ClassRefDupInConstantPoolTest$Duplicates.class")
.readAllBytes());
----
where the `Duplicates` class is just defined as code in the test file:
----
class Duplicates {
String concat(String s1, String s2) {
return s1 + (s2 == s1 ? " " : s2);
}
}
----
This works when run from "make test", but fails when run from IntelliJ via the JTreg plugin with:
----
java.lang.NullPointerException: Cannot invoke "java.io.InputStream.readAllBytes()" because the return value of "java.lang.Class.getResourceAsStream(String)" is null
at ClassRefDupInConstantPoolTest.main(ClassRefDupInConstantPoolTest.java:40)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
at java.base/java.lang.Thread.run(Thread.java:1474)
JavaTest Message: Test threw exception: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.readAllBytes()" because the return value of "java.lang.Class.getResourceAsStream(String)" is null
JavaTest Message: shutting down test
STATUS:Failed.`main' threw exception: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.readAllBytes()" because the return value of "java.lang.Class.getResourceAsStream(String)" is null
----
This test might be a symptom of a pattern which generally won't work in IntelliJ, but it can be easily changed to use the toolbox to compile on-the-fly.
test/langtools/tools/javac/jvm/ClassRefDupInConstantPoolTest.java
attempts to read class-file bytes from the compiled test JAR via:
----
ClassModel cls = ClassFile.of().parse(
ClassRefDupInConstantPoolTest.class
.getResourceAsStream("ClassRefDupInConstantPoolTest$Duplicates.class")
.readAllBytes());
----
where the `Duplicates` class is just defined as code in the test file:
----
class Duplicates {
String concat(String s1, String s2) {
return s1 + (s2 == s1 ? " " : s2);
}
}
----
This works when run from "make test", but fails when run from IntelliJ via the JTreg plugin with:
----
java.lang.NullPointerException: Cannot invoke "java.io.InputStream.readAllBytes()" because the return value of "java.lang.Class.getResourceAsStream(String)" is null
at ClassRefDupInConstantPoolTest.main(ClassRefDupInConstantPoolTest.java:40)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
at java.base/java.lang.Thread.run(Thread.java:1474)
JavaTest Message: Test threw exception: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.readAllBytes()" because the return value of "java.lang.Class.getResourceAsStream(String)" is null
JavaTest Message: shutting down test
STATUS:Failed.`main' threw exception: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.readAllBytes()" because the return value of "java.lang.Class.getResourceAsStream(String)" is null
----
This test might be a symptom of a pattern which generally won't work in IntelliJ, but it can be easily changed to use the toolbox to compile on-the-fly.