Remove the fallback that reads type-use annotations from bytecode type attributes

Open
#2,042 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
backend, devtools

Research direction

Start by reading the fallback methods and their callers named in NullabilityUtil, then review the JDK compatibility checks added in #1317 and #1794. Determine how standard mode should enforce the required javac support and flag, including whether to warn before requiring it. Done means the fallback is removed and standard-mode users receive the agreed compatibility behavior.

Written by the indexing model from the issue text.

Description

Split out from #1170, item 2.

When a class comes from bytecode, javac without the JDK-8346471 fix does not put type-use annotations on the Symbol, so NullAway reads them from the symbol's raw type attributes instead: NullabilityUtil.hasAnyAnnotationMatchingBackCompat, getAllAnnotationsForParameter, and getTypeUseAnnotations, plus their callers. The fix ships in JDK 17.0.19+ and 21.0.8+ behind -XDaddTypeAnnotationsToSymbol=true, and JDK 22 and later have it without the flag.

JSpecify mode already requires it: since #1317 (0.12.11) NullAway fails in JSpecify mode when javac lacks the fix or the flag is missing, and #1794 (0.14.2) detects whether a JDK 17 or 21 javac supports the flag. Standard mode has no such check and runs without the flag, so it still depends on the fallback.

Deleting the fallback means extending that requirement to standard mode: JDK 22+, or JDK 17.0.19+ / 21.0.8+ with -XDaddTypeAnnotationsToSymbol=true. Standard-mode users who do not pass the flag today would break, so this needs a decision on when to require it, for example a release that warns first.

Dominant language
Java
Stars
4.1k
Forks
381
Avg merge
1d 2h
Merged PRs (30d)
106

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from uber/NullAway

All issues in uber/NullAway

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.