Bug 210432

Summary: BodyDeclaration.getJavadoc() returns null if javadoc follows an annotation
Product: [Eclipse Project] JDT Reporter: Mike Yawn <mike>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: eric_jodet, jerome_lanneluc, Olivier_Thomann
Version: 3.2.2   
Target Milestone: 3.4 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

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