[
https://issues.apache.org/jira/browse/GROOVY-11614?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17997761#comment-17997761
]
Saravanan edited comment on GROOVY-11614 at 7/5/25 11:37 AM:
-------------------------------------------------------------
I think the difference between your code and mine is that you have
@CompileStatic on the class while I am applying it on the compiler
configuration like this (Excuse the kotlin code style). I am adding a
compilation customizer to apply CompileStatic to all classes
{code:java}
GroovyClassLoader(
TestRecordsPlugin::class.java.classLoader,
CompilerConfiguration().also {
it.setTargetDirectory("/tmp/groovy/")
it.addCompilationCustomizers(ASTTransformationCustomizer(CompileStatic::class.java))
}
).also {
it.parseClass(File("testdata/plugins/records/RecordTesting.java"))
} {code}
Sure enough if I add CompileStatic to the class, it works as expected. How do I
continue to apply CompileStatic for everything?
was (Author: chavan77):
I think the difference between your code and mine is that you have
@CompileStatic on the class while I am applying it on the compiler
configuration like this (Excuse the kotlin code style). I am adding a
compilation customizer to apply CompileStatic to all classes
{code:java}
GroovyClassLoader(
TestRecordsPlugin::class.java.classLoader,
CompilerConfiguration().also {
it.setTargetDirectory("/tmp/groovy/")
it.addCompilationCustomizers(ASTTransformationCustomizer(CompileStatic::class.java))
}
).also {
it.parseClass(File("testdata/plugins/records/RecordTesting.java"))
} {code}
> Enums in switch/case statements that are not fully qualified will cause a
> groovy compile error but Java requires enums to "not" be fully qualified
> --------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-11614
> URL: https://issues.apache.org/jira/browse/GROOVY-11614
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 4.0.24, 5.0.0-alpha-12
> Reporter: Saravanan
> Assignee: Paul King
> Priority: Minor
> Fix For: 5.0.0-beta-1, 4.0.27
>
>
> This is a difference in Java vs Groovy behaviour. Enums must be fully
> qualified in Groovy while Java requires them to not be fully qualified.
> -This was supposedly fixed, but does not seem to work in 4.0.24. Not sure
> where it broke.-
> Example:
> {code:groovy}
> void test(Thread.State ts) {
> switch (ts) {
> case Thread.State.NEW: // cannot remove "Thread.State." without
> @CompileStatic
> break
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)