Christopher Smith created GROOVY-11079:
------------------------------------------
Summary: GroovyCastException on closure implementing Consumer
Key: GROOVY-11079
URL: https://issues.apache.org/jira/browse/GROOVY-11079
Project: Groovy
Issue Type: Bug
Components: Static compilation
Affects Versions: 4.0.12
Reporter: Christopher Smith
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?
{code}
loadOriginal(ep.payload)
.onSuccess { sps.envelope.filename = it._1 } // exception thrown at the end
of this closure
.<PDDocument> map(Tuple2::_2)
{code}
{code}
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)
{code}
{code}
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
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)