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

AssertionError on intersection types in throws clause with all debugging info

XMLWordPrintable

    • x86_64
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Manjaro, OpenJDK from repositories

      openjdk version "1.8.0_172"
      OpenJDK Runtime Environment (build 1.8.0_172-b11)
      OpenJDK 64-Bit Server VM (build 25.172-b11, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      AssertionError on intersection types in throws clause with all debugging info (-g flag of javac) when compiling the provided code.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the class with `javac -g Exceptions.java`

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The code compiling
      ACTUAL -
      An exception has occurred in the compiler (10.0.1). 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.Exception&Exceptions.Example<? extends java.lang.Number&java.lang.Comparable<? extends java.lang.Number&java.lang.Comparable<?>>>
              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:5225)
              at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleClassSig(Types.java:5201)
              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.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)

      ---------- BEGIN SOURCE ----------
      import java.util.List;

      public class Exceptions {
          public static void main(String[] args) {
              var exceptions = List.of(new Exceptionable(), new VeryExceptionable());
              try {
                  raiseException(exceptions.get(0));
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }

          private static <E extends Exception & Example<?>> void raiseException(E exceptionable) throws E {
              throw exceptionable;
          }

          private interface Example<T> {
          }

          private static class Exceptionable extends Exception implements Example<Integer> {
          }

          private static class VeryExceptionable extends Exception implements Example<Long> {
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Don't write stupid code :)

      FREQUENCY : always


            fmatte Fairoz Matte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: