Skip to content

Add NullAway static null-safety checker via Error Prone#9

Merged
Garciat merged 4 commits into
mainfrom
copilot/add-nullaway-support
Dec 14, 2025
Merged

Add NullAway static null-safety checker via Error Prone#9
Garciat merged 4 commits into
mainfrom
copilot/add-nullaway-support

Conversation

Copilot AI commented Dec 14, 2025

Copy link
Copy Markdown
Contributor
  • Understand NullAway and Error Prone integration requirements
  • Add Error Prone plugin to Maven compiler configuration
  • Add NullAway dependency with version check
  • Configure Error Prone with NullAway checker
  • Test build with NullAway enabled
  • Fix any nullability issues found by NullAway
  • Run code review and security checks
  • Final verification
  • Address feedback: Replace Void with Unit type in PrintAll
  • Address feedback: Replace Void with Unit type in FwdList#forEach
Original prompt

This section details on the original issue you should resolve

<issue_title>Add NullAway support</issue_title>
<issue_description>Add NullAway as a static checker via Error Prone.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Added Error Prone 2.45.0 as compiler plugin
- Added NullAway 0.12.14 for null-safety checking
- Added JSpecify 1.0.0 for nullability annotations
- Configured Error Prone with Java 21 compatibility flags
- Fixed nullability issues in PrintAll.java
- Added @SuppressWarnings for test helper classes
- All tests passing

Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>
Comment thread src/main/java/com/garciat/typeclasses/classes/PrintAll.java Outdated
Comment thread pom.xml
Copilot AI changed the title [WIP] Add NullAway support via Error Prone Add NullAway static null-safety checker via Error Prone Dec 14, 2025
Copilot AI requested a review from Garciat December 14, 2025 11:42
@Garciat Garciat marked this pull request as ready for review December 14, 2025 11:42
- Created new Unit record type in types package
- Updated PrintAll to use Unit instead of Void with @nullable
- Removed @SuppressWarnings annotation as it's no longer needed
- Updated test to use Unit type
- All tests passing

Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>
@Garciat

Garciat commented Dec 14, 2025

Copy link
Copy Markdown
Owner

@copilot how come the check didn't trigger for FwdList#forEach? It uses null.

Copilot AI commented Dec 14, 2025

Copy link
Copy Markdown
Contributor Author

@copilot how come the check didn't trigger for FwdList#forEach? It uses null.

NullAway didn't trigger for FwdList#forEach because:

  1. The method's declared return type is void (not Void), so NullAway doesn't check the return value
  2. The null values on lines 51 and 55 are only used internally to satisfy the generic match method's type signature <Void>match(...)
  3. Since the method signature promises void, the internal use of Void as a type parameter for coordination is not checked by NullAway

This is actually a good candidate for using Unit instead - it would make the code cleaner without using null at all. Would you like me to update FwdList#forEach to use Unit as well?

@Garciat

Garciat commented Dec 14, 2025

Copy link
Copy Markdown
Owner

@copilot yes let's use Unit there as well.

- Updated FwdList#forEach to use Unit instead of Void
- Replaced null returns with unit() calls
- Added static import for Unit.unit()
- Eliminates all null usage from FwdList#forEach
- All tests passing

Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>

Copilot AI commented Dec 14, 2025

Copy link
Copy Markdown
Contributor Author

@copilot yes let's use Unit there as well.

Done in commit 6eafa1f. Updated FwdList#forEach to use Unit instead of Void, eliminating all null usage.

@Garciat Garciat merged commit 5f90220 into main Dec 14, 2025
1 check passed
Copilot AI requested a review from Garciat December 14, 2025 12:14
@Garciat Garciat deleted the copilot/add-nullaway-support branch December 14, 2025 12:33
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.

Add NullAway support

2 participants