1) Drag a 12MB tools.jar copy into the bundle.
Reasons: (a) every time java is upgraded (even between the minor fix releases) I'll either have to upgrade tools.jar or verify it's the same (b) I may need to use the application with Java 1.7 and 1.6 and if tools.jar change I can't drag around two copies.

2) Use -cp JDK_PATH/lib/tools.jar + org.osgi.framework.system.packages.extra
Reasons: This requires every executable to have that -cp and every eclipse configuration to have the org.osgi.framework.system.packages.extra. I run automated tests with on the fly p2-generated configuration and developers run Plugin JUnit tests from the UI. I can't have a developer be required to go into every single config.ini for every single debug application and add that property every time he wants to debug a new JUnit test.

What I found was that using "Bundle-ClassPath: external:$java.home$/../lib/tools.jar" works like a charm in Equinox dynamically, but fails to compile with PDE statically (at least in the UI).

If I include the above Bundle-ClassPath: in the bundle A and Export-Package: com.sun.tools.attach (even though UI marks this export as an error Equinox runtime has no problem resolving), require bundle A from bundle B, DynamicImport-Package: com.sun.tools.attach.* and run Class.forName("com.sun.tools.attach.VirtualMachine") in bundle B, everything works: EclipseClassLoadingHook.addClassPathEntry kicks in, sees "external:", resolves $java.home$ via BaseStorageHook.substituteVars, tools.jar is found and loaded, class is found, sun shines, birds sing.

However, there is absolutely no way I can compile equivalent code statically, since "external:$java.home$/../lib/tools.jar" is not resolved by PDE the same way Equinox would, and therefore I can't Export-Package: com.sun.tools.attach from bundle A, I can't Import-Package: com.sun.tools.attach from bundle B and consequently I can't reference com.sun.tools.attach.VirtualMachine.list() statically from a java file - compiler can't find the class files needed.

Is there any way to make the above Bundle-ClassPath work for static compilation? Are there any other ways to achieve what I want?

I'm using Eclipse 3.8.2 and will have to stay on it for a while, until 4.x stops crashing every 15 minutes. I'm ready to implement a required patch myself if someone would be so kind to point me in the direction of a class that deals with PDE bundle class-path resolution in UI and at compile time. ]]>Arcadiy Ivanov2013-05-16T01:39:19-00:00