diff --git a/src/main/java/net/fabricmc/loader/api/MappingResolver.java b/src/main/java/net/fabricmc/loader/api/MappingResolver.java index 0cea14875..8d80f3ad0 100644 --- a/src/main/java/net/fabricmc/loader/api/MappingResolver.java +++ b/src/main/java/net/fabricmc/loader/api/MappingResolver.java @@ -49,7 +49,7 @@ public interface MappingResolver { * Map a class name to the mapping currently used at runtime. * * @param namespace the namespace of the provided class name - * @param className the provided binary class name + * @param className the provided internal/binary class name * @return the mapped class name, or {@code className} if no such mapping is present */ String mapClassName(String namespace, String className); @@ -58,7 +58,7 @@ public interface MappingResolver { * Unmap a class name to the mapping currently used at runtime. * * @param targetNamespace The target namespace for unmapping. - * @param className the provided binary class name of the mapping form currently used at runtime + * @param className the provided internal/binary class name of the mapping form currently used at runtime * @return the mapped class name, or {@code className} if no such mapping is present */ String unmapClassName(String targetNamespace, String className); @@ -67,7 +67,7 @@ public interface MappingResolver { * Map a field name to the mapping currently used at runtime. * * @param namespace the namespace of the provided field name and descriptor - * @param owner the binary name of the owner class of the field + * @param owner the internal/binary name of the owner class of the field * @param name the name of the field * @param descriptor the descriptor of the field * @return the mapped field name, or {@code name} if no such mapping is present @@ -78,7 +78,7 @@ public interface MappingResolver { * Map a method name to the mapping currently used at runtime. * * @param namespace the namespace of the provided method name and descriptor - * @param owner the binary name of the owner class of the method + * @param owner the internal/binary name of the owner class of the method * @param name the name of the method * @param descriptor the descriptor of the method * @return the mapped method name, or {@code name} if no such mapping is present diff --git a/src/main/java/net/fabricmc/loader/impl/MappingResolverImpl.java b/src/main/java/net/fabricmc/loader/impl/MappingResolverImpl.java index f1407bb8c..d8a591218 100644 --- a/src/main/java/net/fabricmc/loader/impl/MappingResolverImpl.java +++ b/src/main/java/net/fabricmc/loader/impl/MappingResolverImpl.java @@ -57,16 +57,15 @@ protected final NamespaceData getNamespaceData(String namespace) { NamespaceData data = new NamespaceData(); TinyTree mappings = mappingsSupplier.get(); - Map classNameMap = new HashMap<>(); for (ClassDef classEntry : mappings.getClasses()) { - String fromClass = mapClassName(classNameMap, classEntry.getName(fromNamespace)); - String toClass = mapClassName(classNameMap, classEntry.getName(targetNamespace)); + String fromClass = classEntry.getName(fromNamespace); + String toClass = classEntry.getName(targetNamespace); data.classNames.put(fromClass, toClass); data.classNamesInverse.put(toClass, fromClass); - String mappedClassName = mapClassName(classNameMap, fromClass); + String mappedClassName = fromClass; recordMember(fromNamespace, classEntry.getFields(), data.fieldNames, mappedClassName); recordMember(fromNamespace, classEntry.getMethods(), data.methodNames, mappedClassName); @@ -76,14 +75,6 @@ protected final NamespaceData getNamespaceData(String namespace) { }); } - private static String replaceSlashesWithDots(String cname) { - return cname.replace('/', '.'); - } - - private String mapClassName(Map classNameMap, String s) { - return classNameMap.computeIfAbsent(s, MappingResolverImpl::replaceSlashesWithDots); - } - private void recordMember(String fromNamespace, Collection descriptoredList, Map putInto, String fromClass) { for (T descriptored : descriptoredList) { EntryTriple fromEntry = new EntryTriple(fromClass, descriptored.getName(fromNamespace), descriptored.getDescriptor(fromNamespace)); @@ -103,36 +94,28 @@ public String getCurrentRuntimeNamespace() { @Override public String mapClassName(String namespace, String className) { - if (className.indexOf('/') >= 0) { - throw new IllegalArgumentException("Class names must be provided in dot format: " + className); - } + className = className.replace('.', '/'); // maintain backwards compatibility with dotty format requirement return getNamespaceData(namespace).classNames.getOrDefault(className, className); } @Override public String unmapClassName(String namespace, String className) { - if (className.indexOf('/') >= 0) { - throw new IllegalArgumentException("Class names must be provided in dot format: " + className); - } + className = className.replace('.', '/'); // maintain backwards compatibility with dotty format requirement return getNamespaceData(namespace).classNamesInverse.getOrDefault(className, className); } @Override public String mapFieldName(String namespace, String owner, String name, String descriptor) { - if (owner.indexOf('/') >= 0) { - throw new IllegalArgumentException("Class names must be provided in dot format: " + owner); - } + owner = owner.replace('.', '/'); // maintain backwards compatibility with dotty format requirement return getNamespaceData(namespace).fieldNames.getOrDefault(new EntryTriple(owner, name, descriptor), name); } @Override public String mapMethodName(String namespace, String owner, String name, String descriptor) { - if (owner.indexOf('/') >= 0) { - throw new IllegalArgumentException("Class names must be provided in dot format: " + owner); - } + owner = owner.replace('.', '/'); // maintain backwards compatibility with dotty format requirement return getNamespaceData(namespace).methodNames.getOrDefault(new EntryTriple(owner, name, descriptor), name); }