Bug 15244

Summary: NPE in JDTCompilerAdapter
Product: [Eclipse Project] JDT Reporter: Rodrigo Peretti <rodrigo>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 M6   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Rodrigo Peretti CLA 2002-05-03 17:12:26 EDT
build 20020502

The following code on JDTCompilerAdapter.setupJavacCommand() causes a NPE if 
there JRE_LIB does not exist:

String jre_lib = JavaCore.getClasspathVariable("JRE_LIB").toOSString(); //$NON-
NLS-1$
if (jre_lib == null) {
    throw new BuildException(Util.bind
("ant.jdtadapter.error.missingJRELIB")); //$NON-NLS-1$
}

It would be helpful if the error message could say that the two possibilities 
to solve the problem are or setting a varible called JRE_LIB or setting the 
parameter bootclasspath on the Ant javac task.
Comment 1 Olivier Thomann CLA 2002-05-06 10:48:24 EDT
Indeed the code should be:
IPath jre_lib = JavaCore.getClasspathVariable("JRE_LIB"); 
//$NON-NLS-1$
if (jre_lib == null) {
    throw new 
BuildException(Util.bind
("ant.jdtadapter.error.missingJRELIB")); //$NON-NLS-
1$
}
....jre_lib.toOSString();

If the jre_lib entry is not set, 
JavaCore.getClasspathVariable("JRE_LIB") returns null and then toOSString() throws a NPE.
Comment 2 Olivier Thomann CLA 2002-05-06 11:15:39 EDT
Fixed and released in HEAD.