[
https://issues.apache.org/jira/browse/GROOVY-11019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jason Garrett updated GROOVY-11019:
-----------------------------------
Description:
I haven't managed to reproduce this in a simple example, but as I'm upgrading
my application from groovy 3 to 4 I have run into this situation. I have a
class that defines a public static final string like this:
{code:java}
class PublicStaticString {
public static final String NONE = "None"
}
{code}
Its java stub fails to compile with:
{noformat}
error: no suitable constructor found for String(Object)
public static final java.lang.String NONE = new
java.lang.String((java.lang.Object)null);{noformat}
I can remove the "public" from the declaration and the class/stub will compile,
but now any java class that references that field will fail to compile with:
{noformat}
error: NONE has private access in PublicStaticString
selectNoneButton.setText(PublicStaticString.NONE);{noformat}
The only way I know to fix this is to convert the java class to groovy.
was:
I haven't managed to reproduce this in a simple example, but as I'm upgrading
my application from groovy 3 to 4 I have run into this situation. I have a
class that defines a public static final string like this:
{code:java}
class PublicStaticString {
public static final String NONE = "None"
}
{code}
Its java stub fails to compile with:
{noformat}
error: no suitable constructor found for String(Object)
public static final java.lang.String NONE = new
java.lang.String((java.lang.Object)null);{noformat}
Priority: Major (was: Minor)
> joint compilation: public static final string does not compile
> ---------------------------------------------------------------
>
> Key: GROOVY-11019
> URL: https://issues.apache.org/jira/browse/GROOVY-11019
> Project: Groovy
> Issue Type: Bug
> Components: Stub generator / Joint compiler
> Affects Versions: 4.0.11
> Environment: OpenJDK Runtime Environment Temurin-11.0.16.1+1 (build
> 11.0.16.1+1)
> Reporter: Jason Garrett
> Priority: Major
>
> I haven't managed to reproduce this in a simple example, but as I'm upgrading
> my application from groovy 3 to 4 I have run into this situation. I have a
> class that defines a public static final string like this:
> {code:java}
> class PublicStaticString {
> public static final String NONE = "None"
> }
> {code}
> Its java stub fails to compile with:
> {noformat}
> error: no suitable constructor found for String(Object)
> public static final java.lang.String NONE = new
> java.lang.String((java.lang.Object)null);{noformat}
>
> I can remove the "public" from the declaration and the class/stub will
> compile, but now any java class that references that field will fail to
> compile with:
> {noformat}
> error: NONE has private access in PublicStaticString
> selectNoneButton.setText(PublicStaticString.NONE);{noformat}
> The only way I know to fix this is to convert the java class to groovy.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)