Bug 173013 - [assist] NPE while completing in catch formal parameter
Summary: [assist] NPE while completing in catch formal parameter
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M6   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-06 05:13 EST by Frederic Fusier CLA
Modified: 2007-03-20 02:28 EDT (History)
0 users

See Also:


Attachments
Proposed fix (5.66 KB, patch)
2007-02-12 09:16 EST, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2007-02-06 05:13:13 EST
Using warm-up build I20070205-0009 and taken example given in buildnotes for bug 157584, I got an NPE while completing in catch formal parameter.

Here's the test case I used:
package bug;
public class X {
  void foo() throws TestException, TestOtherException {}
  void bar() {
    try {
    	foo();
    } catch(TestException e) {
    } catch(Test|) //complete at '|' position
  }
}
class TestException extends Exception {}
class TestOtherException extends Exception {}

Then you'll get an NPE with following stack trace:
java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.canBeSeenBy(ReferenceBinding.java:254)
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.findExceptionFromTryStatement(CompletionEngine.java:2321)
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.findExceptionFromTryStatement(CompletionEngine.java:2469)
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:936)
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1994)
	at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:123)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:320)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:313)
	at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.internalComputeCompletionProposals(JavaCompletionProposalComputer.java:180)
	at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.computeCompletionProposals(JavaCompletionProposalComputer.java:148)
	at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:303)
	at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:264)
	at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:251)
	at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:220)
Comment 1 Frederic Fusier CLA 2007-02-06 05:14:10 EST
Note that the NPE does not occur if TestException and TestOtherException are top level types defined in their own CU...
Comment 2 David Audel CLA 2007-02-12 09:16:31 EST
Created attachment 58767 [details]
Proposed fix
Comment 3 David Audel CLA 2007-02-12 09:19:53 EST
Released for 3.3M6.

Test added
  CompletionTests#testCatchClauseExceptionRef14()
Comment 4 Maxime Daniel CLA 2007-03-20 02:28:23 EDT
Verified for 3.3 M6 using build I20070319-1335.