Commit 825dadd
authored
feat(gapic-generator): Add NullMarked annotation to generated classes (#13517)
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](http://goto.google.com/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:
- Please refer to this doc:
https://docs.google.com/document/d/1h126pbTGqSwtJyl35E2_vQjM9gNtmWETYCM7PObcvmQ/edit?tab=t.0#heading=h.s4q06jxocx8b
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 annotations1 parent 591cae0 commit 825dadd
289 files changed
Lines changed: 596 additions & 6 deletions
File tree
- java-showcase
- gapic-showcase/src/main/java/com/google/showcase/v1beta1
- stub
- proto-gapic-showcase-v1beta1/src/main/java/com/google/showcase/v1beta1
- rules_java_gapic
- sdk-platform-java
- gapic-generator-java
- src
- main/java/com/google/api/generator/gapic/composer
- common
- resourcename
- test/java/com/google/api/generator
- engine/writer/goldens
- gapic/composer
- grpcrest/goldens
- grpc/goldens
- resourcename/goldens
- rest/goldens
- gax-java
- hermetic_build/library_generation/owlbot/templates/poms
- test/integration/goldens
- apigeeconnect/src/com/google/cloud/apigeeconnect/v1
- stub
- asset/src/com/google/cloud/asset/v1
- stub
- bigtable/src/com/google
- bigtable/v2
- cloud/bigtable/data/v2
- stub
- compute/src/com/google/cloud/compute/v1small
- stub
- credentials/src/com/google/cloud/iam/credentials/v1
- stub
- iam/src/com/google/iam/v1
- stub
- kms/src/com/google/cloud/kms/v1
- stub
- library/src/com/google
- cloud/example/library/v1
- stub
- example/library/v1
- logging/src/com/google
- cloud/logging/v2
- stub
- logging/v2
- pubsub/src/com/google
- cloud/pubsub/v1
- stub
- pubsub/v1
- redis/src/com/google/cloud/redis/v1beta1
- stub
- storage/src/com/google/storage/v2
- stub
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
355 | 356 | | |
356 | 357 | | |
357 | 358 | | |
| 359 | + | |
358 | 360 | | |
359 | 361 | | |
360 | 362 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
364 | 365 | | |
365 | 366 | | |
366 | 367 | | |
| 368 | + | |
367 | 369 | | |
368 | 370 | | |
369 | 371 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
| 290 | + | |
289 | 291 | | |
290 | 292 | | |
291 | 293 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
449 | 450 | | |
450 | 451 | | |
451 | 452 | | |
| 453 | + | |
452 | 454 | | |
453 | 455 | | |
454 | 456 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| 129 | + | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
309 | 310 | | |
310 | 311 | | |
311 | 312 | | |
| 313 | + | |
312 | 314 | | |
313 | 315 | | |
314 | 316 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| |||
0 commit comments