Skip to content

feat(gapic-generator): Add NullMarked annotation to generated classes#13517

Merged
nnicolee merged 6 commits into
mainfrom
feat/jspecify-nullmarked
Jun 25, 2026
Merged

feat(gapic-generator): Add NullMarked annotation to generated classes#13517
nnicolee merged 6 commits into
mainfrom
feat/jspecify-nullmarked

Conversation

@nnicolee

@nnicolee nnicolee commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This PR updates the gapic-generator-java to add the JSpecify @NullMarked annotation to all generated class declarations. Adding @NullMarked at the class level defines the class scope as null-safe, establishing that all unannotated types in method signatures (parameters and return types) are nonnull able by default. This is the first 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:

  • Client Classes: AbstractServiceClientClassComposer
  • Settings Classes: AbstractServiceSettingsClassComposer and AbstractServiceStubSettingsClassComposer
  • Stub Classes: AbstractServiceStubClassComposer and AbstractTransportServiceStubClassComposer
  • Callable Factories: AbstractServiceCallableFactoryClassComposer
  • Resource Names: ResourceNameHelperClassComposer, CommonStrings

Implementation Changes:

  • Added JSpecify import statements to class-level generation templates
  • Registered NullMarked.class and Nullable.class in TypeStore across all class composers to ensure references compile and resolve properly

Verification/Testing:

Revisions:

  • Mainly to fix the autogenerator, not related to logic: added goldens + dependencies for the build

Next Steps:

  • In the next PR, will add @nullable annotations

@nnicolee nnicolee self-assigned this Jun 18, 2026
@nnicolee nnicolee added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 18, 2026
@nnicolee nnicolee requested a review from lqiu96 June 18, 2026 18:25
gemini-code-assist[bot]

This comment was marked as resolved.

@nnicolee nnicolee force-pushed the feat/jspecify-nullmarked branch from ef5eb49 to dae9b95 Compare June 18, 2026 19:51
@nnicolee nnicolee force-pushed the feat/jspecify-nullmarked branch from dae9b95 to b1aab81 Compare June 18, 2026 20:59
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
6.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@sonarqubecloud

Copy link
Copy Markdown

@nnicolee nnicolee added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 24, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 24, 2026
@nnicolee nnicolee removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 24, 2026
@nnicolee nnicolee marked this pull request as ready for review June 24, 2026 17:10
@nnicolee nnicolee requested review from a team as code owners June 24, 2026 17:10
@lqiu96 lqiu96 changed the title feat: add NullMarked annotation to classes feat(gapic-generator): Add NullMarked annotation to generated classes Jun 24, 2026
@nnicolee nnicolee merged commit 825dadd into main Jun 25, 2026
292 of 298 checks passed
@nnicolee nnicolee deleted the feat/jspecify-nullmarked branch June 25, 2026 04:51
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.

4 participants