Skip to content

Prototype implementation of javac plugin to serialize nullness annotations#1225

Merged
msridhar merged 26 commits intomasterfrom
jdk-javac-plugin
Jul 8, 2025
Merged

Prototype implementation of javac plugin to serialize nullness annotations#1225
msridhar merged 26 commits intomasterfrom
jdk-javac-plugin

Conversation

@msridhar
Copy link
Copy Markdown
Collaborator

@msridhar msridhar commented Jun 26, 2025

This is a new approach to serializing the annotations from https://github.com/jspecify/jdk for use with NullAway. The idea is we build that JDK with this plugin, which will dump out all the discovered annotation info into JSON files. Then, we write some code to take all those JSON files and convert them to astubx for NullAway. I went with JSON instead of directly serializing astubx to iterate more quickly. I have tested with jspecify/jdk and confirmed I can inject this plugin into the build and the output JSON files get created. I haven't started on the code to convert the JSON to astubx yet.

Of course there is much left to do, but I wanted to get this initial implementation up for review rather than dropping a huge PR at the end (and also to enable others to help out). We previously thought about getting out the JDK annotations by parsing the source files (and wrote some code to do so), but I think this approach will be more robust, as in the javac plugin we don't need worry about parsing of recent language features and all symbols are just resolved.

Related to #950 (which probably needs to be updated if we go forward with this approach)

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 96.20253% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.44%. Comparing base (20dd152) to head (359bd3d).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...away/javacplugin/NullnessAnnotationSerializer.java 96.20% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1225      +/-   ##
============================================
+ Coverage     88.36%   88.44%   +0.07%     
- Complexity     2366     2369       +3     
============================================
  Files            89       90       +1     
  Lines          7693     7772      +79     
  Branches       1540     1552      +12     
============================================
+ Hits           6798     6874      +76     
- Misses          450      452       +2     
- Partials        445      446       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msridhar
Copy link
Copy Markdown
Collaborator Author

@cpovirk would be interested to get your thoughts on this approach

@msridhar msridhar marked this pull request as ready for review June 26, 2025 03:20
@msridhar msridhar requested review from akshayutture and yuxincs June 26, 2025 03:20
@cpovirk
Copy link
Copy Markdown

cpovirk commented Jun 26, 2025

That all sounds reasonable to me. I don't want to obligate @cushon or @eamonnmcmanus to get deep into this, but if either of them wants to run screaming into the chapel to object, now would be the time :)

Copy link
Copy Markdown
Collaborator

@yuxincs yuxincs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome!

@msridhar msridhar merged commit 10d4fee into master Jul 8, 2025
12 checks passed
@msridhar msridhar deleted the jdk-javac-plugin branch July 8, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants