diff --git a/src/main/java/net/md_5/specialsource/JarMapping.java b/src/main/java/net/md_5/specialsource/JarMapping.java index 9362338..f6dc36c 100644 --- a/src/main/java/net/md_5/specialsource/JarMapping.java +++ b/src/main/java/net/md_5/specialsource/JarMapping.java @@ -471,8 +471,8 @@ public class JarMapping { String oldFieldName = inputTransformer.transformFieldName(tokens[0], tokens[1]); String newFieldName = outputTransformer.transformFieldName(tokens[0], tokens[2]); + String newClassName = reverseMap.map(oldClassName); if (reverse) { - String newClassName = reverseMap.map(oldClassName); if (newClassName.equals(oldClassName)) { // throw new IOException("Invalid csrg file line, could not be reversed: " + line); } @@ -484,6 +484,7 @@ public class JarMapping { } fields.put(oldClassName + "/" + oldFieldName, newFieldName); + fields.put(newClassName + "/" + oldFieldName, newFieldName); } else if (tokens.length == 4) { String oldClassName = inputTransformer.transformClassName(tokens[0]); String oldMethodName = inputTransformer.transformMethodName(tokens[0], tokens[1], tokens[2]); @@ -608,12 +609,14 @@ public class JarMapping { } String oldEntry = oldClassName + "/" + oldFieldName; + String newEntryHack = newClassName + "/" + oldFieldName; + if (fields.containsKey(oldEntry) && !newFieldName.equals(fields.get(oldEntry))) { throw new IllegalArgumentException("Duplicate field mapping: " + oldEntry + " ->" + newFieldName + " but already mapped to " + fields.get(oldEntry) + " in line=" + line); } - fields.put(oldEntry, newFieldName); + fields.put(newEntryHack, newFieldName); } else if (kind.equals("MD:")) { String oldFull = tokens[1]; String newFull = tokens[3]; diff --git a/src/main/java/net/md_5/specialsource/UnsortedRemappingMethodAdapter.java b/src/main/java/net/md_5/specialsource/UnsortedRemappingMethodAdapter.java index 2dd53fc..838f396 100644 --- a/src/main/java/net/md_5/specialsource/UnsortedRemappingMethodAdapter.java +++ b/src/main/java/net/md_5/specialsource/UnsortedRemappingMethodAdapter.java @@ -81,6 +81,7 @@ public class UnsortedRemappingMethodAdapter extends MethodRemapper { Object... bsmArgs) { // Special case lambda metaFactory to get new name + if (META_FACTORIES.contains(bsm)) { String owner = Type.getReturnType(desc).getInternalName(); String odesc = ((Type) bsmArgs[0]).getDescriptor(); // First constant argument is "samMethodType - Signature and return type of method to be implemented by the function object." @@ -90,6 +91,19 @@ public class UnsortedRemappingMethodAdapter extends MethodRemapper { name = remapper.mapInvokeDynamicMethodName(name, desc); } + if (bsm.getOwner().equals("java/lang/runtime/ObjectMethods")) { + // TODO: consider asserting name (the parameter) equals hashCode, toString, or equals + + Type clazz = (Type)bsmArgs[0]; + // TODO: consider asserting (String)bsmArgs[1] == "step;feature" + + for (int i = 2; i < bsmArgs.length; i++) { + Handle h = (Handle)bsmArgs[i]; + String newName = remapper.mapFieldName(clazz.getInternalName(), h.getName(), h.getDesc()); + bsmArgs[i] = new Handle(h.getTag(), h.getOwner(), newName, h.getDesc(), h.isInterface()); + } + } + for (int i = 0; i < bsmArgs.length; i++) { bsmArgs[i] = remapper.mapValue(bsmArgs[i]); }