Community
Participate
Working Groups
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)
Note that the NPE does not occur if TestException and TestOtherException are top level types defined in their own CU...
Created attachment 58767 [details] Proposed fix
Released for 3.3M6. Test added CompletionTests#testCatchClauseExceptionRef14()
Verified for 3.3 M6 using build I20070319-1335.