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

Bug 178751

Summary: [infer type arguments] NPE in infer type arguments when Code contains error
Product: [Eclipse Project] JDT Reporter: Karsten Becker <eclipse>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: milos.gligoric
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Karsten Becker CLA 2007-03-22 06:30:47 EDT
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;


public class A {
	public void Test(){
		Map m=new HashMap();
		new A<String>();
		m.put("", "");
	}
}

A call to the infer type arguments dialog causes a NPE:
eclipse.buildId=I20070321-0010
java.version=1.6.0_01
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.sdk.ide -pdelaunch
Command-line arguments:  -product org.eclipse.sdk.ide -data C:\workspaces\eclipse-sh3/../runtime-EclipseApplication -dev file:C:/workspaces/eclipse-sh3/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties -pdelaunch -os win32 -ws win32 -arch x86 -consoleLog

Error
Thu Mar 22 11:28:32 CET 2007
Unhandled event loop exception

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)

Caused by: java.lang.NullPointerException
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintCreator.createMethodTypeArguments(InferTypeArgumentsConstraintCreator.java:482)
at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintCreator.endVisit(InferTypeArgumentsConstraintCreator.java:748)
at org.eclipse.jdt.core.dom.ClassInstanceCreation.accept0(ClassInstanceCreation.java:336)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2523)
at org.eclipse.jdt.core.dom.ExpressionStatement.accept0(ExpressionStatement.java:143)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
at org.eclipse.jdt.core.dom.Block.accept0(Block.java:135)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2523)
at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:501)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:483)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:213)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
at org.eclipse.jdt.internal.corext.fix.Java50Fix$AddTypeParametersOperation.rewriteAST(Java50Fix.java:115)
at org.eclipse.jdt.internal.corext.fix.LinkedFix.createChange(LinkedFix.java:74)
at org.eclipse.jdt.internal.ui.text.correction.FixCorrectionProposal.createTextChange(FixCorrectionProposal.java:131)
at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.createChange(CUCorrectionProposal.java:438)
at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.getChange(ChangeCorrectionProposal.java:207)
at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getTextChange(CUCorrectionProposal.java:448)
at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getAdditionalProposalInfo(CUCorrectionProposal.java:169)
at org.eclipse.jdt.internal.ui.text.correction.FixCorrectionProposal.getAdditionalProposalInfo(FixCorrectionProposal.java:98)
at org.eclipse.jface.text.contentassist.AdditionalInfoController$6.run(AdditionalInfoController.java:162)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
... 23 more
Comment 1 Milos Gligoric CLA 2012-11-27 19:03:08 EST
I am unable to reproduce this on:

Eclipse Java EE IDE for Web Developers.
Version: Juno Service Release 1
Build id: 20120920-0800

Also "public class A" should be "public class A<T>"
Comment 2 Eclipse Genie CLA 2020-03-10 12:37:29 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.