Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8327683

Crash with primitive type pattern and generic expression in instanceof

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • 23
    • tools
    • b16

      Consider this code:

       private static <T extends Byte> byte test(T test) {
          if (test instanceof byte i) { return i; }
          return 2;
      }

      public static void main(String argv[]) {
          System.out.println(test(Byte.MAX_VALUE));
      }

       An exception has occurred in the compiler (23-ea). 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: T.byteValue
             at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:162)
             at jdk.compiler/com.sun.tools.javac.code.Symbol$MethodSymbol.<init>(Symbol.java:1974)
             at jdk.compiler/com.sun.tools.javac.code.Symbol$MethodSymbol$1.<init>(Symbol.java:1980)
             at jdk.compiler/com.sun.tools.javac.code.Symbol$MethodSymbol.clone(Symbol.java:1980)
             at jdk.compiler/com.sun.tools.javac.code.Symbol$MethodSymbol.clone(Symbol.java:1950)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.binaryQualifier(Gen.java:264)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSelect(Gen.java:2377)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2582)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:859)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1910)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1816)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:859)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitTypeCast(Gen.java:2269)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:2204)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:859)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitAssign(Gen.java:2064)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCAssign.accept(JCTree.java:2060)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:859)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1783)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1603)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:588)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:623)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:609)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:660)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:753)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:674)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBinary(Gen.java:2194)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:2175)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:859)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:761)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:674)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitIf(Gen.java:1751)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1572)
             ...

            abimpoudis Angelos Bimpoudis
            abimpoudis Angelos Bimpoudis
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: