Description
Java 17 (at least as of EA31) is now emitting "PermittedSubclasses" attributes for certain enum classes. When groovyc 3.0.8 encounters these, it crashes with an UnsupportedOperationException.
Test case:
AnEnum.java
public enum AnEnum { ONE() { @Override public String digit() { return "1"; } }; public abstract String digit(); }
Foo.groovy
import AnEnum
Compile them...
$ jdk-17/bin/javac AnEnum.java $ JAVA_HOME=jdk-17 groovy-3.0.8/bin/groovyc Foo.groovy >>> a serious error occurred: BUG! exception in phase 'semantic analysis' in source unit 'Foo.groovy' PermittedSubclasses requires ASM9 >>> stacktrace: BUG! exception in phase 'semantic analysis' in source unit 'Foo.groovy' PermittedSubclasses requires ASM9 at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:905) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:610) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189) 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:568) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:111) at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:129) Caused by: java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9 at groovyjarjarasm.asm.ClassVisitor.visitPermittedSubclass(ClassVisitor.java:266) at groovyjarjarasm.asm.ClassReader.accept(ClassReader.java:683) at groovyjarjarasm.asm.ClassReader.accept(ClassReader.java:401) at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81) at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:251) at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:189) at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:169) at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:125) at org.codehaus.groovy.control.ResolveVisitor.resolveToOuter(ResolveVisitor.java:869) at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:505) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1430) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:261) at org.codehaus.groovy.control.CompilationUnit.lambda$new$16(CompilationUnit.java:738) at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:901) ... 13 more
Attachments
Issue Links
- relates to
-
GROOVY-10154 Bump asm to 9.2
- Closed