微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我可以使用 Implementation.Composable#andThen() 将 InvokeDynamic 与 FixedValue 组合在一起吗?

如何解决我可以使用 Implementation.Composable#andThen() 将 InvokeDynamic 与 FixedValue 组合在一起吗?

我正在 ByteBuddy 中“手动”构建一个方法。我正在构建的方法一个 this.route.queryParams.pipe( switchMap(({id}) => { return this.formService.getFormFieldValById(id); }) ).subscribe(res => { // bind response to form }) 类型的参数。假设它看起来像这样:

ProductType

在该方法中,我正在构建相当于:

public ProductType frob(ProductType product) {
  // stuff that I'm implementing and asking about goes here
}

当我像这样构建 product.foo(); // more on this below; foo() has a void return type,which may be important return product; // FixedValue.argument(0) 时,这很好用:

Implementation

(希望我输入正确。)

但是,如果我像这样构建一个 MethodCall.invoke(fooMethodDescription) // invoke foo()... .onArgument(0) // ...on product... .andThen(FixedValue.argument(0)); // ...and then return product

Implementation

...当然,如果使用正确的 InvokeDynamic.bootstrap(...) // look up foo()'s MethodHandle via my bootstrap method... .invoke("foo",TypeDescription.VOID) // ...invoke the method handle with a return type of void... .withArgument(0) // ..."on" the first and only argument (product) and "with" no other arguments... .andThen(FixedValue.argument(0)); // ...and then return product 配方,由于 InvokeDynamic 错误 (Operand stack underflow) 导致无法验证生成的类。

我有一个类似的 Attempt to pop empty stack 配方,在其他地方的很多地方都使用过,所以我知道我的问题不在于 InvokeDynamic用法。相反,它似乎与作曲有关?可能是?尽管 InvokeDynamicMethodCall 都是 InvokeDynamic,但它们的行为是否可能不同?也许 Implementation 不会在操作数堆栈上压入一些东西(也许只是在 InvokeDynamic 返回的情况下?)而 void 会吗?我在 MethodCall 用法中遗漏了什么?

使用 ByteBuddy 1.11.2。

解决方法

正如您正确指出的,这是 Byte Buddy 中的一个错误,现已修复。感谢那。它将随 1.11.3 版本一起发布。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。