Add JSpecify annotations to 10 language package classes#4218
Conversation
Co-authored-by: dondonz <[email protected]>
Co-authored-by: dondonz <[email protected]>
Co-authored-by: dondonz <[email protected]>
# Conflicts: # .claude/commands/jspecify-annotate.md
Test Results 335 files ±0 335 suites ±0 5m 5s ⏱️ ±0s Results for commit 72ea92a. ± Comparison against base commit 89b4446. This pull request removes 204 and adds 180 tests. Note that renamed tests count towards both.This pull request skips 1 test.♻️ This comment has been updated with latest results. |
| Note that JSpecify is already used in this repository so it's already imported. | ||
|
|
||
| If you see a builder static class, you can label it `@NullUnmarked` and not need to do anymore for this static class in terms of annotations. | ||
| **IMPORTANT: Builder classes MUST be annotated with `@NullUnmarked`.** When you encounter a `public static final class Builder` or `public static class Builder` inside a `@NullMarked` class, you MUST: |
There was a problem hiding this comment.
A number of builder annotations were missed, so I've updated the prompt
Interesting there is a difference between "you can" and "you must" for LLMs
|
Item for discussion - this now enforces a selection set on fragment definition (as per spec), and now requires fields to have a name |
Resolve JSpecifyAnnotationsCheck conflict by taking master's exemption list updates. Accept master's deletion of FragmentsOnCompositeTypeTest from rules/ (moved to validation/). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
NodeVisitor, NodeVisitorStub, SourceLocation, and Type are already annotated with @NullMarked so they should not be in the exemption list. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Test ReportTest Results
Code Coverage (Java 25)
|
The assertNotNull guards added for JSpecify annotations introduce unreachable throw paths that aren't covered by tests. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
andimarek
left a comment
There was a problem hiding this comment.
We need to fix the formatting changes first ... to many wrong and not needed line breaks etc
| @Internal | ||
| protected Document(List<Definition> definitions, SourceLocation sourceLocation, List<Comment> comments, IgnoredChars ignoredChars, Map<String, String> additionalData) { | ||
| protected Document(List<Definition> definitions, @Nullable SourceLocation sourceLocation, List<Comment> comments, | ||
| IgnoredChars ignoredChars, Map<String, String> additionalData) { |
There was a problem hiding this comment.
there are multiple examples with this wrong formatting ... lets fix that before merging.
| /** | ||
| * Returns a list of definitions of the specific type. It uses {@link java.lang.Class#isAssignableFrom(Class)} for the test | ||
| * Returns a list of definitions of the specific type. It uses | ||
| * {@link java.lang.Class#isAssignableFrom(Class)} for the test |
There was a problem hiding this comment.
this is not needed change I think ... more examples below
…y-annotations-again # Conflicts: # src/test/groovy/graphql/archunit/JSpecifyAnnotationsCheck.groovy
Keep only the real JSpecify annotation changes (@NullMarked, @NullUnmarked, @nullable, assertNotNull wrapping). Revert indentation, line wrapping, blank line, and javadoc reflow changes to match master's formatting. Also remove duplicate SelectionSet import in DataFetchingEnvironmentImplTest.
Annotates 10 classes in
graphql.languagepackage with JSpecify nullability annotations and removes them from the exemption list.Annotated Classes
Approach
Field nullability: Core fields (name, type, typeCondition) are marked
@Nullableto allow test code to create incomplete instances for validation testing.Getter enforcement: Getters use
assertNotNull()to satisfy NamedNode contract and fail fast:Builder leniency: Builders accept nullable values without validation, supporting existing test patterns that create invalid AST nodes.
List copying: deepCopy() methods use
assertNotNull()on list results since AbstractNode'sdeepCopy(List)returns@Nullable List.Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.