Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8204

@Delegate on arrays causes NPE during compilation

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.11
    • 2.4.12
    • None
    • None

    Description

      I have stumbled upon this bug partly by accident, and I'm not convinced it's a valid use case, but either way it should not crash the compiler with a NPE.

      Trying to compile the following simple class:

      import groovy.lang.Delegate
      
      class BugsMe {
      
      	@Delegate
      	byte[] file
      }
      

      Results in the following exception:

      >>> a serious error occurred: BUG! exception in phase 'canonicalization' in source unit 'BugsMe.groovy' unexpected NullpointerException
      >>> stacktrace:
      BUG! exception in phase 'canonicalization' in source unit 'BugsMe.groovy' unexpected NullpointerException
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1070)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
      	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:537)
      	at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:61)
      	at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:217)
      	at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:150)
      	at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:180)
      	at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:164)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
      	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
      Caused by: java.lang.NullPointerException
      	at org.codehaus.groovy.ast.ClassHelper.getNextSuperClass(ClassHelper.java:454)
      	at org.codehaus.groovy.ast.ClassHelper.getNextSuperClass(ClassHelper.java:449)
      	at org.codehaus.groovy.ast.tools.GenericsUtils.extractSuperClassGenerics(GenericsUtils.java:444)
      	at org.codehaus.groovy.transform.DelegateASTTransformation.addDelegateMethod(DelegateASTTransformation.java:233)
      	at org.codehaus.groovy.transform.DelegateASTTransformation.visit(DelegateASTTransformation.java:129)
      	at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:134)
      	at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:178)
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
      	... 15 more
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            paulk Paul King
            kszafran Krzysztof SzafraƄski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment