You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

BiPredicate lambda触发java.lang.VerifyError操作数栈类型错误如何修复?

不知为何程序报错提示Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'java/lang/Boolean',可确定BiPredicate中不存在任何返回Object的逻辑,且报错时相关代码甚至还未被调用。尝试进行调试后发现所有断点都无法命中,即便是构造方法上的断点也没有触发。

对应静态字段初始化代码如下:

public static SlotType<SlotInput> IT_IN = new SlotType<>("item_in", (type, gui, inv, i, d) -> new SlotInput(type, gui, inv.getOrDefault(type, new EmptyHandler()), i, d.getX(), d.getY()), (t, i) -> {
        if (t instanceof TileEntityMachine) {
            return (((TileEntityMachine<?>) t).recipeHandler.map(rh -> rh.accepts(i)).orElse(true));
        }
        return true;
    }, ContentEvent.ITEM_INPUT_CHANGED, true, false);

崩溃看起来是在类加载阶段就直接触发的,报错信息和上述提示一致。
SlotType类构造方法代码如下:

public SlotType(String id, ISlotSupplier<T> slotSupplier, BiPredicate<IGuiHandler, ItemStack> validator, ContentEvent ev, boolean input, boolean output) {
        this.id = id;
        this.slotSupplier = slotSupplier;
        this.output = output;
        this.tester = validator;
        this.input = input;
        this.ev = ev;
        AntimatterAPI.register(SlotType.class, this);
    }

问题更新

将IT_IN对应的lambda替换为BiPredicate的自定义实现后,崩溃就停止了,但其他同类型lambda都能正常运行,现象非常奇怪。

内容的提问来源于stack exchange,提问作者Trinsdar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 20:36:00