Bug 45592 - NPE while searching a method references in jdt-core
Summary: NPE while searching a method references in jdt-core
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-27 07:46 EST by Frederic Fusier CLA
Modified: 2003-11-24 07:21 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2003-10-27 07:46:32 EST
When 'Reporting Invalid Javadoc Annotation' compiler option is set, then I got 
a NPE while looking for references of Boolean.valueOf(boolean) in Working set 
project 'jdt-core'.

Here's the stack of this exception:
!ENTRY org.eclipse.jdt.ui 4 10001 Oct 27, 2003 13:00:16.942
!MESSAGE Internal Error
!STACK 0
java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run
(ProgressMonitorDialog.java:386)
	at org.eclipse.jdt.ui.actions.FindAction.run(FindAction.java:292)
	at org.eclipse.jdt.ui.actions.FindReferencesAction.run
(FindReferencesAction.java:83)
	at org.eclipse.jdt.ui.actions.FindAction.run(FindAction.java:220)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun
(SelectionDispatchAction.java:194)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run
(SelectionDispatchAction.java:172)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:842)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:547)
	at org.eclipse.jface.action.ActionContributionItem.access$4
(ActionContributionItem.java:494)
	at org.eclipse.jface.action.ActionContributionItem$6.handleEvent
(ActionContributionItem.java:466)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2173)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1863)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1579)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:1562)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:858)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:299)
	at org.eclipse.core.launcher.Main.run(Main.java:765)
	at org.eclipse.core.launcher.Main.main(Main.java:599)
Caused by: java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.isSuperAccess
(MessageSend.java:116)
	at org.eclipse.jdt.internal.compiler.lookup.MethodBinding.canBeSeenBy
(MethodBinding.java:151)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findExactMethod
(Scope.java:173)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod
(Scope.java:1650)
	at 
org.eclipse.jdt.internal.compiler.ast.AnnotationMessageSend.resolveType
(AnnotationMessageSend.java:91)
	at org.eclipse.jdt.internal.compiler.ast.Annotation.resolve
(Annotation.java:132)
	at 
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveAnnotatio
n(AbstractMethodDeclaration.java:366)
	at 
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve
(AbstractMethodDeclaration.java:356)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve
(TypeDeclaration.java:852)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve
(TypeDeclaration.java:902)
	at 
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve
(CompilationUnitDeclaration.java:271)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process
(MatchLocator.java:870)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:603)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:640)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:749)
	at org.eclipse.jdt.core.search.SearchEngine.search
(SearchEngine.java:572)
	at org.eclipse.jdt.core.search.SearchEngine.search
(SearchEngine.java:499)
	at org.eclipse.jdt.internal.ui.search.JavaSearchOperation.execute
(JavaSearchOperation.java:96)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run
(WorkspaceModifyOperation.java:71)
	at org.eclipse.core.internal.resources.Workspace.run
(Workspace.java:1555)
	at org.eclipse.core.internal.resources.Workspace.run
(Workspace.java:1572)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run
(WorkspaceModifyOperation.java:85)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run
(ModalContext.java:101)
Comment 1 Frederic Fusier CLA 2003-10-27 07:49:52 EST
Happens on build I20031023
Comment 2 Frederic Fusier CLA 2003-10-27 10:12:21 EST
Problem comes from resolving annotation. If javadoc comment contains @see 
references on current class method (typically: @see #foo()), then isSuperAccess
() method is called which need that receiver of MessageSend was not null.
On current class this was not the case :(

Fixed by overriding isSuperAccess() in AnnotationMessageSend and 
AnnotationFieldReference classes. In this case (eg. using current class for 
references), also set the receiver with a new instance of 
AnnotationQualifiedTypeReference initialized with the receiverType.compoundName.
Comment 3 Frederic Fusier CLA 2003-10-31 11:22:24 EST
Test case testBug45592 added in AnnotationTestMixed.
Comment 4 Frederic Fusier CLA 2003-11-18 11:10:21 EST
Using early previous v_382a posted I get a NullPointerException again while 
searching references in jdt-core of SimpleSet.add(Object) method...
Comment 5 Frederic Fusier CLA 2003-11-18 11:14:44 EST
This is a side effect of bug 45958 fix.

While searching, this is not possible to get the main file name, so we cannot 
figure out whether the member name in @see reference may be a constructor or 
not in JavadocParser.getMember(TypeReference) method).

Currently we get a null for the name which makes this NPE happen while 
resolving the referenced type...
Comment 6 Frederic Fusier CLA 2003-11-18 14:36:36 EST
Fixed.

Allow that in some circumstances, it is not possible to figure out the name of 
current type while parsing and set it while resolving (as it was done before...)

In this case, assume that we have a reference to a constructor, as if we do not 
find a constructor matching the member name during the resolution, then we 
finally try to find a method...
Comment 7 David Audel CLA 2003-11-24 07:21:44 EST
Verified.