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

AIOOBE with Java lambda syntax

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.9
    • 3.0.18, 4.0.13
    • Static compilation
    • None

    Description

      This bug may have something to do with the overload-selection challenges discussed previously, but I don't remember an actual internal exception before.

      When using Vavr Try, several of the methods have overloads that accept either Runnable or Consumer<T>. Using a Groovy-syntax lambda with an explicit parameter can result in erroneous selection of Runnable (covered elsewhere), but using a Java-syntax lambda apparently results in the same erroneous selection with a crash instead of a meaningful error.

      Try.<Val> success(someValue)
        .andThen((Val result) -> { println result }) // should be unambiguously Consumer<Val>
      

      produces

      [ERROR] Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.13.1:compile (default) on project azimuth-server: Error occurred while calling a method on a Groovy class from classpath.: InvocationTargetException: startup failed:
      [ERROR] General error during instruction selection: Index 0 out of bounds for length 0
      [ERROR] 
      [ERROR] java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.createParametersWithExactType(StaticTypesLambdaWriter.java:296)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.addSyntheticLambdaMethodNode(StaticTypesLambdaWriter.java:274)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.createLambdaClass(StaticTypesLambdaWriter.java:251)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.lambda$getOrAddLambdaClass$2(StaticTypesLambdaWriter.java:216)
      [ERROR]         at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.getOrAddLambdaClass(StaticTypesLambdaWriter.java:215)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.writeLambda(StaticTypesLambdaWriter.java:118)
      [ERROR]         at org.codehaus.groovy.classgen.AsmClassGenerator.visitLambdaExpression(AsmClassGenerator.java:873)
      [ERROR]         at org.codehaus.groovy.ast.expr.LambdaExpression.visit(LambdaExpression.java:46)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.visitArgument(StaticInvocationWriter.java:512)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.loadArguments(StaticInvocationWriter.java:459)
      [ERROR]         at org.codehaus.groovy.classgen.asm.InvocationWriter.writeDirectMethodCall(InvocationWriter.java:213)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.writeDirectMethodCall(StaticInvocationWriter.java:385)
      [ERROR]         at org.codehaus.groovy.classgen.asm.InvocationWriter.makeDirectCall(InvocationWriter.java:311)
      [ERROR]         at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:131)
      [ERROR]         at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:125)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.makeCall(StaticInvocationWriter.java:647)
      [ERROR]         at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:454)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.writeInvokeMethod(StaticInvocationWriter.java:135)
      [ERROR]         at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:988)
      [ERROR]         at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:77)
      [ERROR]         at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:613)
      [ERROR]         at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:827)
      [ERROR]         at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
      [ERROR]         at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:95)
      [ERROR]         at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77)
      [ERROR]         at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:752)
      [ERROR]         at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
      [ERROR]         at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:611)
      [ERROR]         at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:546)
      [ERROR]         at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
      [ERROR]         at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:695)
      [ERROR]         at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1131)
      [ERROR]         at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1124)
      [ERROR]         at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
      [ERROR]         at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:365)
      [ERROR]         at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:797)
      [ERROR]         at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:937)
      [ERROR]         at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:692)
      [ERROR]         at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:666)
      [ERROR]         at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:647)
      [ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      [ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      [ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      [ERROR]         at org.codehaus.gmavenplus.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:212)
      [ERROR]         at org.codehaus.gmavenplus.mojo.AbstractCompileMojo.doCompile(AbstractCompileMojo.java:334)
      [ERROR]         at org.codehaus.gmavenplus.mojo.CompileMojo.execute(CompileMojo.java:70)
      

      This may be a duplicate if the correct resolution is "enhance the overload-selection logic to pick the most suitable one at an earlier stage".

      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: