Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.9
-
None
Description
I don't know if this is the same as GROOVY-3454 or not. That issue is marked resolved but I am seeing the problem with 2.1.9.
Code from the attached app...
package com.demo; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface MyAnnotation { String value(); String code() default ""; }
package com.demo class MyAnnotationSpec extends spock.lang.Specification { void 'test code'() { expect: Widget.getDeclaredField('name').getAnnotation(MyAnnotation).code() == 'alpha' } } class Widget { @MyAnnotation(code='alpha') String name }
That test compiles and passes. I expected the compiler to fail on the Widget class since the annotation does not provide a value for the "value" attribute.
Am I overlooking something simple or is this broken?
Attachments
Attachments
Issue Links
- is duplicated by
-
GROOVY-5952 Groovyc doesn't check annotations for missing attributes if variable is annotated
- Closed
- is related to
-
GROOVY-3454 Compiler should enforce that annotation value w/o default is provided
- Closed