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

jakarta.inject support #1009

Closed
kdombeck opened this issue Jun 9, 2023 · 5 comments
Closed

jakarta.inject support #1009

kdombeck opened this issue Jun 9, 2023 · 5 comments

Comments

@kdombeck
Copy link
Contributor

kdombeck commented Jun 9, 2023

The javax to Jakarta headache never ends. :)

I see that this project is using javax.inject.Inject in TypesafeConfigurator.

This is causing issues when I upgraded to Guice 7.0 as my FactoryCreator is not being injected into TypesafeConfigurator.

I see that you are aware of the headaches this is causing by your comments in google/guice#1383 so I am wondering on what your thoughts are on being able to support jakarta.inject.Inject?

@ben-manes
Copy link
Owner

yeah, I was wondering about what to do here.

An easy fix is to write an adapter rather than directly wire up requestStaticInjection(TypesafeConfigurator.class). Guice doesn't use classpath scanning so the old inject would be ignored. Or is something else amiss?

An issue that is not easy to work around is if you use org.jsr107.ri:cache-annotations-ri-guice? Since jcache is abandonware this uses the javax annotations and won't migrate. Thus the annotation support is broken. The only way to resolve that is bytecode rewriting, e.g. using gradle-jakartaee-migration-plugin.

I'd be fine updating to use the newer annotation, but I don't know if that would resolve your woes.

@kdombeck
Copy link
Contributor Author

kdombeck commented Jun 9, 2023

You are spot on for both points!!!

  1. We currently are using requestStaticInjection(TypesafeConfigurator.class) and that is how I was able to find that FactoryCreator was not being "injected".
  2. We were using org.jsr107.ri:cache-annotations-ri-guice prior to us migrating to jakarta, but I then realized it was abandoned like you mentioned and was able to remove it without issue.

I copied the source of TypesafeConfigurator and replaced the package name of javax.inject.Inject with jakarta.inject.Inject and everything worked. So I "think" that is the only change needed right now.

Or I can do like you mentioned and manually set the FactoryCreator on TypesafeConfigurator.

@ben-manes
Copy link
Owner

Released in 3.1.7

@froque
Copy link

froque commented Jul 27, 2023

This should not have been a patch version

@ben-manes
Copy link
Owner

ben-manes commented Jul 27, 2023

This change should only require that Guice users who leverage this static injection upgrade to 6.0, which has support for both namespaces. That is a backwards compatible release and usages of the RI annotations will work until Guice 7.0 which drops support for javax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants