Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320084 - [hovering] NPE when hovering over @value reference within a type's Javadoc
Summary: [hovering] NPE when hovering over @value reference within a type's Javadoc
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Tom Hofmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 323091 373267 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-07-16 04:49 EDT by Tom Hofmann CLA
Modified: 2012-03-06 11:00 EST (History)
4 users (show)

See Also:
markus.kell.r: review+


Attachments
Patch against JavadocContentAccess2.java (1.38 KB, patch)
2010-07-16 04:57 EDT, Tom Hofmann CLA
no flags Details | Diff
Updated patch (1.42 KB, patch)
2010-07-16 04:58 EDT, Tom Hofmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2010-07-16 04:49:37 EDT
3.6

- have a class with a static final field

------ Test.java -------
class Test {
	public static final String OUTER= "coolbar";
	/**
	 * Reference to {@value #CONSTANT} and {@value #OUTER}.
	 */
	static class Inner {
		public static final String OUTER= "innerbar";
		public static final String CONSTANT= "foobar";
	}
}
------------------------

- hover over the 'Inner' class name
> boom: "Unexpected runtime error while computing a text hover"
- see exception stack trace below.

Problem is that JavadocContentAccess2 assumes that fMember is not a top-level type.


java.lang.NullPointerException
at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.handleValueTag(JavadocContentAccess2.java:1175)
at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.handleInlineTagElement(JavadocContentAccess2.java:1125)
at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.handleContentElements(JavadocContentAccess2.java:1067)
at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.handleContentElements(JavadocContentAccess2.java:1033)
at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.toHTML(JavadocContentAccess2.java:774)
at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.javadoc2HTML(JavadocContentAccess2.java:630)
at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContentFromSource(JavadocContentAccess2.java:582)
at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:466)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:609)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:555)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:547)
at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:141)
Comment 1 Tom Hofmann CLA 2010-07-16 04:57:03 EDT
Created attachment 174476 [details]
Patch against JavadocContentAccess2.java

Patch fixing the reported NPE. The code walks the chain of enclosing types until it finds the corresponding field.
Comment 2 Tom Hofmann CLA 2010-07-16 04:58:46 EDT
Created attachment 174477 [details]
Updated patch

oops, I inadvertedly attached the previous version of the patch which did not stop walking the chain when it encountered a non-constant field.
Comment 3 Dani Megert CLA 2010-07-19 05:37:02 EDT
Tom, which build id?
This works fine for me using R3.6 and latest 3.7. Markus to confirm.
Comment 4 Tom Hofmann CLA 2010-07-19 05:54:18 EDT
Sorry, the example is bad and does not reproduce the problem.

I can reproduce with eclipse SDK 3.6 (I20100608-0911) and the following snippet when hovering over 'Test'. The type being hovered over has to be a top-level type to trigger the error.

------- Test.java ---------
/**
 * Reference to {@value #OUTER}.
 */
class Test {
    public static final String OUTER= "coolbar";
}
---------------------------
Comment 5 Dani Megert CLA 2010-08-19 01:26:31 EDT
*** Bug 323091 has been marked as a duplicate of this bug. ***
Comment 6 Rajesh CLA 2010-09-14 07:36:51 EDT
Reviewed the patch and tested, seems to work fine.
Comment 7 Dani Megert CLA 2010-09-21 10:23:46 EDT
Tom, please just go ahead and commit to HEAD and don't forget to add your credentials to the copyright notice as usual.
Comment 8 Dani Megert CLA 2010-10-06 12:01:30 EDT
Tom, are you still there? ;-)
Comment 9 Dani Megert CLA 2010-10-27 03:12:45 EDT
Tom, please add yourself to the copyright section before committing to HEAD.
Comment 10 Tom Hofmann CLA 2010-10-29 11:41:41 EDT
Fixed > 20101029.

Sorry this took so long, turn-around time should be shorter next time...
Comment 11 Markus Keller CLA 2010-10-29 12:00:28 EDT
Great to have you back, Tom!
Moved milestone, since M3 is already packaged for shipping.
Comment 12 Markus Keller CLA 2012-03-06 11:00:11 EST
*** Bug 373267 has been marked as a duplicate of this bug. ***