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

Crash with a different types patterns (primitive vs generic) in instanceof

    XMLWordPrintable

Details

    • b23

    Description

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

      public static void main(String argv[]) {
          Integer value = 0x1000000;
          System.out.println(test(value));
      }
       
      java --version
      java 23-ea 2024-09-17
      Java(TM) SE Runtime Environment (build 23-ea+18-1469)
      Java HotSpot(TM) 64-Bit Server VM (build 23-ea+18-1469, mixed mode, sharing)
       
      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.intValue
             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.genArgs(Gen.java:884)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1915)
             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.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.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.visitLetExpr(Gen.java:2422)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$LetExpr.accept(JCTree.java:3419)
             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.visitBinary(Gen.java:2190)
             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)
             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.doVisitBlock(Gen.java:1102)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1095)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1092)
             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.doVisitBlock(Gen.java:1102)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1095)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1092)
             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.genMethod(Gen.java:949)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:912)
             at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:916)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:588)
             at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2461)
             at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:770)
             at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1709)
             at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1677)
             at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:977)
             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.MemoryContext.compileProgram(MemoryContext.java:125)
             at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.run(SourceLauncher.java:150)
             at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.main(SourceLauncher.java:78)
       
      This code compiles and executes when the generic type is the wrapper for the primitive type but fails with an exception otherwise

      Attachments

        Issue Links

          Activity

            People

              abimpoudis Angelos Bimpoudis
              eananeva Ella Ananeva
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: