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

GroovyCastException on closure implementing Consumer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.12
    • 4.0.13
    • Static compilation
    • None

    Description

      I'm having trouble making a minimal repro for this one, but here's the actual code. Libraries are PDFBox (PDDocument) and Vavr. The bytecode problem seems to be that although 31 pushes null onto the stack, it's popped before being cast to Void, leaving the String on top. Shouldn't these be reversed?

      loadOriginal(ep.payload)
        .onSuccess { sps.envelope.filename = it._1 }  // exception thrown at the end of this closure
        .<PDDocument> map(Tuple2::_2)
      
      org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'dummy.pdf' with class 'java.lang.String' to class 'java.lang.Void'
      	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:424)
      	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:335)
      	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:255)
      	at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
      	at com.example.EsignFinisherImpl$_notifySignatureApplied_closure2$_closure11.doCall(EsignFinisherImpl.groovy:70)
      
        public java.lang.Void doCall(java.lang.Object);
          descriptor: (Ljava/lang/Object;)Ljava/lang/Void;
          flags: (0x0001) ACC_PUBLIC
          Code:
            stack=3, locals=3, args_size=2
               0: aload_1
               1: checkcast     #35                 // class io/vavr/Tuple2
               4: getfield      #38                 // Field io/vavr/Tuple2._1:Ljava/lang/Object;
               7: dup
               8: astore_2
               9: aload_0
              10: getfield      #27                 // Field sps:Lgroovy/lang/Reference;
              13: invokevirtual #44                 // Method groovy/lang/Reference.get:()Ljava/lang/Object;
              16: checkcast     #46                 // class SignaturePageSpec
              19: invokevirtual #50                 // Method SignaturePageSpec.getEnvelope:()LSignaturePageSpec$Envelope;
              22: aload_2
              23: invokedynamic #64,  0             // InvokeDynamic #0:cast:(Ljava/lang/Object;)Ljava/lang/String;
              28: invokevirtual #70                 // Method SignaturePageSpec$Envelope.setFilename:(Ljava/lang/String;)V
              31: aconst_null
              32: pop
              33: invokedynamic #72,  0             // InvokeDynamic #0:cast:(Ljava/lang/Object;)Ljava/lang/Void;
              38: areturn
      

      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: