Class loading when extending an Eclipse plugin with a fragment project does not work

1.5k Views Asked by At

I am trying to extend a third-party Eclipse plug-in by using a fragment project. The major reason is that the third party plug-in contains classes having the default (package) modifier and I need to extend them.

Thus, my extensions class must be located in exactly the same package. I create a fragment project containing the same package and put my class into it. Everything works fine when I am using a runtime workspace.

However, if I try to deploy my fragment (e.g., deploying it into the dropins folder of my Eclipse distribution), I am not able to execute the code. Extensions and stuff like that work fine (e.g., I use extensions for a new Run Configuration. However, if I try to instantiate this run configuration I get an error message that the third-party root plug-in was unable to load the class to display my configuration tab group.

Any experience with this kind of problems?

3

There are 3 best solutions below

3
On

Sorry, but that does not work. Unless the host bundle has been crafted specially for it, you cannot override a class in the host from a fragment. The reason is that resources - including classes - are retrieved from the host before any fragment.

See org.eclipse.osgi.baseadaptor.loader.ClasspathManager for the implementation..

0
On

Actually I found the problem now for myself. The problem was a wrong configured build properties file which excluded the Java byte code from my fragment JAR. Very itchy, as the classes were in the JAR but in a wrong subdirectory.

0
On

Actually, this is the extension code I am using:

<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
  <launchConfigurationTabGroup
    class="com.android.ide.eclipse.adt.internal.launch.jouleunit.AndroidJouleUnitTabGroup"
    id="com.android.ide.eclipse.adt.jouleunit.AndroidJouleUnitLaunchConfigTabGroup"
    type="com.android.ide.eclipse.adt.jouleunit.launchConfigurationType">
  </launchConfigurationTabGroup>

Of course, there are further extensions definig the launch configuration type etc. but this is the one leading to the class which Eclipse can not find.