use of org.codehaus.groovy.classgen.BytecodeInstruction in project groovy by apache.
the class StaticTypesLambdaWriter method addDeserializeLambdaMethodForEachLambdaExpression.
private void addDeserializeLambdaMethodForEachLambdaExpression(final LambdaExpression expression, final ClassNode lambdaClass) {
ClassNode enclosingClass = controller.getClassNode();
Statement code = block(new BytecodeSequence(new BytecodeInstruction() {
@Override
public void visit(final MethodVisitor mv) {
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ICONST_0);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/SerializedLambda", "getCapturedArg", "(I)Ljava/lang/Object;", false);
mv.visitTypeInsn(CHECKCAST, BytecodeHelper.getClassInternalName(lambdaClass));
OperandStack operandStack = controller.getOperandStack();
operandStack.push(lambdaClass);
}
}), returnS(expression));
enclosingClass.addSyntheticMethod(createDeserializeLambdaMethodName(lambdaClass), ACC_PUBLIC | ACC_STATIC, OBJECT_TYPE, createDeserializeLambdaMethodParams(), ClassNode.EMPTY_ARRAY, code);
}
Aggregations