Bug 210432 - BodyDeclaration.getJavadoc() returns null if javadoc follows an annotation
Summary: BodyDeclaration.getJavadoc() returns null if javadoc follows an annotation
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.4 M4   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-20 13:21 EST by Mike Yawn CLA
Modified: 2007-12-11 09:33 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Yawn CLA 2007-11-20 13:21:17 EST
Build ID: 3.2.2

Steps To Reproduce:
1. Create source file with method containing both an annotation and a Javadoc comment
2. Parse the AST of the method
3. If the Javadoc precedes any annotations, BodyDeclaration.getJavadoc() returns it.  If the Javadoc comes between annotations and method declaration, .getJavadoc returns null


More information:
This parses correctly:
	/** Javadoc on ID field  */
	@Id
	@GeneratedValue
	public int getId();

This does not:
	@Id
	@GeneratedValue
	/** Javadoc on ID field  */
	public int getId();
Comment 1 Olivier Thomann CLA 2007-11-20 14:27:14 EST
I would expect the javadoc to be placed before the start of the method. The modifiers (annotation) are part of the method declaration.
Therefore I would expect the javadoc to be located before the first modifier. I don't find the actual behavior as being boggus.

We should actually see if the apt type model reports a javadoc for such a declaration.

Frederic, any comment?
Comment 2 Eric Jodet CLA 2007-11-20 16:54:42 EST
(In reply to comment #1)
> I would expect the javadoc to be placed before the start of the method. The
> modifiers (annotation) are part of the method declaration.
> Therefore I would expect the javadoc to be located before the first modifier. I
> don't find the actual behavior as being boggus.

Tested the javadoc tool behavior:
- with the javadoc comment before the first modifier (1st syntax), the comment is correctly generated.
- with the javadoc comment located between the annotations and the public modifier (2nd syntax) , no javadoc gets generated.
Comment 3 Mike Yawn CLA 2007-11-20 17:03:12 EST
This is looking like it might be a user misunderstanding on my part of what legal syntax is.   I'm curious (if anyone knows), what happens to the 'misplaced' Javadoc in this case?  Is it demoted to a regular-style comment, or is it just thrown away?
Comment 4 Frederic Fusier CLA 2007-11-21 01:57:19 EST
Your test case is like writing:
public /** comment */ int /** xxx */ getId();

In this case you'd never expect a javadoc to be generated by javadoc tool or parsed by the Eclipse compiler (Eric's comment 2 confirmed that). So, I agree with Olivier that we behave correctly and then consider this bug as INVALID.

(In reply to comment #3)
> This is looking like it might be a user misunderstanding on my part of what
> legal syntax is.   I'm curious (if anyone knows), what happens to the
> 'misplaced' Javadoc in this case?  Is it demoted to a regular-style comment, or
> is it just thrown away?
> 
Nothing is done with this comment. It's just available in the comments list of the  compilation unit (you can see it in the ASTView), but it's not attached to any node, so not really usable...

Comment 5 Jerome Lanneluc CLA 2007-12-11 09:33:01 EST
Verified for 3.4M4 using I20071210-1800