JDK-8334757 : AssertionError: Missing type variable in where clause
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-06-22
  • Updated: 2024-07-15
  • Resolved: 2024-07-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23 JDK 24
23Fixed 24 b06Fixed
Related Reports
Relates :  
Relates :  
Description
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)

Comments
A pull request was submitted for review. Branch: jdk23 URL: https://git.openjdk.org/jdk/pull/20085 Date: 2024-07-08 20:16:42 +0000
09-07-2024

Changeset: babf6df7 Author: Liam Miller-Cushon <cushon@openjdk.org> Date: 2024-07-08 20:09:07 +0000 URL: https://git.openjdk.org/jdk/commit/babf6df7d97e4beedb25e689634d999412c1e950
08-07-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/19840 Date: 2024-06-22 01:10:01 +0000
22-06-2024