[
https://issues.apache.org/jira/browse/GROOVY-11624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17945028#comment-17945028
]
Saravanan edited comment on GROOVY-11624 at 4/17/25 11:28 PM:
--------------------------------------------------------------
This standard Groovy also fails with a similar error (it seems to fail only
when I do PART1 + PART2
Expected 'com.org.interfaces.Blah$Inner.MYSTRING' to be an inline constant of
type java.lang.String not a property expression in @java.lang.Deprecated
Attribute 'since' should have type 'java.lang.String'; but found type
'java.lang.Object' in @java.lang.Deprecated
{code:groovy}
class Blah {
@Deprecated(since = Inner.MYSTRING)
void myMethod() {
}
public static class Inner {
public static final String PART1 = "my";
public static final String PART2 = "string";
public static final String MYSTRING = PART1 + PART2;
}
}
{code}
was (Author: chavan77):
This also fails with a similar error (it seems to fail only when I do PART1 +
PART2
Expected 'com.org.interfaces.Blah$Inner.MYSTRING' to be an inline constant of
type java.lang.String not a property expression in @java.lang.Deprecated
Attribute 'since' should have type 'java.lang.String'; but found type
'java.lang.Object' in @java.lang.Deprecated
{code:java}
class Blah {
@Deprecated(since = Inner.MYSTRING)
void myMethod() {
}
public static class Inner {
public static final String PART1 = "my";
public static final String PART2 = "string";
public static final String MYSTRING = PART1 + PART2;
}
}
{code}
> 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 (pulled in as byte code from a jar dependency)
>
> {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. When I compile my groovy class with the
> java jar in the dependency path,
>
> {code:groovy}
> 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)