Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

suztomo
Copy link
Member

@suztomo suztomo commented Sep 11, 2024

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
Copy link
Member Author

suztomo commented Sep 11, 2024

The build failed:

[INFO] ------------------------------------------------------------------------
Error:  Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project gax: Compilation failure: Compilation failure: 
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[71,55] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[85,57] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[90,18] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[94,12] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[101,65] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[120,67] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[125,18] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[133,12] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[140,65] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[160,67] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[165,18] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java:[173,12] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchingSettings.java:[108,25] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchingSettings.java:[114,28] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java:[284,64] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java:[288,66] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java:[370,27] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java:[375,21] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/InstantiatingWatchdogProvider.java:[52,36] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/InstantiatingWatchdogProvider.java:[61,26] scoping construct cannot be annotated with type-use annotation: @org.jspecify.annotations.Nullable
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchEntry.java:[52,16] cannot find symbol
Error:    symbol:   class AutoValue_BatchEntry
Error:    location: class com.google.api.gax.batching.BatchEntry<ElementT,ElementResultT>
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java:[119,41] package AutoValue_EndpointContext does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetrySettings.java:[222,39] package AutoValue_RetrySettings does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchingSettings.java:[124,42] package AutoValue_BatchingSettings does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowControlSettings.java:[72,45] package AutoValue_FlowControlSettings does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/batching/DynamicFlowControlSettings.java:[85,52] package AutoValue_DynamicFlowControlSettings does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/batching/DefaultBatchResource.java:[42,46] package AutoValue_DefaultBatchResource does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/batching/DefaultBatchResource.java:[51,46] package AutoValue_DefaultBatchResource does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/core/FixedCredentialsProvider.java:[46,16] cannot find symbol
Error:    symbol:   class AutoValue_FixedCredentialsProvider
Error:    location: class com.google.api.gax.core.FixedCredentialsProvider
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/core/GoogleCredentialsProvider.java:[107,51] package AutoValue_GoogleCredentialsProvider does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/core/InstantiatingExecutorProvider.java:[93,55] package AutoValue_InstantiatingExecutorProvider does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/core/InstantiatingExecutorProvider.java:[106,55] package AutoValue_InstantiatingExecutorProvider does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/retrying/TimedAttemptSettings.java:[101,46] package AutoValue_TimedAttemptSettings does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/PageContext.java:[47,16] cannot find symbol
Error:    symbol:   class AutoValue_PageContext
Error:    location: class com.google.api.gax.rpc.PageContext<RequestT,ResponseT,ResourceT>
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/PageContext.java:[56,16] cannot find symbol
Error:    symbol:   class AutoValue_PageContext
Error:    location: class com.google.api.gax.rpc.PageContext<RequestT,ResponseT,ResourceT>
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ErrorDetails.java:[143,38] package AutoValue_ErrorDetails does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java:[139,39] package AutoValue_ClientContext does not exist
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing/SpanName.java:[50,16] cannot find symbol
Error:    symbol:   class AutoValue_SpanName
Error:    location: class com.google.api.gax.tracing.SpanName
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedHeaderProvider.java:[54,16] cannot find symbol
Error:    symbol:   class AutoValue_FixedHeaderProvider
Error:    location: class com.google.api.gax.rpc.FixedHeaderProvider
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedHeaderProvider.java:[69,16] cannot find symbol
Error:    symbol:   class AutoValue_FixedHeaderProvider
Error:    location: class com.google.api.gax.rpc.FixedHeaderProvider
Error:  /home/runner/work/sdk-platform-java/sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing/MethodName.java:[52,16] cannot find symbol
Error:    symbol:   class AutoValue_MethodName
Error:    location: class com.google.api.gax.tracing.MethodName
Error:  -> [Help 1]

@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
Copy link
Member Author

suztomo commented Sep 13, 2024

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
Copy link
Member Author

suztomo commented Sep 16, 2024

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

@suztomo
Copy link
Member Author

suztomo commented Sep 18, 2024

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.

Copy link

Copy link

Quality Gate Passed Quality Gate passed for 'java_showcase_integration_tests'

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
81.8% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant