md-5 / SpecialSource

Automatic generator and renamer of jar obfuscation mappings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Records aren't mapped properly

opened this issue · comments

Classes that extend Record, implementing synthetic toString, hashCode, and/or equals, with the characteristic of this.method<invokedynamic>(...) under fernflower, require special mapping treatment to be used in a debug environment without remapping.

Assembly:

DEFINE PUBLIC FINAL hashCode()I
A:
LINE A 54
ALOAD this
INVOKEDYNAMIC hashCode (Lnet/minecraft/world/level/biome/BiomeSource$1FeatureData;)I handle[H_INVOKESTATIC java/lang/runtime/ObjectMethods.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/TypeDescriptor;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/Object;] args[Lnet/minecraft/world/level/biome/BiomeSource$1FeatureData;, "step;feature", handle[H_GETFIELD net/minecraft/world/level/biome/BiomeSource$1FeatureData.a I], handle[H_GETFIELD net/minecraft/world/level/biome/BiomeSource$1FeatureData.b Lnet/minecraft/world/level/levelgen/feature/ConfiguredFeature;]]
IRETURN
B:
C:

CFR:

package net.minecraft.world.level.biome;

import java.lang.invoke.MethodHandle;
import java.lang.runtime.ObjectMethods;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;

record BiomeSource$1FeatureData(int step, ConfiguredFeature<?, ?> feature) {
    @Override
    public final String toString() {
        return ObjectMethods.bootstrap("toString", new MethodHandle[]{BiomeSource$1FeatureData.class, "step;feature", "a", "b"}, this);
    }

    @Override
    public final int hashCode() {
        return (int)ObjectMethods.bootstrap("hashCode", new MethodHandle[]{BiomeSource$1FeatureData.class, "step;feature", "a", "b"}, this);
    }

    @Override
    public final boolean equals(Object object) {
        return (boolean)ObjectMethods.bootstrap("equals", new MethodHandle[]{BiomeSource$1FeatureData.class, "step;feature", "a", "b"}, this, object);
    }
}

I'm not sure how to approach pulling the old parent symbol to read the internal field cache. Duplicating put entries in the mappings loader with the alternative/new class symbol seems to work. https://pastebin.com/eqkMU6J0
image Seems to be stable

commented

Pull request?

Sure, lemme just rebase to master instead of the last release and test again

commented

Thanks