Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 402455 - NullPointerException on "Open Declaration" for method without source code
Summary: NullPointerException on "Open Declaration" for method without source code
Status: VERIFIED DUPLICATE of bug 400559
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2.2   Edit
Hardware: PC Mac OS X
: P3 normal with 1 vote (vote)
Target Milestone: 4.3 M7   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-05 11:43 EST by Marshall Scorcio CLA
Modified: 2013-04-30 07:46 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marshall Scorcio CLA 2013-03-05 11:43:39 EST
This problem does not occur if there is source code attached for the target method.

1. Write some code that calls a method in Java that you don't have source for. For example: private void foo() { String.format("%s", "bar"); }

2. Click on the method name, "format", and press F3 to open the declaration.

Assuming you don't have the source for String.class you should see "An error has occurred. See error log for more details. java.lang.NullPointerException".

The error log has this stack trace:
java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:540)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:255)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:241)
	at org.eclipse.jdt.internal.core.JavaElement.exists(JavaElement.java:159)
	at org.eclipse.jdt.internal.corext.util.JavaModelUtil.isPolymorphicSignature(JavaModelUtil.java:932)
	at org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester.isIntroduceIndirectionAvailable(RefactoringAvailabilityTester.java:744)
	at org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester.isIntroduceIndirectionAvailable(RefactoringAvailabilityTester.java:754)
	at org.eclipse.jdt.ui.actions.IntroduceIndirectionAction.selectionChanged(IntroduceIndirectionAction.java:91)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchSelectionChanged(SelectionDispatchAction.java:263)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.selectionChanged(SelectionDispatchAction.java:258)
	at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:164)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:162)
	at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:2188)
	at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1725)
	at org.eclipse.jface.viewers.TreeViewer.setSelection(TreeViewer.java:1139)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlinePage.select(JavaOutlinePage.java:1132)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setSelection(JavaEditor.java:2410)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.revealInEditor(EditorUtility.java:252)
	at org.eclipse.jdt.ui.JavaUI.revealInEditor(JavaUI.java:734)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:251)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:228)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaElementHyperlink.open(JavaElementHyperlink.java:77)
	at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseUp(HyperlinkManager.java:429)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:220)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4136)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1271)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3982)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3621)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

eclipse.buildId=M20130204-1200
java.version=1.6.0_41
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.java.product -keyring /Users/mscorcio/.eclipse_keyring -showlocation
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.java.product -keyring /Users/mscorcio/.eclipse_keyring -showlocation
Comment 1 Marshall Scorcio CLA 2013-03-05 11:44:36 EST
Also, this didn't happen in 3.7.x. I first saw it in 4.2.1.
Comment 2 Martin Mathew CLA 2013-03-07 23:25:00 EST
Could not reproduce the issue in Eclipse Version: 4.3.0 Build id: I20130306-2330. Can you try in one of the latest builds and let us know if the bug still exists?
Comment 3 Marshall Scorcio CLA 2013-03-11 11:23:54 EDT
(In reply to comment #2)
> Could not reproduce the issue in Eclipse Version: 4.3.0 Build id:
> I20130306-2330. Can you try in one of the latest builds and let us know if
> the bug still exists?

I have confirmed that this bug does not exist in the 4.3 M5 build.
Comment 4 Dani Megert CLA 2013-03-11 12:33:14 EDT
.
Comment 5 Vincent Privat CLA 2013-04-19 19:45:56 EDT
Duplicate of https://bugs.eclipse.org/bugs/show_bug.cgi?id=400559
Comment 6 Dani Megert CLA 2013-04-22 05:38:09 EDT
.

*** This bug has been marked as a duplicate of bug 400559 ***
Comment 7 Stephan Herrmann CLA 2013-04-30 07:46:36 EDT
Verified for 4.3 M7 using build 20130428-2000 that:
- stack trace is the same as in bug 400559
- bug cannot be reproduced in a pristine JDT.