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

Quarkus extension to convert javax to jakarta annotations not working #46263

Open
BobShoaun opened this issue Feb 13, 2025 · 1 comment
Open
Labels
kind/question Further information is requested

Comments

@BobShoaun
Copy link

Describe the bug

Hi, I am currently working on writing a Quarkus extension to convert all javax annotations to jakarta annotations (for e.g. javax.annotation.PostConstruct to jakarta.annotation.PostConstruct).

I have written an annotation transformer with a processor triggered during deployment time. But even though it seems that the transformer is picking up the javax PostConstruct annotations and converting them to jakarta PostConstruct annotations (verified with print statements), during runtime the behaviour does not seem to be reflected, and the behaviour is the same as if the transformer did not convert the annotations at all. (javax annotations does not work in Quarkus)

Attached is the code of my transformer and processor including tests, please let me know if I’m missing something. Thanks.

Expected behavior

The extension successfully transforms the javax.annotation.PostConstruct to jakarta.annotation.PostConstruct in Javax2JakartaResource. The changeValue method gets triggered and mutates this.value, causing the test the pass.

Actual behavior

After the transformation, the changeValue method still does not get triggered, which implies the transformation did not happen. this.value does not get mutated and the test fails.

How to Reproduce?

javax2jakarta.zip

  1. Download and unzip code
  2. cd javax2jakarta
  3. run mvn test
  4. observe test failure:
[ERROR] Failures: 
[ERROR]   Javax2JakartaResourceTest.testValueEndpoint:19 1 expectation failed.
Response body doesn't match expectation.
Expected: is "Value is changed"
  Actual: Value is not changed
  1. Comment out line 23 and uncomment line 24 in Javax2JakartaResource.java (replace javax import to jakarta)
  2. run mvn test
  3. observe test pass

Output of uname -a or ver

No response

Output of java -version

openjdk version "23.0.1" 2024-10-15 OpenJDK Runtime Environment (build 23.0.1+11-39) OpenJDK 64-Bit Server VM (build 23.0.1+11-39, mixed mode, sharing)

Quarkus version or git rev

3.15.3

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) Maven home: /opt/homebrew/Cellar/maven/3.9.9/libexec Java version: 23.0.2, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk/23.0.2/libexec/openjdk.jdk/Contents/Home Default locale: en_CA, platform encoding: UTF-8 OS name: "mac os x", version: "15.2", arch: "aarch64", family: "mac"

Additional information

No response

@BobShoaun BobShoaun added the kind/bug Something isn't working label Feb 13, 2025
@BobShoaun
Copy link
Author

Worth mentioning that converting javax.inject.Named to jakarta.inject.Named using AnnotationTransformers work.

@geoand geoand added kind/question Further information is requested and removed triage/needs-triage kind/bug Something isn't working labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants