Community
Participate
Working Groups
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();
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?
(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.
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?
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...
Verified for 3.4M4 using I20071210-1800