Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.5.9
-
None
Description
Groovy does not allow the definition of literal byte constants. This makes impossible to express byte constant in some use cases.
First example:
public @interface Version { byte value(); } class Foo { @Version(0x01) String bar } Error: Attribute 'value' should have type 'java.lang.Byte'; but found type 'int' in @Version
Second example:
public @interface Version { byte value(); } class Foo { @Version(1 as byte) String bar } Expected '(byte) 1' to be an inline constant of type byte in @Version at line: 6, column: 14Attribute 'value' should have type 'java.lang.Byte'; but found type 'java.lang.Object' in @Version at line: -1, column: -1
Third example:
public @interface Version { byte value(); } class Foo { public static final byte ONE = 0b01 @Version(ONE) String bar } Expected 'ONE' to be an inline constant of type byte not a field expression in @Version at line: 7, column: 12Attribute 'value' should have type 'java.lang.Byte'; but found type 'java.lang.Object' in @Version at line: -1, column: -1
Attachments
Issue Links
- is related to
-
GROOVY-9206 Cannot use annotation with attribute of type char
- Closed
-
GROOVY-9205 Specify primitive annotation default value using number literal with cast/coerce
- Closed
- relates to
-
GROOVY-7252 Integer literal not accepted for primitive short annotation attribute
- Closed
-
GROOVY-10068 Cannot compile when set short value to annotation by already defined short variable since version 2.5.4
- Closed