feat(gapic-generator): Add Nullable annotation to generated classes#13558
feat(gapic-generator): Add Nullable annotation to generated classes#13558nnicolee wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces @Nullable annotations to various generated classes and generator code in the Java GAPIC generator. Specifically, it updates the composer classes to annotate settings fields, getter methods, non-required resource name helper arguments, parse methods, toStringList generic types, and equals method arguments, with corresponding updates to the golden files. A review comment highlights a fragile workaround in ResourceNameHelperClassComposer.java where the @Nullable annotation is hacked into the VaporReference name string, warning that this could lead to issues with type comparisons, fully qualified names, AST manipulation, and missing imports, and suggests extending the AST classes to properly support type-use annotations.
| .setGenerics( | ||
| Arrays.asList( | ||
| VaporReference.builder() | ||
| .setName("@Nullable " + thisClassType.reference().name()) | ||
| .setPakkage(thisClassType.reference().pakkage()) | ||
| .build())) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|



This PR updates the gapic-generator-java to add the JSpecify @nullable annotation to all generated class declarations. This is the second phase in onboarding the generated client libraries to compile-time safety validation, see design doc for more details: go/sdk:java-jspecify-null-annotations-gapic
Classes Annotated:
Implementation Changes:
Verification/Testing: