From 3d8e754ddc57f03bbee3b57966c0379ad30b0807 Mon Sep 17 00:00:00 2001 From: heipiao233 Date: Sat, 28 May 2022 14:18:43 +0800 Subject: [PATCH 1/2] Use mapping file for fallback --- .../java/net/fabricmc/tinyremapper/AsmRemapper.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java b/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java index 35e8d6f6..e23ee583 100644 --- a/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java +++ b/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java @@ -46,7 +46,12 @@ public String map(String typeName) { @Override public String mapFieldName(String owner, String name, String desc) { ClassInstance cls = getClass(owner); - if (cls == null) return name; + if (cls == null) { + System.out.println(String.format("Warning: actual class missing: %1$s", owner)); + if(!tr.ignoreFieldDesc) + return tr.fieldMap.getOrDefault(owner + "/" + name + ";;" + desc, name); + else return tr.fieldMap.getOrDefault(owner + "/" + name, name); + } return mapFieldName(cls, name, desc); } @@ -76,7 +81,10 @@ public String mapMethodName(String owner, String name, String desc) { } ClassInstance cls = getClass(owner); - if (cls == null) return name; // TODO: try to map these from just the mappings?, warn if actual class is missing + if (cls == null) { + System.out.println(String.format("Warning: actual class missing: %1$s", owner)); + return tr.methodMap.getOrDefault(owner + "/" + name + desc, name); + } return mapMethodName(cls, name, desc); } From d7c6159b5dbbbc121dfe5d50803d517700e4932e Mon Sep 17 00:00:00 2001 From: heipiao233 Date: Sun, 29 May 2022 14:26:51 +0800 Subject: [PATCH 2/2] checkd sytle --- .../java/net/fabricmc/tinyremapper/AsmRemapper.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java b/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java index e23ee583..127e5f0a 100644 --- a/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java +++ b/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2018, 2021, FabricMC + * Copyright (c) 2018, 2022, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -46,11 +46,15 @@ public String map(String typeName) { @Override public String mapFieldName(String owner, String name, String desc) { ClassInstance cls = getClass(owner); + if (cls == null) { System.out.println(String.format("Warning: actual class missing: %1$s", owner)); - if(!tr.ignoreFieldDesc) + + if (!tr.ignoreFieldDesc) { return tr.fieldMap.getOrDefault(owner + "/" + name + ";;" + desc, name); - else return tr.fieldMap.getOrDefault(owner + "/" + name, name); + } else { + return tr.fieldMap.getOrDefault(owner + "/" + name, name); + } } return mapFieldName(cls, name, desc); @@ -81,6 +85,7 @@ public String mapMethodName(String owner, String name, String desc) { } ClassInstance cls = getClass(owner); + if (cls == null) { System.out.println(String.format("Warning: actual class missing: %1$s", owner)); return tr.methodMap.getOrDefault(owner + "/" + name + desc, name);