Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Confusing LinkageError(While trying to use two different versions of the same package, I'm encountering LinkageErrors)
Confusing LinkageError [message #1750326] Tue, 20 December 2016 00:59
Sean Reid is currently offline Sean ReidFriend
Messages: 1
Registered: December 2016
Junior Member
I have two library plugins, each of the same library that have the same API, but different versions

One of the library plugins has the following in the MANIFEST.MF:
Export-Package: com.package.packagename1;version=1.0.0,

The second library plugin has the following defined in the MANIFEST.MF:
Export-Package: com.package.packagename1;version=1.1.0,

The plugin that uses this API has the following defined in the MANIFEST.MF:
Import-Package: com.package.packagename1;version="[1.0.0,1.1.0]",

When the plugin that is using Import-Package is activated,
it checks a preference value to determine which version of the library
the user would like to use. The Activator then calls bundle.stop() and bundle.uninstall()
for the library version that is NOT wanted, leaving only the one plugin available to satisfy the
Import-Package. Up to this point, everything functions as expected and the correct version of the
library can be used without error.

The problem comes in when changing versions. The solution we have is that when the preference
value is changed, we force the application to shutdown and ask the user to restart it so that
the platform and JVM will both restart and we can programmatically stop and uninstall
the other version of the plugin. However, when we think try to invoke the installed version of
the library after a switch, we get the following exception:

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/package/package1/ClassName"

Restarting the JVM and Platform again without changing the preference fixes this issue, but I'd much
rather find a solution that doesn't require users to restart the application two times to change
a library version. Is there another way to solve this problem to avoid this linkage error?
Previous Topic:Can not able to add new pages in projectproperties in plugin.xml
Next Topic:Can I use the latest PDE to develop plugins targeted for an earlier version of Eclipse?
Goto Forum:

Current Time: Sat Jul 24 08:57:00 GMT 2021

Powered by FUDForum. Page generated in 0.01726 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top