Bug 165701 - [model] NPE while computing method unique key
Summary: [model] NPE while computing method unique key
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.3 M4   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-23 14:18 EST by R Lenard CLA
Modified: 2006-12-12 07:14 EST (History)
1 user (show)

See Also:


Attachments
Snippet that produces the problem (712 bytes, text/plain)
2006-11-23 14:18 EST, R Lenard CLA
no flags Details
Snippet that produces the problem (712 bytes, text/plain)
2006-11-23 14:18 EST, R Lenard CLA
no flags Details
Proposed patch (2.45 KB, patch)
2006-11-24 13:57 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description R Lenard CLA 2006-11-23 14:18:12 EST
The attached code sample has ambiguous javadoc - it's not clear which of the getMax variants the link should be resolved to.  Eclipse 3.3M3 correctly identifies the ambiguity, but doesn't have a hint other than removing the link.  If it's not resolvable perhaps it should suggest converting it into {@code}?
Also the javadoc spec seems to imply that getMax(Iterable ip1) should be more resolvable than getMax(Iterable) - so the 3rd instance shouldn't be ambiguous.
Comment 1 R Lenard CLA 2006-11-23 14:18:55 EST
Created attachment 54429 [details]
Snippet that produces the problem
Comment 2 R Lenard CLA 2006-11-23 14:18:58 EST
Created attachment 54430 [details]
Snippet that produces the problem
Comment 3 R Lenard CLA 2006-11-23 14:33:02 EST
The JDK documentation sucks for this sort of stuff - otherwise I'd point to what it should be suggesting
Comment 4 Martin Aeschlimann CLA 2006-11-24 08:22:31 EST
Must be a problem in code select over the Java doc link. When I hover of the link I gte the folloing exception:

Exception in thread "Text Viewer Hover Presenter" java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.lookup.MethodBinding.computeUniqueKey(MethodBinding.java:328)
	at org.eclipse.jdt.internal.compiler.lookup.Binding.computeUniqueKey(Binding.java:55)
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.selectFrom(SelectionEngine.java:892)
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:690)
	at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:155)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:329)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:323)
	at org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:120)
	at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69)
	at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:160)
Comment 5 Olivier Thomann CLA 2006-11-24 10:18:29 EST
The reason is that the @link #getMax(Iterable) is ambiguous.
The javadoc tool doesn't detect it and creates two identical anchors for both methods.
We have two ways to fix it.
1) The code selection checks if the binding is a valid binding before trying to open the javadoc. This would end up with no hints for this link.
2) We try to take the closest match if one is set for the problem method.

David, I'll let you investigate it.
Comment 6 Frederic Fusier CLA 2006-11-24 10:42:02 EST
This is a side effect of fix for bug 155003 to have the method thrown exceptions dumped in unique key...
I'll add a check to prevent the NPE...
Comment 7 Frederic Fusier CLA 2006-11-24 13:57:28 EST
Created attachment 54494 [details]
Proposed patch
Comment 8 Frederic Fusier CLA 2006-11-25 14:55:33 EST
Released for 3.3 M4 in HEAD stream.

Note for verifier, you need to use build I20061121-1845 to verify that this NPE really happens. As it was (unfortunately) introduced while fixing bug 155003, it does not happen in 3.3 M3...
Comment 9 Olivier Thomann CLA 2006-11-26 15:21:42 EST
We should also investigate why code selection is trying to get the key of a problem method binding.
In this case the method is ambiguous.
David, please comment on this.
Comment 10 David Audel CLA 2006-11-27 06:38:28 EST
Code select return java element as result. These java elements are computed from bindings. Code select can compute the elements from problems bindings for some specific case.
Keys are used to build resolved java elements (e.g. ResolvedSourceMethod).

The current test case must be supported but the behavior of code select with ambiguous methods isn't perfect and must be improved. I opened another bug for this issue: bug 165900.

I close this bug as fixed because the NPE is fixed.
Comment 11 David Audel CLA 2006-12-12 07:14:18 EST
Verified for 3.3M4 with I20061212-0010.