CadixDev / Mercury

A source transformation and -remapping framework for Java.
Eclipse Public License 2.0
54 stars 23 forks source link

Binding resolution problem #7

Closed Chocohead closed 4 years ago

Chocohead commented 4 years ago

I've been attempting to make a simple test case to try some things out, but I can't get Mercury to play ball. Having stepped through the debugger it appears JDT can't find the bindings for any of the inputs, so any binding#getDeclaringClass() returns null in SimpleRemapperVisitor. Any help or general pointers to why it doesn't want to work would be much appreciated.

I've been using the following code (along with the latest dependencies pulled from the repo), with the attached files:

    private static final Path STUFF = Paths.get("<path/to/files>");

    public static void main(String[] args) throws Exception {
        Path input = STUFF.resolve("forge");
        assert Files.isDirectory(input);
        Path output = STUFF.resolve("output");

        Mercury mercury = new Mercury();

        Path classpath = STUFF.resolve("AnvilBlockAlso.jar");
        assert Files.isRegularFile(classpath);
        mercury.getClassPath().add(classpath);
        mercury.getProcessors().add(MercuryRemapper.create(makeMappings()));

        mercury.rewrite(input, output);
    }

    private static MappingSet makeMappings() {
        MappingSet out = MappingSet.create();

        //Just some mappings to exist for Mercury to find
        ClassMapping<?, ?> classMapping = out.getOrCreateClassMapping("AnvilBlockAlso");
        MethodMapping methodMapping = classMapping.getOrCreateMethodMapping("test", "(IDJII)V");
        methodMapping.setDeobfuscatedName("goodTest");

        return out;
    }
Chocohead commented 4 years ago

Not entirely sure what was wrong last night but after a little bit more tinkering it's fine now.