Consider a scenario where the system JRE on developers machine (where Eclipse IDE is running) is version 1.5. But the bundle execution environment will be JVM 1.4. This is such cases, it is very easy to make the mistakes of accessing the functions that may not be available at runtime.
API Tooling can catch such errors easily if the Execution Environments are available.
Installing Execution Environments
Open the API Tooling preferences (Window > Preferences > Plug-in Development > API Errors/Warnings).
By default the severity level is set to Ignore. Change it to Warning or Error. Click the link install them now. This shall open the Install wizard.API Errors/Warnings
Work with the Galileo release site Galileo - http://download.eclipse.org/releases/galileo. The execution environments are categorized under General Purpose Tools > PDE/API Tools Environment Descriptions. Install the ones you need.
Once installed the API preferences page will show the available execution environments.
System Library Validation in action
Consider a plug-in is execution environment marked as Java 1.4.
Execution Environment section on Overview page of Manifest Editor
If such a plug-in tries to access Java 1.5, there won't be any compilation errors (we will discuss the JDK Compliance level towards the end of this post).
For example, see the snippet below.
String name ="ankur"; name.contentEquals(new StringBuilder("ankur"));
This code will compile fine but will fail at runtime as contentEquals won't take StringBuilder in 1.4. That's an 1.5 API.
Once the API Preference for System Libraries is set to warning or error, same will be reported in the Problems view.
API Tooling validating against System Library
Compiler compliance level Vs System Library Validation
The problem we just discussed above can be also caught by setting the compiler compliance level appropriately. Where it differs is that the compiler setting are restricted to the JDK version. The API Tooling focuses on the execution environment from OSGi perspective. As you would have noticed there are non-Java specific environment descriptions too like CDC-Foundation and OSGi/Miminum.
Another major difference is that API Tooling does not need JRE/JDK. It checks the usage against the environment descriptions. The descriptions are just the environment API and thus occupy very less space. For example, the 1.5 JRE takes close to 50MB while the descriptions for the same takes less than 2 MB.