[not for review yet] deps: changing jsr305 to jspecify by suztomo · Pull Request #3191 · googleapis/sdk-platform-java · GitHub
Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.

[not for review yet] deps: changing jsr305 to jspecify#3191

Draft
suztomo wants to merge 13 commits into
mainfrom
jspecify_annotations
Draft

[not for review yet] deps: changing jsr305 to jspecify#3191
suztomo wants to merge 13 commits into
mainfrom
jspecify_annotations

Conversation

@suztomo

@suztomo suztomo commented Sep 11, 2024

Copy link
Copy Markdown
Member

Preparation for b/341380807. Following https://jspecify.dev/docs/using/#if-your-code-already-uses-jsr-305-annotations

  • Change com.google.code.findbugs:jsr305 to org.jspecify:1.0.0 in pom.xml
  • Change import javax.annotation.Nullable; to import org.jspecify.annotations.Nullable;
    • For fully-qualified class names appearing in code, the annotation moves to just between the package and the simple class name. For example:
      @Nullable private java.time.Duration timeout
      
      becomes
      private java.time. @Nullable Duration timeout;
      
  • Change import javax.annotation.Nonnull; to import org.jspecify.annotations.NonNull; and change @Nonnull to NonNull.

@suztomo suztomo changed the title deps: changing jsr305 to jspecify deps: changing jsr305 to jspecify [not for review yet] Sep 11, 2024
@suztomo

suztomo commented Sep 11, 2024

Copy link
Copy Markdown
Member Author

@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Sep 11, 2024
@suztomo suztomo changed the title deps: changing jsr305 to jspecify [not for review yet] [not for review yet] deps: changing jsr305 to jspecify Sep 12, 2024
@suztomo

suztomo commented Sep 13, 2024

Copy link
Copy Markdown
Member Author

ci / build(8) for gapic-generator-java failed: https://github.com/googleapis/sdk-platform-java/actions/runs/10837827237/job/30074668962?pr=3191

external/com_google_api_gax_java/gax/src/main/java/com/google/api/gax/batching/FlowController.java:336: error: could not resolve Nullable
@nullable

I need to add jspecify dependency in the Bazel build too.

@suztomo

suztomo commented Sep 16, 2024

Copy link
Copy Markdown
Member Author

"ci / build(8) except for gapic-generator-java" passed.

@suztomo

suztomo commented Sep 18, 2024

Copy link
Copy Markdown
Member Author

There are differnces in the AutoValue generated code. https://gist.github.com/suztomo/0dc82b1b04d9364ecb35421f8b65cc63
It seems explicitly adding Nullable annotations for variables that can be null.

Update: They are irrelevant. AutoValue is adding the Nullable for the builder fields that can be null at initialization when type annotation is found.

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant