[ https://issues.apache.org/jira/browse/GROOVY-7854?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-7854. ----------------------------- > Annotation value cannot be concatenated constant > ------------------------------------------------ > > Key: GROOVY-7854 > URL: https://issues.apache.org/jira/browse/GROOVY-7854 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation > Affects Versions: 2.4.6 > Environment: - OS X > - Java(TM) SE Runtime Environment (build 1.8.0_66-b17) > - IntelliJ Idea 14 CE \w Groovy plugin > - Gradle 2.2 > Reporter: Simo Tuokko > Assignee: Paul King > Priority: Major > Fix For: 3.0.0-alpha-4, 2.5.4 > > > Following code as .java class works ok: > {code:title=UserDAO.java|borderStyle=solid} > public abstract class UserDAO { > public static final String Select_User_join_Addresses_Features_Images = > "select "+ > "u.*, a.*, f.*, i.* "+ > "from users u "+ > "left outer join addresses a on (u.id = a.user_id) "+ > "left outer join userfeatures f on (u.id = f.user_id) "+ > "left outer join images i on (u.id = i.user_id) "; > public static final String Select_User_by_id = > Select_User_join_Addresses_Features_Images + "where u.id = :id"; > public static final String Select_User_by_email = > Select_User_join_Addresses_Features_Images + "where u.email = > lower(:email)"; > @SqlQuery(Select_User_by_id) > abstract FoldingList<User> findById(@Bind("id") long id); > } > {code} > However if I write and compile it as Groovy, I get "Expected > 'UserDAO.Select_User_by_id' to be an inline constant of type java.lang.String > not a property expression" error from compiler. > Also if works if those constant String are in separate .java class that is > accessed from annotation (within a .groovy class), but not if they are in > separate .groovy file. > So the difference seems to be that constant strings are not concatenated at > compile-time in Groovy, but in Java they are? Is this by design or is it a > bug that can be fixed? -- This message was sent by Atlassian JIRA (v7.6.3#76005)