Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Resolver Problem with guava and e4 (javax.annotation)

a) Removing the javax.annotation import would surely not work, since then you won’t have any visibility of that package at all. I assume resolver.problem does actually use this package?

b) Modifying Guava would require repackaging it and maintaining that indefinitely.

I propose a third solution: import package javax.annotation from your bundle but don’t require version 1. The package is after all part of JavaSE since at least Java 1.6, and the JRE exports everything as version zero.

Regards,
Neil

On 10 June 2014 at 21:32:06, Tom Schindl (tom.schindl@xxxxxxxxxxxxxxx) wrote:

Hi,

[cross posting because different projects are involved in the problem]

I've just discover a problem when one tries to use e4-DI and
com.google.guava 15.0.0.

The MANIFEST.MF is really simply:
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: Problem
> Bundle-SymbolicName: resolver.problem
> Bundle-Version: 1.0.0.qualifier
> Bundle-RequiredExecutionEnvironment: JavaSE-1.8
> Import-Package: javax.annotation;version="1.0.0"
> Require-Bundle: com.google.guava;bundle-version="15.0.0"

and when trying to resolve it one gets:
> resolver.problem [196]
> Bundle was not resolved because of a uses contraint violation.
> org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource resolver.problem [osgi.identity; osgi.identity="resolver.problem"; type="osgi.bundle"; version:Version="1.0.0.qualifier"] because it is exposed to package 'javax.annotation' from resources javax.annotation [osgi.identity; osgi.identity="javax.annotation"; type="osgi.bundle"; version:Version="1.2.0.v201401042248"] and org.eclipse.osgi [osgi.identity; osgi.identity="org.eclipse.osgi"; type="osgi.bundle"; version:Version="3.10.0.v20140528-2014"; singleton:="true"] via two dependency chains.
>
> Chain 1:
> resolver.problem [osgi.identity; osgi.identity="resolver.problem"; type="osgi.bundle"; version:Version="1.0.0.qualifier"]
> import: (&(osgi.wiring.package=javax.annotation)(version>=1.0.0))
> |
> export: osgi.wiring.package: javax.annotation
> javax.annotation [osgi.identity; osgi.identity="javax.annotation"; type="osgi.bundle"; version:Version="1.2.0.v201401042248"]
>
> Chain 2:
> resolver.problem [osgi.identity; osgi.identity="resolver.problem"; type="osgi.bundle"; version:Version="1.0.0.qualifier"]
> require: (&(osgi.wiring.bundle=com.google.guava)(bundle-version>=15.0.0))
> |
> provide: osgi.wiring.bundle; bundle-version:Version="15.0.0.v201403281430"; osgi.wiring.bundle="com.google.guava"
> com.google.guava [osgi.identity; osgi.identity="com.google.guava"; type="osgi.bundle"; version:Version="15.0.0.v201403281430"]
> import: (osgi.wiring.package=javax.annotation)
> |
> export: osgi.wiring.package: javax.annotation
> org.eclipse.osgi [osgi.identity; osgi.identity="org.eclipse.osgi"; type="osgi.bundle"; version:Version="3.10.0.v20140528-2014"; singleton:="true"]

The reason is that guava optionally imports:

Import-Package: javax.annotation;resolution:=optional,javax.inject;res
olution:=optional,sun.misc;resolution:=optional

So guava wires to the package from the JDK and presents classes in its
API so I guess that's why the bundles who uses guava results in the
resolution conflict.

There are 2 possible solutions:
a) because we now require JavaSE-6 in all our e4 code we could remove
the need for explicit javax.annotation imports - this would break
existing code but is maybe the correct solution in the long run?

b) guava does import javax.annotation;1.0.0 instead

Tom
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Back to the top