googleapis / sdk-platform-java

Tooling and shared libraries for Cloud SDK for Java
https://cloud.google.com/java/docs/bom
Apache License 2.0
64 stars 51 forks source link

api-common using deprecated javax.annotation-api #1938

Open sydney-munro opened 1 year ago

sydney-munro commented 1 year ago

Google Cloud storage recieved https://github.com/googleapis/java-storage/issues/2176 due to a transient dependency on javax.annotaion-api. This should be updated to the new jakarta namespace.

suztomo commented 1 year ago

javax package is not compliant with Jakarta platform. Please release google-cloud-storage:jar which is Jakarta platform compliant.

Digging further.

Where do we use javax.annotation?

Here are example usages

sdk-platform-java

~/sdk-platform-java$ grep -ir javax.annotation . |awk -F':' '{print $2}' |sort -u gave

java-storage

suztomo commented 1 year ago

@abhishekshan03 Would you share details about the noncompliance? Do you get any error message when you use certain tools from Jakarta EE?

I found this article https://jakarta.ee/blogs/javax-jakartaee-namespace-ecosystem-progress/ but it didn't have any specifics about javax.annotation-api.

abhishekshan03 commented 1 year ago

Hi @suztomo Please pardon my limited knowledge. As far as I know packages javax.* are not part of Jakarta EE platform and hence are deprecated and will be replaced by jakarta annotations As an example please refer to below issue. https://github.com/jruby/jruby/issues/6514

MyDogIsMyPersonality commented 11 months ago

Hi @suztomo Is there any idea on when this might be released? It is blocking a major upgrade for us.

suztomo commented 11 months ago

@abhishekshan03 @MyDogIsMyPersonality Are you suffering from some errors with certain tools when they're used with GCP Java libraries? I think it's easy to swap but I'd like to ensure to verify the fix.

Thank you for sharing https://github.com/jruby/jruby/issues/6514. I see it's fixed there.

MyDogIsMyPersonality commented 11 months ago

There is more information in issue 2176, but Jakarta won't upgrade due to the transient dependency in javax.

suztomo commented 11 months ago

@MyDogIsMyPersonality https://github.com/googleapis/java-storage/issues/2176 does not have any errors.

Jakarta won't upgrade

Would you elaborate a bit more? Are you referencing a certain version of one of the tools listed in https://jakarta.ee/compatibility/ ?

abhishekshan03 commented 11 months ago

@abhishekshan03 @MyDogIsMyPersonality Are you suffering from some errors with certain tools when they're used with GCP Java libraries? I think it's easy to swap but I'd like to ensure to verify the fix.

Thank you for sharing jruby/jruby#6514. I see it's fixed there.

@suztomo
I shared jruby/jruby#6514 as an example for your to refer. I havent not asked any action to be taken on this issue. javax.annotation-api.jar is deprecated and should be replaced by jakarta annotations. This ticket was to illustrate that other projects are replacing deprecated javax.annotation-api.jar with jarkarta annotations.

Can you please give us an ETA for replacing the dependency for javax.annotation-api.jar with jarkarta annotations in google-cloud-storage.jar ?

abhishekshan03 commented 11 months ago

https://jakarta.ee/compatibility/

We are not facing any error but since there is dependency on the deprecated javax.annotation-api.jar, we are proactively removing such dependencies.

suztomo commented 11 months ago

Thank you. It's good to hear that there's no one suffering from errors due to the annotations.

we are proactively removing such dependencies

It seems that you're not a normal user of Jakarta EE and Google Cloud. Do you mind sharing who is "we" here (organization name or the name of a team)? Given you're not suffering from this issue, I would like to know the context of why you want this change.

suztomo commented 11 months ago

Got information from the TAM. Thank you. I'll update you about the plan soon. We have the email thread to follow up.

suztomo commented 11 months ago

Continuing investigation.

suztomo commented 11 months ago

We use code generators in Cloud SDK for Java, and they use javax.annotation.Generated:

Now each has tracking feature request (but no commitment). So far no one has suffered problems caused by javax namespace.

For GuardedBy, (usage), as long as the purpose is Errorprone's static analysis, Errorprone's com.google.errorprone.annotations.concurrent.GuardedBy is recommended one. I'm working on https://github.com/googleapis/sdk-platform-java/pull/2061.

GuardedBy

https://github.com/google/error-prone/blob/master/docs/bugpattern/GuardedBy.md

The GuardedBy analysis checks that fields or methods annotated with @GuardedBy(lock) are only accessed when the specified lock is held.

Would removing the synchronized clause fail the build? => Yes, the Bazel build caught a bug I intentionally introduced in https://github.com/googleapis/sdk-platform-java/pull/2060.