Bug 15244 - NPE in JDTCompilerAdapter
Summary: NPE in JDTCompilerAdapter
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-03 17:12 EDT by Rodrigo Peretti CLA
Modified: 2002-05-06 11:15 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.