[ https://issues.apache.org/jira/browse/GROOVY-11624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17945447#comment-17945447 ]
Eric Milles commented on GROOVY-11624: -------------------------------------- Due to fix for GROOVY-5150, GROOVY-10902, GROOVY-10928, GROOVY-11019 the Java stub of Interfaces is written out as: {code:java} import static com.org.nativecompiler.cli.MyDefinitionInJava.MYTEXTINJAVA; public interface Interfaces { String OTHERTEXT = new String(MYTEXTINJAVA + "1234"); @Deprecated(since = OTHERTEXT) public interface InnerClass { } } {code} It is javac that gives the error "error: element value must be a constant expression". Assuming I can get past this, it is StaticImportVisitor that replaces MYTEXTINJAVA with a variable reference. After that, the constant can be inlined by Verifier. I'll have to see where StaticCompilationVisitor replaces `MYTEXTINJAVA + "1234"` with `MYTEXTINJAVA.plus("1234")`. > Unable to use statically imported const string in annotation > ------------------------------------------------------------ > > Key: GROOVY-11624 > URL: https://issues.apache.org/jira/browse/GROOVY-11624 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation > Affects Versions: 5.0.0-alpha-12 > Reporter: Saravanan > Assignee: Eric Milles > Priority: Minor > > I have a java class defined > > {code:java} > package com.org.nativecompiler.cli; > public final class MyDefinitionInJava { > public static final String MYTEXTINJAVA = "asdsad"; > } > {code} > I am using this in my Groovy class > > {code:java} > import static com.org.nativecompiler.cli.MyDefinitionInJava.MYTEXTINJAVA; > public interface Interfaces { > String OTHERTEXT = MYTEXTINJAVA + "1234"; > @Deprecated(since = OTHERTEXT) > public interface InnerClass { > } > } > {code} > I get a compile error (in comple static mode) in the use of OTHERTEXT > Expected > 'com.org.nativecompiler.cli.MyDefinitionInJava.MYTEXTINJAVA.plus(1234)' to be > an inline constant of type java.lang.String in @java.lang.Deprecated > This seems to be an issue only if I static import it. This works if I use > MyDefintionInJava.MYTEXTINJAVA directly -- This message was sent by Atlassian Jira (v8.20.10#820010)