WARNING: Annotation classes from the 'javax.inject' or 'javax.annotation' package found give no indication who is using them
I just opening one of my recent Eclipse downloads and got the new message. I think @HannesWell added them.
WARNING: Annotation classes from the 'javax.inject' or 'javax.annotation' package found.
I was wondering who is the offender.... I only have the market place client, EGit, m2e-pde and the SDK installed.
How would I find out who is using these packages as an Eclipse IDE user? If I have no way to identifying this as a user, the message seems not so valuable to a user. Maybe this should not be shown to a user?
@jonahgraham is this warning planned to be visible in the EPP packages?
The javax.inject package is provided by these two bundles in the current SimRel:
We're trying to eliminate the former, which is pulled in by XWT which I might need to disable because they appear to be unresponsive to @HannesWell attempt to contribute a fix.
But that still leaves the other one, and these are all the things that use that package:
So I believe it's inevitable that a bundle with that package will be in all the EPP packages.
The Platform produces that warning in org.eclipse.e4.core.internal.di.AnnotationLookup.loadJavaxClass(Runnable):
private static void loadJavaxClass(Runnable run) {
try {
if (!getSystemPropertyFlag("eclipse.e4.inject.javax.disabled", false)) { //$NON-NLS-1$
run.run();
if (!javaxWarningPrinted) {
if (getSystemPropertyFlag("eclipse.e4.inject.javax.warning", true)) { //$NON-NLS-1$
@SuppressWarnings("nls")
String message = """
WARNING: Annotation classes from the 'javax.inject' or 'javax.annotation' package found.
It is recommended to migrate to the corresponding replacements in the jakarta namespace.
The Eclipse E4 Platform will remove support for those javax-annotations in a future release.
To suppress this warning, set the VM property: -Declipse.e4.inject.javax.warning=false
To disable processing of 'javax' annotations entirely, set the VM property: -Declipse.e4.inject.javax.disabled=true
""";
System.err.println(message);
}
javaxWarningPrinted = true;
}
}
} catch (NoClassDefFoundError e) {
// Ignore exception: javax-annotation seems to be unavailable in the runtime
}
}
Probably the EPP packages should use -Declipse.e4.inject.javax.disabled=true.
The Platform produces that warning in org.eclipse.e4.core.internal.di.AnnotationLookup.loadJavaxClass(Runnable):
Exactly.
Btw. with this perma-link
https://github.com/eclipse-platform/eclipse.platform/blob/b345854ba79a6b4adaff0c839d7e5fad9e2d92ee/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/AnnotationLookup.java#L164-L186
you get the following nicely rendered reference
https://github.com/eclipse-platform/eclipse.platform/blob/b345854ba79a6b4adaff0c839d7e5fad9e2d92ee/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/AnnotationLookup.java#L164-L186
Probably the EPP packages should use
-Declipse.e4.inject.javax.disabled=true.
I agree as well, especially since there are probably quite a few plugins in SimRel that are not yet migrated because they either only have their TP be based on released artifacts (e.g. usually m2e) or have a one year or longer compatibility strategy (like Xtext). And I think that's OK, since the injector is designed to allow the soft migration.
How would I find out who is using these packages as an Eclipse IDE user? If I have no way to identifying this as a user, the message seems not so valuable to a user. Maybe this should not be shown to a user?
As a plain user of the IDE this is not really helpful besides that you can report it to the developers of a Plugin. As a Plugin/Application developers you can check your projects or the dependencies in your TP (and report to them), which still require javax.inject/annotation.
As a user of the IDE you can also find out the requireres by opening the OSGi Host Console and running the command:
g! packages javax.injectg! packages javax.annotation
For my Eclipse development Eclipse this gives
g! packages javax.inject
osgi.wiring.package; bundle-symbolic-name="javax.inject"; bundle-version:Version="1.0.0.v20220405-0441"; version:Version="1.0.0"; osgi.wiring.package="javax.inject"<javax.inject_1.0.0.v20220405-0441 [1720]>
org.eclipse.m2e.maven.runtime_3.9.500.20231113-2345 [2327] imports
org.eclipse.m2e.core_2.4.1.20231119-0901 [2361] imports
org.eclipse.e4.core.di_1.9.200.v20231105-0754 [2129] imports
org.eclipse.e4.core.di.extensions_0.18.100.v20231103-2012 [2063] imports
org.eclipse.e4.core.di.annotations_1.8.200.v20231103-2012 [2062] imports
org.eclipse.m2e.profiles.ui_2.0.301.20231030-1438 [2011] imports
org.eclipse.m2e.editor.lemminx_2.0.5.20231113-2319 [2326] imports
org.eclipse.e4.core.contexts_1.12.400.v20231103-2012 [2060] imports
org.eclipse.e4.core.services_2.4.200.v20231103-2012 [2064] imports
g! packages javax.annotation
osgi.wiring.package; bundle-symbolic-name="javax.annotation"; bundle-version:Version="1.3.5.v20200909-1856"; version:Version="1.3.5"; osgi.wiring.package="javax.annotation"<javax.annotation_1.3.5.v20200909-1856 [1719]>
org.eclipse.m2e.maven.runtime_3.9.500.20231113-2345 [2327] imports
org.eclipse.e4.core.di_1.9.200.v20231105-0754 [2129] imports
org.jsoup_1.16.2 [2338] imports
The org.eclipse.e4.i* bundles require javax.inject only optionally since the have the @javax.inject.Qualifier and @jakarta.inject.Qualifier meta-annotations applied at the same time, in case there are external processors (just for the E4 injector jakarta would be sufficient).
I will migrate the UI elements in m2e after the December release, but org.eclipse.m2e.maven.runtime will even then require the package javax.inject/annotation because the embedded Maven-runtime requires both (probably for a long time).
Probably the EPP packages should use
-Declipse.e4.inject.javax.disabled=true.I agree as well, especially since there are probably quite a few plugins in SimRel that are not yet migrated because they either only have their TP be based on released artifacts (e.g. usually m2e) or have a one year or longer compatibility strategy (like Xtext). And I think that's OK, since the injector is designed to allow the soft migration.
Can you confirm that is the flag I should use, or did you mean -Declipse.e4.inject.javax.warning=false?
Is it possible to provide stacktraces/etc to the offending uses of javax? That would give users a useful place to file a bug against (and make it equivalent-ish) to org.eclipse.swt.graphics.Resource.reportNonDisposed.
I was trying to find org.eclipse.emf.ecp to update their usage but the website says it is using Bugzills and Gerrit. Anyone knows if they planning to move from these deprecated service?
Can you confirm that is the flag I should use, or did you mean
-Declipse.e4.inject.javax.warning=false?
Sorry the initially mentioned flag would disable javax-processing entirly.
-Declipse.e4.inject.javax.warning=false is what you have to use in order to supress the warning.
Is it possible to provide stacktraces/etc to the offending uses of javax? That would give users a useful place to file a bug against (and make it equivalent-ish) to
org.eclipse.swt.graphics.Resource.reportNonDisposed.
Not at the moment. You can only determine the requireres of the javax.inject/annotation packages using the OSGi Host console as described above. But that can also give false positives, Like the m2e.maven.runtime that requires them for other reasons.
It would probably be possible to really only warn about those really processed by the injector, but it's not trivial if it should be done with minimal/no performance impact.
Sorry for my adding confusion!! 😢