Paul King created GROOVY-11634:
----------------------------------

             Summary: ClassFormatError when property and abstract getter exist 
in the same class
                 Key: GROOVY-11634
                 URL: https://issues.apache.org/jira/browse/GROOVY-11634
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 4.0.26
            Reporter: Paul King


I was exploring workarounds for GROOVY-11633 and spotted this:
{code:groovy}
abstract class MyTask {
    final Integer foo = 0
    abstract final Integer getFoo()
}
{code}
The following exception is thrown during compilation:
{noformat}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during instruction selection: java.lang.ClassFormatError: Method 
getFoo in class MyTask has illegal modifiers: 0x411

java.lang.RuntimeException: java.lang.ClassFormatError: Method getFoo in class 
MyTask has illegal modifiers: 0x411
        at 
org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:972)
        at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:692)
        at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:666)
        at 
groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:365)
        at 
groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:314)
        at 
org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
        at 
org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
        at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314)
        at groovy.lang.GroovyShell.parseClass(GroovyShell.java:572)
        at groovy.lang.GroovyShell.run(GroovyShell.java:392)
        at groovy.lang.GroovyShell.run(GroovyShell.java:382)
        at groovy.ui.GroovyMain.processOnce(GroovyMain.java:649)
        at groovy.ui.GroovyMain.run(GroovyMain.java:389)
        at groovy.ui.GroovyMain.access$1400(GroovyMain.java:67)
        at groovy.ui.GroovyMain$GroovyCommand.process(GroovyMain.java:313)
        at groovy.ui.GroovyMain.processArgs(GroovyMain.java:141)
        at groovy.ui.GroovyMain.main(GroovyMain.java:114)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:569)
        at 
org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:115)
        at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:37)
Caused by: java.lang.ClassFormatError: Method getFoo in class MyTask has 
illegal modifiers: 0x411
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
        at 
java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
...
{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to