| Summary: | [implementation] NPE while opening the first java editor | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Sebastian Davids <sdavids> |
| Component: | Text | Assignee: | Dani Megert <daniel_megert> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | critical | ||
| Priority: | P2 | CC: | alexfo2003, cfmdobbie, juergen |
| Version: | 3.0 | ||
| Target Milestone: | 3.0.1 | ||
| Hardware: | PC | ||
| OS: | Windows 98 | ||
| Whiteboard: | |||
| Bug Depends on: | 70838, 70853 | ||
| Bug Blocks: | |||
|
Description
Sebastian Davids
Which VM do you use? Use -consoleLog -vmargs -showversion Any additional plug-ins installed? If so, which ones? Do you see the error on plain Eclipse SDK? Is this reproducable? How did you create the empty class? Found the problem :) @@@@ java version "1.4.2_03" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02) Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode) eclipse.buildId=I200406251208 java.version=1.4.2_03 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE @@@@ I installed the eclipse platform SDK. Afterwards I used the update manager: Thu Jul 15 12:47:16 CEST 2004 file:/c:/WINDOWS/Desktop/x/eclipse/ site-install success Thu Jul 15 12:47:44 CEST 2004 org.eclipse.jdt_3.0.0 feature-install success Thu Jul 15 12:51:51 CEST 2004 org.eclipse.jdt_3.0.0 feature-enable success @@@@ Start with a new -- default -- workspace. Window/Preferences/Java/Editor/Hovers Select "Enable anotation roll-over when opening a new editor" OK. Close Eclipse Restart. Create new Java project. Create a new Class. @@@@ The first editor opened will produce the NPE ... all editors afterwards will not. This bug is not reproducible with the complete SDK 3.0 drop. Looking at the source code:
ManifestElement[] manifestElements;
try {
manifestElements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires);
} catch (BundleException e) {
continue;
}
int i= 0;
while (i < manifestElements.length && !toTest.isEmpty()) {
@@@@
It is not checked whether manifestElements is null.
ManifestElement.parseHeader() has several cases where it returns null.
so the following lineLooking at the source code:
ManifestElement[] manifestElements;
try {
manifestElements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires);
} catch (BundleException e) {
continue;
}
int i= 0;
while (i < manifestElements.length && !toTest.isEmpty()) {
@@@@
It is not checked whether manifestElements is null.
ManifestElement.parseHeader() has several cases where it returns null.
A possible fix would be:
ManifestElement[] manifestElements;
try {
manifestElements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires);
} catch (BundleException e) {
continue;
}
if (manifestElements == null) continue;
int i= 0;
while (i < manifestElements.length && !toTest.isEmpty()) {
Damn cut'n'paste demon :/ good catch - will try to reproduce *** Bug 70004 has been marked as a duplicate of this bug. *** The ClassCastException is a follow-up of the NPE and happens due to bug 70838. The NPE is caused because manifestElements is null after this code as already outlined in comment 5: try { manifestElements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires); } catch (BundleException e) { continue; } In contrast to other Eclipse APIs this one is specified to return null instead of an empty array and hence we later fail with the NPE. The code which follows has to handle null. And we should log the exception. However, this does still not explain why it fails when using Update/Install but not when using the Eclipse SDK drop. Test Case for full Eclipse SDK drop: Add a org.eclipse.jdt.ui.javaEditorTextHovers extension to a plug-in which has no prereqs (e.g. org.eclipse.text) and start Eclipse. OK to fix for 3.0.1 Reproduced the bug using Install/Update. I instrumented ConfigurationElementSorter to write log info and what I found is that the following code returns null: String requires= (String)bundle.getHeaders().get(Constants.REQUIRE_BUNDLE); i.e. does not find the required plug-ins for the bundles who contribute to the extension point "org.eclipse.jdt.ui.javaEditorTextHovers": - org.eclipse.jdt.ui (symbolic bundle name) - org.eclipse.jdt.debug.ui (symbolic bundle name) Those plug-ins are there after using Install/Update and also the code can be run e.g. to open the preferences or create a Java project. In my development workspace I then set the PDE target platform to that install and for some strange reason PDE only lists the Eclipse Platform SDK plug-ins. Fix in R3_0_maintenance branch. Will be released into M200407280800 *** Bug 71346 has been marked as a duplicate of this bug. *** starting to verify for 3.1 verified for 3.1 that the NPE does not occur. Verified in M200409010800. Looks good to me as well - 3.1.0 (200408122000) *** Bug 74179 has been marked as a duplicate of this bug. *** |