I'm running Eclipse Kepler SR2, with Maven 3.1.1 attached with the m2e and m2e-apt plugins, and I'm getting an error I don't know how to resolve.
I managed to find all the dependencies needed to get @AutoValue
working into my pom.xml, but now I'm in a state where it only works if the methods which need to be defined all have primitive return types. If I provide an abstract getter which returns an Object
or more specific, I get this error:
@AutoValue processor threw an exception:
java.lang.IllegalArgumentException:
Failed to invoke com.google.auto.value.processor.AutoValueProcessor$Property.nullable() on getObject...
I've tried the basics - cleared the maven cache, restarted Eclipse, rebuilt the project... no dice. So I dug down into the source code and I found a discrepancy which I'm not sure how it's intended to be resolved.
In the Velocity template for the generated AutoValue class, there is some basic logic for rendering primitives differently than objects, for instance on line 37, p.nullable
is checked. The p
variable is an instance of AutoValueProcessor$Property
class, which, as can be seen on line 205 of the preceeding link, has an isNullable()
method, but no nullable
method or property.
How is the Velocity rendering phase intended to work then? Does Velocity auto-expand p.nullable
to p.isNullable
some how, but not for me because reasons? Is this a bug? I'm not sure what to do from here.
Example class that doesn't compile:
@AutoValue
public abstract class Point {
public static Point of(double x, double y) {
return new AutoValue_Point(x, y);
}
public abstract Double x();
public abstract Double y();
}
Eclipse highlights the described error under Point
at the head of the class declaration.