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

AIOOBE when using method reference in nested lambda

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.11
    • 3.0.18, 4.0.12
    • Static compilation
    • None

    Description

      When using (1) the method-reference operator (but not the method-closure operator) (2) inside a nested lambda, the STC throws an AIOOBE.

      @Grapes([
          @Grab(group = 'software.amazon.awssdk', module = 'utils', version = '2.18.31'),
          @Grab(group = 'io.vavr', module = 'vavr', version = '0.10.3'),
      ])
      @CompileStatic
      class Bug {
          Object bug() {
              Try.success('1234')
                  .flatMap {
                      Try.success(it)
                          .map(StringInputStream::new)
                  }
          }
      }
      
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      General error during instruction selection: Internal compiler error while compiling Bug.groovy
      Method: org.codehaus.groovy.ast.MethodNode@782bf610[software.amazon.awssdk.utils.StringInputStream ctorRef$doCall$0(java.lang.String) from Bug$_bug_closure1]
      Line -1, expecting casting to software.amazon.awssdk.utils.StringInputStream but operand stack is empty
      
      java.lang.ArrayIndexOutOfBoundsException: Internal compiler error while compiling Bug.groovy
      Method: org.codehaus.groovy.ast.MethodNode@782bf610[software.amazon.awssdk.utils.StringInputStream ctorRef$doCall$0(java.lang.String) from Bug$_bug_closure1]
      Line -1, expecting casting to software.amazon.awssdk.utils.StringInputStream but operand stack is empty
              at org.codehaus.groovy.classgen.asm.OperandStack.throwExceptionForNoStackElement(OperandStack.java:335)
              at org.codehaus.groovy.classgen.asm.OperandStack.doConvertAndCast(OperandStack.java:340)
              at org.codehaus.groovy.classgen.asm.OperandStack.doGroovyCast(OperandStack.java:305)
              at org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:593)
              at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:812)
              at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:73)
              at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:601)
              at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:546)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
              at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:685)
              at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1142)
              at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1124)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
              at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:365)
              at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:797)
              at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:814)
              at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:937)
              at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:692)
              at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:666)
              at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:647)
              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:109)
              at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:132)
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              chrylis Christopher Smith
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: