RFR: 8322706: AnnotationTypeMismatchException in javac with annotation processing

Jan Lahoda jlahoda at openjdk.org
Tue Apr 15 15:16:41 UTC 2025


Annotations are processed in a sequence of queues. But, it may happen this:
- while running verification in `validateQ`, an annotation type is completed (when a default attribute value is an annotation, whose type has not been completed yet)
- if this annotation type has attributes with default values, there will be temporary proxies created for the default values, and conversion of these default values to real values will be scheduled into `q`. `Annotate.flush()` will be called, but because flush is already running it will be ignored.
- until there are more unrelated calls to `Annotate.flush()`, the temporary proxies will linger. If someone will try to use the default values for the attributes, they will get the proxies instead of the real values, leading to trouble.

The proposal herein is to clear the queues in rounds as long as there are entries in the queues. An alternative might be to use a `PriorityQueue`, although that brings some complexity.

-------------

Commit messages:
 - 8322706: AnnotationTypeMismatchException in javac with annotation processing

Changes: https://git.openjdk.org/jdk/pull/24666/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24666&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8322706
  Stats: 168 lines in 2 files changed: 157 ins; 0 del; 11 mod
  Patch: https://git.openjdk.org/jdk/pull/24666.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24666/head:pull/24666

PR: https://git.openjdk.org/jdk/pull/24666


More information about the compiler-dev mailing list