Friday, July 07, 2006

Setting the Bundle-RequiredExecutionEnvironment

In 3.2, each bundle included in the Eclipse SDK got its "required execution environments" set.
The two main motivations were:
  • Carefully controlling the set of APIs we use from the JRE and reduce our dependencies
  • Express in an API way the fact that some bundles could run on lower configurations than the one recommended by the platform (for example SWT and OSGi can run on foundation)
By doing that we also got some added benefits:
  • At runtime, bundles that do not qualify to run on the VM will not run (for example bundles requiring java 5 will not resolve on a 1.4 VM)
  • At build time, PDE Build will set the compilation flags for you and make use of the proper class library (see PDE Build help).
So if you write your bundle using java 5 feature, want to manage your JRE dependencies or simply want to do it the platform way, set the Bundle-RequiredExecutionEnvironment in your manifest.mf. Check out the wiki for the details.


3 comments:

Chris Gross said...

Is this seperate from the compiler level in the project properties? Will the compiler mark incorrect usage of features not in the EE? Or do I need to use the compiler level in the project properties for that?

zx said...

"Things on eclise from a core guy."

You misspelled your about ;)

Le ScaL said...

In response to Chris Gross, the compiler level will be set accordingly once you will have clicked the "update classpath and compiler compliance settings" link on the overview page of the manifest.
As for features, the compiler will for example flag usage of generics in a 1.3 environment.
The API enforcement is done by putting the right class library on the classpath (done automatically when setting the value). So make sure to associate a JRE with each of the execution environment you use.