Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 369527

Summary: Potential NPEs in JDT UI code
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.8   
Target Milestone: 3.8 M5   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Deepak Azad CLA 2012-01-24 10:00:42 EST
master branch

Potential null pointer access: The field fGeneratedAnnotations may be null at this location	CompilationUnitDocumentProvider.java	/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor	line 744

The code does look wrong to me
	private void stopCollectingProblems() {
		if (fGeneratedAnnotations != null)
			removeAnnotations(fGeneratedAnnotations, true, true);
		fGeneratedAnnotations.clear();   //warning
	}

Potential null pointer access: The field fLeaveDelegateCheckBox may be null at this location	MoveInstanceMethodWizard.java	/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring	line 259

Similar code pattern as above

fLeaveDelegateCheckBox= //something
if (fLeaveDelegateCheckBox != null) {
// lots of code here
}			fProcessor.setInlineDelegator(!fLeaveDelegateCheckBox.getSelection()); //warning
fProcessor.setRemoveDelegator(!fLeaveDelegateCheckBox.getSelection());
Comment 1 Dani Megert CLA 2012-01-24 10:50:06 EST
I've fixed the the CUDP. There was never a problem to get an NPE since the field is initialized once and never set later.

Moving to Markus for the MoveInstanceMethodWizard: I guess

    fProcessor.setInlineDelegator(!fLeaveDelegateCheckBox.getSelection());
    fProcessor.setRemoveDelegator(!fLeaveDelegateCheckBox.getSelection());

not only it has to be protected against 'null' but also be updated when the selection of 'fLeaveDelegateCheckBox' changes.
Comment 2 Markus Keller CLA 2012-01-24 17:06:45 EST
MoveInstanceMethodWizard: Just removed the two lines, since DelegateUIHelper.generateLeaveDelegateCheckbox(..) already installs a callback to update the refactoring when the check box is toggled.