Runtime annotations with enum or wildcard fields DONT BUILD with lombok.jar on CP

72 views
Skip to first unread message

Erem

unread,
Mar 18, 2010, 3:48:07 PM3/18/10
to Project Lombok
Hey guys,

Been using lombok for a while. Came across a very specific issue I
think is a bug. Can anyone explain this behavior?

This is all you do

(1) Put the java file at the end of this msg into a directory with
lombok.jar
(2) run the command: javac TestAnnotations.java
(3) Observe that it builds.
(4) run the command: javac -cp lombok.jar TestAnnotations.java
(5) Observe the following error:

TestAnnotations.java:17: incompatible types
found : TestAnnotations.FooEnum
required: TestAnnotations.FooEnum
FooEnum enumParam() default FooEnum.AnythingReally;
^
1 error


This problem also occurs with class wildcards. It doesn't occur with
the eclipse JDT compiler.

Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-10M3025)
Java HotSpot(TM) Client VM (build 14.3-b01-101, mixed mode)
javac 1.6.0_17, mac Snow Leopard. Also doesn't work on ubuntu linux
Sun VM 1.6.0_18 I believe

-------- TestAnnotations.java --------
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

public class TestAnnotations {
//Given an enum, a class, an interface, and an implementation of the
interface
public enum FooEnum {
AnythingReally;
}

//Make an annotation with wildcards
@Target( {ElementType.FIELD, METHOD} ) @Retention(RUNTIME)
public @interface FooAnnotation {
FooEnum enumParam() default FooEnum.AnythingReally;
}
}

Reinier Zwitserloot

unread,
Mar 18, 2010, 5:09:01 PM3/18/10
to Project Lombok
Yup, it's a known javac bug (known to us, anyway). It's not exactly
lombok that's at fault, it occurs when any annotation processor is
run. The workaround is to write FooEnum as a fully qualified name (so
package.name.FooEnum) in the value:

FooEnum enumParam() default package.name.FooEnum.

It's *really* annoying and we'll look into finding a way to fix this
ourselves in flying turtle.

Erem

unread,
Mar 18, 2010, 6:00:54 PM3/18/10
to Project Lombok
Thank you, Reinier. You have no idea the pain you just saved me.
Reply all
Reply to author
Forward
0 new messages