Bug 81082 NPE when testing switch to 5.0 quick fix [quick fix] [5.0]
I20041214-2000 I was testing the new quick fix which changes the compliance: added <T> as return type of Logo.paint(Graphics). I pressed the "Run in Background" button on the upcoming dialog. and continued working. When I now try to change the workspace compliance again I always get the NPE. java.lang.NullPointerException at org.eclipse.jdt.internal.ui.text.correction.ReorgCorrectionsSubProcessor$ChangeTo50Compilace.apply(ReorgCorrectionsSubProcessor.java:269) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:425) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:367) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$19(CompletionProposalPopup.java:363) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$3.widgetDefaultSelected(CompletionProposalPopup.java:328) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:96) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2803) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2448) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1569) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1540) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:285) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:220) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:710) at org.eclipse.core.launcher.Main.main(Main.java:694)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReorgCorrectionsSubProcessor.java
private final IJavaProject fProject;
		
		public ChangeTo50Compilace(String name, IJavaProject project) {
			super(name, null, 5, JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE));
			fProject= project;
		}
		
		public void apply(IDocument document) {
			if (fProject != null) {
				Map map= fProject.getOptions(false);
				JavaModelUtil.set50CompilanceOptions(map);
				fProject.setOptions(map);
			} else {
				Hashtable map= JavaCore.getOptions();
				JavaModelUtil.set50CompilanceOptions(map);
				JavaCore.setOptions(map);
			}
			CoreUtility.startBuildInBackground(fProject.getProject());
		}
	}
	public static void getNeed50ComplianceProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) {
		ICompilationUnit cu= context.getCompilationUnit();
		String label1= CorrectionMessages.getString("ReorgCorrectionsSubProcessor.50_project_compliance.description"); 
		proposals.add(new ChangeTo50Compilace(label1, cu.getJavaProject()));
		String label2= CorrectionMessages.getString("ReorgCorrectionsSubProcessor.50_workspace_compliance.description"); 
		proposals.add(new ChangeTo50Compilace(label2, null));
	}
	
}