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

AssertionError: Missing type variable in where clause

XMLWordPrintable

    • b06

        JDK-8291643 changed diagnostics to print types without type annotations, unless they opt-in to including the type annotations. To do that, it introduced a trivial wrapper around the annotated type, JCDiagnostic.AnnotatedType, to avoid the stripping.

        That wrapper bypasses logic in RichDiagnosticFormatter that preprocesses arguments, including types. The missing preprocessing for types wrapped in JCDiagnostic.AnnotatedType causes crashes when the types are printed:

        import java.lang.annotation.ElementType;
        import java.lang.annotation.Target;

        public class T {
          @Target(ElementType.TYPE_USE)
          @interface TA {}

          static class A {
            static class B<T> {}
          }

          <T> @TA A.B<T> f() {}
        }

        $ javac T.java
        java.lang.AssertionError: Missing type variable in where clause: T
                at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter.unique(RichDiagnosticFormatter.java:249)
                at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitTypeVar(RichDiagnosticFormatter.java:400)
                at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitTypeVar(RichDiagnosticFormatter.java:342)
                at jdk.compiler/com.sun.tools.javac.code.Type$TypeVar.accept(Type.java:1709)

              cushon Liam Miller-Cushon
              cushon Liam Miller-Cushon
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: