Re: [cross-project-issues-dev] Is it acceptable to have two com.google.common.collect providers?
On Mon, Feb 13, 2012 at 4:00 AM, Ed Willink <ed@xxxxxxxxxxxxx>
Xtext gives me a dependency that loads
Acceleo gives me a dependency that loads
Both provide com.google.common.collect.SetMultimap so I'm not
surprised that Hudson gives me:
java.lang.LinkageError: loader constraint violation: loader (instance of
org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated
loading for a different type with name "com/google/common/collect/SetMultimap"
Usually with 2 bundles supplying the same package you'll see ClassCastException (from SetMultipmap to SetMultimap, a head scratcher :-) That this is a linkage indicates that some configuration of the bundles is causing the same classloader to try and load the same class from 2 different locations. Maybe one of the Equinox guys can suggest what kind of configuration might cause this error?
Did Guava absorb com.google.collect, and that's why it includes those packages (instead of consuming them from the next version of the com.google.collect bundle)?
I see the problem in an JUnit test run as a plugin test. The same
JUnit test run as an ordinary test has no problem, so perhaps there
is a relative loading order of com.google.guava and
com.google.collect that can be enforced to avoid the problem.
For a regular JUnit test, it's standard classpath rules ... it'll load the first class it finds on the classpath. Whatever order the jars appear, it's happy with them. Fixing them for JUnit Plugin tests probably means making sure that 1) com.google.collect and com.google.guava are both correctly versioned and export their packages versioned (it sounds like they do) and 2) the plugins that consume them are also following OSGi conventions (set a minimum baseline, don't re-export any packages, use Import-Package if possible).
Hi floor. Make me a sammich! - GIR