JDK-8307444 : java.lang.AssertionError when using unnamed patterns
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-05-04
  • Updated: 2023-05-29
  • Resolved: 2023-05-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21
21 b24Fixed
Related Reports
Relates :  
Description
package test;

public class Test  {
    static abstract class Entree {}

    static class Steak extends Entree  {}
    private static <T> int consume(T t) {
        int success = -1;
        switch(t) {
            case Steak _, Entree _, Object _ : {
                success = 1; break;
            }
        }
        return success;
    }
    public static void main(String argv[]) {
        System.out.println(consume(new Steak()));
    }
}

An exception has occurred in the compiler (21-internal). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.

java.lang.AssertionError
       at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
       at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.handleSwitch(Gen.java:1341)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSwitch(Gen.java:1224)
       at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:1295)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:614)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:649)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:635)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:686)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.doVisitBlock(Gen.java:1128)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1121)
       at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1088)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:614)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:649)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:635)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:686)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.doVisitBlock(Gen.java:1128)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1121)
       at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1088)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:614)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:649)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:975)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:938)
       at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:912)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:614)
       at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2472)
       at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:755)
       at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1680)
       at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1648)
       at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:964)
       at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
       at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
       at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
       at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
       at jdk.compiler/com.sun.tools.javac.launcher.Main.compile(Main.java:399)
       at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:202)
       at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)

error: compilation failed
Comments
Changeset: 8aa50288 Author: Aggelos Biboudis <abimpoudis@openjdk.org> Committer: Jan Lahoda <jlahoda@openjdk.org> Date: 2023-05-22 08:52:36 +0000 URL: https://git.openjdk.org/jdk/commit/8aa50288a1a6a853bf4d8d97b1849d5744ed7a32
22-05-2023

Fixed in PR for https://bugs.openjdk.org/browse/JDK-8304246
08-05-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/13528 Date: 2023-04-19 09:47:39 +0000
08-05-2023