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

Viewed 86

For some reason, it's saying Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'java/lang/Boolean', yet I'm pretty sure it's not returning an Object anywhere in the BiPredicate, not that the code would be called yet anyways. I've tried debugging it, haven't had any luck getting debug points to hit, even a debug point on the constructor didn't get hit.

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

seems as soon as the class loads it crashes with the error

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

here is the link to the class on GitHub: https://github.com/GregTech-Intergalactical/AntimatterAPI/blob/dev/src/main/java/muramasa/antimatter/gui/SlotType.java oh and here's the full crash for reference: https://gist.github.com/Trinsdar/bba054869f1c565a32d61bb60cc31bda

Update: changing the lambda in IT_IN to a custom implementation of BiPredicate seems to have caused it to stop crashing, all the others though are just fine, really weird.

1 Answers

Seems it is definitely an issue with java 8, specifically with it's compiler. I managed to stop the errors by changing the BiPredicate lambda to a custom instance of BiPredicate that implements the code in the lambda, though I will mention I have no idea why the other 9 fields have no issues. This is also fixed by simply using java 11, though that's not an easy alternative for something like jitpack.

Related