Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369527 - Potential NPEs in JDT UI code
Summary: Potential NPEs in JDT UI code
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.8 M5   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-24 10:00 EST by Deepak Azad CLA
Modified: 2012-01-24 17:06 EST (History)
1 user (show)

See Also:


Attachments

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