Community
Participate
Working Groups
JSR335 0.6.2 sect. 9.6.1 has this grammar rule: AnnotationTypeElementDeclaration: InterfaceMethodModifiersopt Type Identifier '(' ')' Dimsopt DefaultValueopt ';' This would admit a default method, yet without a body. Javac b74 happily accepts a default method *with* body in an annotation type. Does the spec admit the modifier because semantic analysis will always detect an error regarding a missing method body? Shouldn't the modifier already be prohibited on annotation members?
Do you have a small test case that a lazy reader can copy/paste ?
(In reply to comment #1) > Do you have a small test case that a lazy reader can copy/paste ? Sure: public @interface I { default String m1() { return "1"; } // syntactically illegal only (?) because of method body default String m2(); // syntactically correct (?) but semantically illegal because default method needs a body }
This rang a bell and I realized that I raised this with the spec committee a few months ago: This is a javac bug and does not require any action on eclipse side: See https://bugs.eclipse.org/bugs/show_bug.cgi?id=380194#c41,
Thanks, that bell should have rung for me, too :)