javac NullPointerException record.type
Jan Lahoda
jan.lahoda at oracle.com
Wed May 29 10:48:44 UTC 2024
Hello Tors,
Thanks for the report. Christian filled:
https://bugs.openjdk.org/browse/JDK-8333169
Thanks,
Jan
On 28. 05. 24 12:38, tors wrote:
> Hi,
> I found a javac error, but the Java bug reporting page didn't allow me
> to submit the bug. Posting the reproducer here.
> Tried on Linux and Windows.
>
> jdk-22.0.1/bin/javac Main.java
> ...
> java.lang.NullPointerException: Cannot invoke
> "com.sun.tools.javac.code.Type.isErroneous()" because "record.type" is
> null
> at jdk.compiler/com.sun.tools.javac.comp.Flow.makePatternDescription(Flow.java:3471)
> ...
>
>
> class Main {
>
> record A() {};
>
> public static void main(String[] args) {
> A a1 = new A();
> A a2 = new A();
>
> ///
> String causesCompilationError = log(
> switch(a1) {
> case A() -> switch(a2) {
> case A() -> "A";
> };
> }
> );
> ///
>
> String worksNonPattern = log(
> switch(a1) {
> case A _ -> switch(a2) {
> case A _ -> "A";
> };
> }
> );
>
> String worksNonNested = log(
> switch(a1) {
> case A() -> "A";
> }
> );
> }
>
> static <T> T log(T t) {
> System.out.println("LOG: " + t);
> return t;
> }
> }
>
>
> ---
> BR,
> tors
More information about the compiler-dev
mailing list