[ 
https://issues.apache.org/jira/browse/GROOVY-11634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17946495#comment-17946495
 ] 

Eric Milles edited comment on GROOVY-11634 at 4/22/25 5:54 PM:
---------------------------------------------------------------

Do you want me to take care of this?  {{ClassCompletionVerifier}} should check 
this: 
https://github.com/apache/groovy/blob/d77d909df28896a21fe4958a201f98c891d5cb51/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java#L550


was (Author: emilles):
Do you want me to take care of this?  `ClassCompletionVerifier` should check 
this: 
https://github.com/apache/groovy/blob/d77d909df28896a21fe4958a201f98c891d5cb51/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java#L550

> 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
>            Priority: Major
>
> 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}
> Abstract and final don't make sense to be together, but we should have a 
> better error message.



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

Reply via email to