[
https://issues.apache.org/jira/browse/GROOVY-11805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18039895#comment-18039895
]
Eric Milles commented on GROOVY-11805:
--------------------------------------
When the vmplugin (aka {{Java8}}) is trying to configure the type variable
{{T}} of {{BadBoy}}, it is checking that the bound type for {{?}} is not
{{Object}}. But the generics have not been set on the class yet.
If you specify "interface BadBoy<T extends BadBoy> {" this should not happen.
> 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
>
> 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)