Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347100

Summary: [hovering] Javadoc hover is blank when using href inside {@link ...}
Product: [Eclipse Project] JDT Reporter: John <M8R-sgiphk>
Component: CoreAssignee: Markus Keller <markus.kell.r>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, anchakrk, daniel_megert, jarthana, markus.kell.r, Olivier_Thomann, remy.suen
Version: 3.7   
Target Milestone: 4.3 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
just in case paste failed none

Description John CLA 2011-05-24 21:12:30 EDT
Build Identifier: I20110523-2200

when hovering mouse over the method, its displayed javadoc is empty, but only when using "{@link" and "<a href" inside the "@link"
Eclipse SDK

Version: 4.1.0
Build id: I20110523-2200

Reproducible: Always

Steps to Reproduce:
package org.some;

public class DatabaseConfig  {

    /**
     * See the {@link <a href="{@docRoot}/../GettingStartedGuide/DB.html#dwdatabase">Getting
     * Started Guide, Database chapter</a>} for a full description
     * of deferred-write databases.
     *
     */
    public void boo() {
    }

}
=======

hover over boo() method, javadoc is empty
to fix do either 1 or 2
1. remove "{@link" and "}"
2. remove everything between "{@link" and "}"

in either case, javadoc now shows
Comment 1 John CLA 2011-05-24 21:14:51 EDT
Created attachment 196500 [details]
just in case paste failed
Comment 2 Dani Megert CLA 2011-05-25 03:58:50 EDT
This is not valid Javadoc, see http://download.oracle.com/javase/1.5.0/docs/tooldocs/windows/javadoc.html#{@link} for details.

Having said that, we should not show nothing in that case.
Comment 3 Markus Keller CLA 2011-05-25 09:00:45 EDT
This is a bug in the AST parser: The Javadoc node has no children in this case. 

Works fine if I add an error, e.g. an "x" before "<a href", or if I use another tag like "<ax href=...".
Comment 4 Markus Keller CLA 2012-06-19 09:59:56 EDT
Unfortunately, the Javadoc "spec" is not entirely clear here. It starts with title:

    {@link  package.class#member  label}

... but later says:

    This tag is very similar to @see – both require the same references [..]

While the "string" and <a href="URL#value">label</a> forms are completely unnecessary in @link, the Javadoc tool silently accepts and processes all 3 forms of @see references also in @link inline tags.

As long as the Javadoc tool doesn't issue a warning/error here, the best fix in JDT Core is to also accept and properly process all 3 forms.

Example:

/**
 * Link to {@link #foo()},<br>
 * link to {@link "Hello World"},<br>
 * and {@link <a href="../package-summary.html">package documentation</a>}
 * 
 * @see #foo()
 * @see "Hello World"
 * @see <a href="../package-summary.html">package documentation</a>
 */
void foo();
Comment 5 Markus Keller CLA 2013-02-11 16:40:48 EST
org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser#commentParse() catches Exception and swallows this one:

java.lang.StringIndexOutOfBoundsException: String index out of range: -16
	at java.lang.String.<init>(String.java:207)
	at org.eclipse.jdt.core.dom.DocCommentParser.pushText(DocCommentParser.java:663)
	at org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser.verifyEndLine(AbstractCommentParser.java:1656)
	at org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser.parseReference(AbstractCommentParser.java:1172)
	at org.eclipse.jdt.core.dom.DocCommentParser.parseTag(DocCommentParser.java:483)
	at org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser.commentParse(AbstractCommentParser.java:241)
	at org.eclipse.jdt.core.dom.DocCommentParser.parse(DocCommentParser.java:74)
	at org.eclipse.jdt.core.dom.DocCommentParser.parse(DocCommentParser.java:60)
	at org.eclipse.jdt.core.dom.ASTConverter.createComment(ASTConverter.java:3382)
	at org.eclipse.jdt.core.dom.ASTConverter.buildCommentsTable(ASTConverter.java:348)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1193)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:291)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1207)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:807)

Fixed with http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=2778a965ba1e30dc1a115e4e03837a51f2d404df
Comment 6 ANIRBAN CHAKRABORTY CLA 2013-03-12 05:24:52 EDT
Verified for M6 build eclipse-SDK-I20130310-2000