feat(gapic-generator): add JSpecify Null annotations to the generator classes#13769
Conversation
…leapis/google-cloud-java into feat/jspecify-generator-annotations
…leapis/google-cloud-java into feat/jspecify-generator-annotations
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces JSpecify nullness annotations (@NullMarked and @Nullable) across the codebase to improve null-safety and static analysis. The review feedback highlights a potential nullness analysis error in Writer.java, where the gapicPackageInfo parameter of the write method should be explicitly annotated with @Nullable because it can receive null values from Composer.composePackageInfo.
|
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request integrates JSpecify nullness annotations (@NullMarked and @nullable) across numerous classes in the gapic-generator-java project to enhance static analysis and null safety. The review feedback highlights three critical nullness issues introduced by these changes: a potential NullPointerException in CodeGeneratorRequestFileToGapicMain.java due to a missing null check on a @nullable response, a static analysis warning in Main.java where a null check is performed using a constant instead of a direct null comparison, and a nullness mismatch in Trie.java where a @nullable field is passed to a non-null-marked function parameter.
… classes (googleapis#13769) This PR continues the onboarding of the gapic-generator-java project to JSpecify null-safety. Specifically, it applies the @NullMarked annotation to all modified source and test classes in this branch to declare them non-null by default. **Annotations Applied** - @NullMarked Class Declarations: Applied at the class level to all modified source and test classes to establish a non-null by default context. - @nullable Type Annotations: Applied to specific methods, fields, and parameters to explicitly denote where null values are accepted/returned. **Automation Method** To apply the class-level annotations efficiently, we leveraged Chris's Error Prone automation tool (custom BugChecker plugin under com.google.errorprone.bugpatterns.nullness) to run AST-based refactoring and automatically insert the JSpecify @NullMarked annotations across the codebase. Verification/Testing - Please refer to this doc: https://docs.google.com/document/d/18c7NzbTpREqqb_qvLUZ1bCaMYGQQnczyo6vrVPmx60Q/edit?resourcekey=0-EOZQxK66NvVhJPF1jg-LQA&tab=t.0
… classes (googleapis#13769) This PR continues the onboarding of the gapic-generator-java project to JSpecify null-safety. Specifically, it applies the @NullMarked annotation to all modified source and test classes in this branch to declare them non-null by default. **Annotations Applied** - @NullMarked Class Declarations: Applied at the class level to all modified source and test classes to establish a non-null by default context. - @nullable Type Annotations: Applied to specific methods, fields, and parameters to explicitly denote where null values are accepted/returned. **Automation Method** To apply the class-level annotations efficiently, we leveraged Chris's Error Prone automation tool (custom BugChecker plugin under com.google.errorprone.bugpatterns.nullness) to run AST-based refactoring and automatically insert the JSpecify @NullMarked annotations across the codebase. Verification/Testing - Please refer to this doc: https://docs.google.com/document/d/18c7NzbTpREqqb_qvLUZ1bCaMYGQQnczyo6vrVPmx60Q/edit?resourcekey=0-EOZQxK66NvVhJPF1jg-LQA&tab=t.0





This PR continues the onboarding of the gapic-generator-java project to JSpecify null-safety. Specifically, it applies the @NullMarked annotation to all modified source and test classes in this branch to declare them non-null by default.
Annotations Applied
Automation Method
To apply the class-level annotations efficiently, we leveraged Chris's Error Prone automation tool (custom BugChecker plugin under com.google.errorprone.bugpatterns.nullness) to run AST-based refactoring and automatically insert the JSpecify @NullMarked annotations across the codebase.
Verification/Testing