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

Compiler crash while generating local variable debug information for inferred type

XMLWordPrintable

    • x86_64
    • generic

      FULL PRODUCT VERSION :
      java version "10" 2018-03-20
      Java(TM) SE Runtime Environment 18.3 (build 10+46)
      Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      The javac compiler crashes when generating local variable debug information for certain inferred types

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to compile the source code provided below with "javac -g" or "javac -g:vars" (both causing generation of debug info for local variables).


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Javac compiler terminates normally
      ACTUAL -
      Javac compiler crashes

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An exception has occurred in the compiler (10). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.AssertionError: Unexpected intersection type: java.lang.Throwable&java.lang.Cloneable
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.enterInner(ClassWriter.java:1043)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.classReference(ClassWriter.java:312)
      at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleClassSig(Types.java:5182)
      at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5114)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.assembleSig(ClassWriter.java:291)
      at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5120)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.assembleSig(ClassWriter.java:291)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.typeSig(ClassWriter.java:334)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeCode(ClassWriter.java:1271)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeMethod(ClassWriter.java:1158)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeMethods(ClassWriter.java:1653)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1761)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1679)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:749)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1627)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1595)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:965)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:306)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:165)
      at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
      at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // Compile the code below with "javac -g BadClass.java":

      // File: BadClass.java
      public class BadClass {

          static void badMethod() {
              var foo = getFoo();
              var foos = wrapIntoArray(foo);
          }

          static <T extends Throwable & Cloneable> T getFoo() {
              return null;
          }

          @SafeVarargs
          static <T> T[] wrapIntoArray(T... array) {
              return array;
          }
      }
      ---------- END SOURCE ----------

            mcimadamore Maurizio Cimadamore
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: