holic87
holic87

Reputation: 791

Java compile error in Ant: using class literals in annotations

I have the following Java annotation on a class (it's for a myBatis plugin):

@Intercepts({ @Signature(type = ResultSetHandler.class, method = "handleResultSets", args = (Statement.class)) })
public class MyResultSetHandlerPlugin implements Interceptor {
    //do stuff...
}

It compiles and works fine in Eclipse, but when trying to run an Ant build script, I get the following error:

[javac] C:CLIP_PoC\src\com\lmig\am\claims\clip\MyPResultSetHandlerPlugin.java:27: annotation value must be a class literal
    [javac] @Intercepts({ @Signature(type = ResultSetHandler.class, method = "handleResultSets", args = (Statement.class)) })
    [javac]                                                                                             ^
    [javac] 1 error

I've tried fully qualifying the classes used in the annotation, but that results in the same error. Any thoughts on what I'm doing wrong?

Thanks.

Upvotes: 0

Views: 536

Answers (1)

Edwin Buck
Edwin Buck

Reputation: 70909

If you are attempting to pass an array of items as an annotation parameter, you need to use curly braces, not parenthesis to indicate that the item is an array.

@Intercepts({ @Signature(type = ResultSetHandler.class, method = "handleResultSets", args = {Statement.class}) })

Upvotes: 2

Related Questions