OSGi Execution Environment Validation

April 2, 2009 | 1 min Read

Execution Environments (EE) are a neat concept within OSGi, however, things can become complicated when developing against multiple EEs. For a real world example of what I mean, this weeks integration build in Eclipse was delayed due to an EE issue. A new bundle (org.eclipse.equinox.p2.repository) was added to the Eclipse SDK that declared an execution environment of J2SE-1.4 but used methods from J2SE-1.5 environment. This is really easy to do when you’re using a 6.0 JRE but developing bundles that should run on a 1.4 JRE. I mean, it isn’t that hard to use a new method from java.lang.String or java.lang.Double that you didn’t know about it.

Well, I’m happy to report that these types of problems should never happen again if you use PDE API Tools. In Eclipse 3.5, the PDE team added support for execution environment (system library) validation. To enable the validation support, simply go to the Plug-in Development->API Compilers Errors/Warnings preference page:

Now that you have system library validation enabled, you should see cool warnings like this in your workspace:

All I can say is that I highly recommend you use PDE API Tools if you’re developing OSGi-based applications with Eclipse. If you find any issues or have suggestions, please let the team know by filing a bug.