[
https://issues.apache.org/jira/browse/GROOVY-11805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18039921#comment-18039921
]
Ed T commented on GROOVY-11805:
-------------------------------
the interesting part is that, if you didn't use GroovyShell and
GroovyClassLoader, and simply just wrote the code directly within the script,
the error doesn't happen. Something is also unique here with the use of
GroovyShell and GroovyClassLoader.
> Groovy5 compiler throws exception:
> "org.codehaus.groovy.ast.ClassNode.getGenericsTypes()" is null
> -------------------------------------------------------------------------------------------------
>
> Key: GROOVY-11805
> URL: https://issues.apache.org/jira/browse/GROOVY-11805
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 5.0.2
> Reporter: Ed T
> Assignee: Eric Milles
> Priority: Major
> Fix For: 5.0.3
>
>
> Compiler chokes on the following script. The code runs on JDK25 with Groovy
> 5.0.2.
>
> {code:java}
> interface BadBoy<T extends BadBoy<?>> {
> void doBadThing()
> }
> class MyBadBoy implements BadBoy<MyBadBoy> {
> void doBadThing() {
> println "bad thing!"
> }
> }
> class CreateBadThings {
> public static BadBoy<?> badThings(Closure cls) {
> println "bad things happened!"
> }
> }
> def classLoader = new GroovyClassLoader(this.class.getClassLoader())
> def shell = new GroovyShell(classLoader)
> def code = '''
> import static CreateBadThings.badThings
> badThings {
> }
> '''
> def compileAndRun(code, shell) {
> def script = shell.parse(code)
> script.run()
> }
> compileAndRun(code, shell) {code}
> It emits this error message.
> {code:java}
> BUG! exception in phase 'semantic analysis' in source unit 'Script1.groovy'
> unexpected NullPointerException
> at ConsoleScript9.compileAndRun(ConsoleScript9:29)
> at ConsoleScript9.run(ConsoleScript9:33)
> Caused by: java.lang.NullPointerException: Cannot load from object array
> because the return value of
> "org.codehaus.groovy.ast.ClassNode.getGenericsTypes()" is null{code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)