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

Bug 526132

Summary: Copy and paste the same function in a class gave NPE
Product: [Eclipse Project] JDT Reporter: Vikas Chandra <Vikas.Chandra>
Component: CoreAssignee: Sasikanth Bharadwaj <sasikanth.bharadwaj>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, sasikanth.bharadwaj, stephan.herrmann
Version: 4.8   
Target Milestone: 4.8 M4   
Hardware: PC   
OS: Windows 7   
See Also: https://git.eclipse.org/r/110306
https://git.eclipse.org/r/112536
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=f8ebd9dcd7fd27b8feb51794363d70a22ae2741f
https://bugs.eclipse.org/bugs/show_bug.cgi?id=520482
Whiteboard:
Attachments:
Description Flags
Possible fix none

Description Vikas Chandra CLA 2017-10-17 06:54:05 EDT
In file InstallationDialog, I copy and pasted this method tabSelected

and then build gave me this

Version: Photon (4.8)
Build id: I20171013-2000


java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.ast.Expression.forcedToBeRaw(Expression.java:1090)
	at org.eclipse.jdt.internal.compiler.ast.ASTNode.checkInvocationArguments(ASTNode.java:443)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:874)
	at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1026)
	at org.eclipse.jdt.internal.compiler.ast.Block.resolveUsing(Block.java:130)
	at org.eclipse.jdt.internal.compiler.ast.TryStatement.resolve(TryStatement.java:1172)
	at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:117)
	at org.eclipse.jdt.internal.compiler.ast.IfStatement.resolve(IfStatement.java:276)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:634)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:307)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:544)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1195)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1308)
Comment 1 Vikas Chandra CLA 2017-10-18 08:14:46 EDT
Created attachment 271068 [details]
Possible fix
Comment 2 Vikas Chandra CLA 2017-10-18 08:20:43 EDT
>>In file InstallationDialog, I copy and pasted this method tabSelected

After the fix in previous comment,  I get duplicate method error as I had expected. ( instead of build failure)
Comment 3 Eclipse Genie CLA 2017-10-18 08:33:06 EDT
New Gerrit change created: https://git.eclipse.org/r/110306
Comment 4 Vikas Chandra CLA 2017-11-02 06:01:09 EDT
>>In file InstallationDialog

This file is present in org.eclipse.ui.workbench which is present in ssh://git.eclipse.org/gitroot/platform/eclipse.platform.ui.git

Steps
1) Take ssh://git.eclipse.org/gitroot/platform/eclipse.platform.ui.git
2) Get plugin org.eclipse.ui.workbench
3) Go to java file InstallationDialog
4) Copy past private void tabSelected(TabItem item) 

Expected Compile Error : Duplicate function error

Actual result: Build Error
Comment 5 Vikas Chandra CLA 2017-11-29 01:52:59 EST
I encountered this issue today also on Build id: I20171128-0100. Can anyone of you evaluate the patch or provide alternative fix.
Comment 6 Eclipse Genie CLA 2017-11-29 03:46:49 EST
New Gerrit change created: https://git.eclipse.org/r/112536
Comment 7 Sasikanth Bharadwaj CLA 2017-11-29 03:50:55 EST
(In reply to comment #6)
> New Gerrit change created: https://git.eclipse.org/r/112536

We don't normally see this because the option ReportUnavoidableGenericTypeProblems is never disabled. When this option is disabled, trying to report raw type warnings causes this exception in the duplicate method which does not have a valid binding. Null check is sufficient in this case.
Comment 9 Stephan Herrmann CLA 2017-11-30 07:45:40 EST
@Sasi, have you seen bug 520482? Is it the same? Perhaps you may want to adopt the test case? 

Note, that I also have a slightly more "sophisticated" solution. Which is better?
Comment 10 Sasikanth Bharadwaj CLA 2017-12-01 04:58:34 EST
(In reply to comment #9)
> @Sasi, have you seen bug 520482? Is it the same? Perhaps you may want to adopt
> the test case?
> 
It is the same
> Note, that I also have a slightly more "sophisticated" solution. Which is
> better?
I would say yours..
Comment 11 Jay Arthanareeswaran CLA 2017-12-06 10:52:49 EST
Verified for 4.8 M4 using build I20171205-2000.