繁体   English   中英

BiPredicate lambda 导致 java.lang.VerifyError: 操作数堆栈上的类型错误,我该如何解决?

[英]BiPredicate lambda is causing a java.lang.VerifyError: Bad type on operand stack, how do I fix this?

出于某种原因,它说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);

似乎一旦类加载它就会因错误而崩溃

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);
    }

这是 GitHub 上该课程的链接: https : //github.com/GregTech-Intergalactical/AntimatterAPI/blob/dev/src/main/java/muramasa/antimatter/gui/SlotType.java哦,这里是完整的崩溃参考: https : //gist.github.com/Trinsdar/bba054869f1c565a32d61bb60cc31bda

更新:将 IT_IN 中的 lambda 更改为 BiPredicate 的自定义实现似乎已导致它停止崩溃,但所有其他的都很好,真的很奇怪。

似乎这绝对是 java 8 的问题,特别是它的编译器。 我设法通过将 BiPredicate lambda 更改为实现 lambda 中的代码的 BiPredicate 的自定义实例来阻止错误,尽管我会提到我不知道为什么其他 9 个字段没有问题。 这也可以通过简单地使用 java 11 来解决,尽管这对于像 jitpack 这样的东西来说不是一个简单的替代方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM