diff --git a/buildscript/src/main/java/Buildscript.java b/buildscript/src/main/java/Buildscript.java index 9e21a6a9..9d46c43d 100644 --- a/buildscript/src/main/java/Buildscript.java +++ b/buildscript/src/main/java/Buildscript.java @@ -277,7 +277,7 @@ protected List createDependencies() { public final BJavaModule recombobulator = new BJavaModule() { @Override MavenId getId() { - return new MavenId(GROUP, "recombobulator", "0.4"); + return new MavenId(GROUP, "recombobulator", "0.5"); } @Override diff --git a/recombobulator/src/main/java/io/github/coolcrabs/brachyura/recombobulator/Recombobulator.java b/recombobulator/src/main/java/io/github/coolcrabs/brachyura/recombobulator/Recombobulator.java index e8b64e13..e1870265 100644 --- a/recombobulator/src/main/java/io/github/coolcrabs/brachyura/recombobulator/Recombobulator.java +++ b/recombobulator/src/main/java/io/github/coolcrabs/brachyura/recombobulator/Recombobulator.java @@ -4,6 +4,6 @@ public class Recombobulator { private Recombobulator() { } public static String getVersion() { - return "0.4"; + return "0.5"; } } diff --git a/recombobulator/src/main/java/io/github/coolcrabs/brachyura/recombobulator/remapper/RecombobulatorRemapper.java b/recombobulator/src/main/java/io/github/coolcrabs/brachyura/recombobulator/remapper/RecombobulatorRemapper.java index 10c08f6d..b16a438b 100644 --- a/recombobulator/src/main/java/io/github/coolcrabs/brachyura/recombobulator/remapper/RecombobulatorRemapper.java +++ b/recombobulator/src/main/java/io/github/coolcrabs/brachyura/recombobulator/remapper/RecombobulatorRemapper.java @@ -6,6 +6,8 @@ import java.util.BitSet; import java.util.Collection; import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.TreeMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -749,7 +751,7 @@ public void visitClassInfo(ClassInfo el) { AttributeMethodParameters params; boolean isDynamic; int[] lvtp; - HashMap lvtTypeMap; + LinkedHashMap lvtTypeMap; @Override public void visitMethodInfo(MethodInfo el) { @@ -759,7 +761,7 @@ public void visitMethodInfo(MethodInfo el) { el.name_index = getUtf8Index(cp, newCp, utf8Map, openSlots, mapped.name); el.descriptor_index = getUtf8Index(cp, newCp, utf8Map, openSlots, mapped.desc); params = null; - lvtTypeMap = new HashMap<>(); + lvtTypeMap = new LinkedHashMap<>(); for (Attribute a : el.attributes) { if (a instanceof AttributeMethodParameters) params = (AttributeMethodParameters) a; if (a instanceof AttributeCode) { @@ -804,10 +806,31 @@ public void visitMethodInfo(MethodInfo el) { params.parameters.get(i).name_index = getUtf8Index(cp, newCp, utf8Map, openSlots, pm); } } + Mutf8Slice[] paramTypes = null; for (int i = 0; i < params.parameters.size(); i++) { if (!mappedp.get(i)) { EntryParameters ep = params.parameters.get(i); - ep.name_index = ep.name_index == 0 ? 0 : getUtf8Index(cp, newCp, utf8Map, openSlots, utf8(cp, ep.name_index)); + Mutf8Slice name = null; + if (ep.name_index != 0) name = utf8(cp, ep.name_index); + if (name == null) { + if (paramTypes == null) { + paramTypes = new Mutf8Slice[pcount]; + int[] startpcs = new int[pcount]; + for (Map.Entry e : lvtTypeMap.entrySet()) { + int index = e.getKey().valueInt(); + if (index < lvtp.length) { + int k = lvtp[index]; + if (paramTypes[k] == null || e.getKey().keyInt() < startpcs[k]) { + paramTypes[k] = e.getValue(); + startpcs[k] = e.getKey().keyInt(); + } + } + } + } + Mutf8Slice type = paramTypes[i]; + name = new Mutf8Slice("p" + getLvNameTypeThing(type) + i); + } + ep.name_index = getUtf8Index(cp, newCp, utf8Map, openSlots, name); } } } @@ -1305,6 +1328,7 @@ public void run() { output.outputClass(cls2Utf8(newCp, ci.this_class) + ".class", ci, in.tag); } catch (Exception e) { Logger.error("Error remapping {}", in.path); + Logger.error(e); throw e; } })