From 7dd0801da34eeaeeb142a1cbc32aaeefa4ac9e55 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Wed, 2 Aug 2023 18:34:24 +0100 Subject: [PATCH] Fix NPE in RemapUnpickDefinitionsTask. Closes #3575 Co-authored-by: Cat Core <34719527+thecatcore@users.noreply.github.com> --- filament/gradle.properties | 2 +- .../task/RemapUnpickDefinitionsTask.java | 27 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/filament/gradle.properties b/filament/gradle.properties index 09a5f50afd..36fb6e54dc 100644 --- a/filament/gradle.properties +++ b/filament/gradle.properties @@ -1 +1 @@ -filament_version=0.6.1 \ No newline at end of file +filament_version=0.6.2 \ No newline at end of file diff --git a/filament/src/main/java/net/fabricmc/filament/task/RemapUnpickDefinitionsTask.java b/filament/src/main/java/net/fabricmc/filament/task/RemapUnpickDefinitionsTask.java index 0e5fb0afa5..afeb31a4ca 100644 --- a/filament/src/main/java/net/fabricmc/filament/task/RemapUnpickDefinitionsTask.java +++ b/filament/src/main/java/net/fabricmc/filament/task/RemapUnpickDefinitionsTask.java @@ -6,6 +6,7 @@ import java.io.UncheckedIOException; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import javax.inject.Inject; @@ -102,19 +103,35 @@ public void execute() { final int toM = mappingTree.getNamespaceId(getParameters().getTargetNamespace().get()); for (MappingTree.ClassMapping classDef : mappingTree.getClasses()) { - classMappings.put(classDef.getName(fromM), classDef.getName(toM)); + final String classFromName = classDef.getName(fromM); + + if (classFromName == null) { + continue; + } + + classMappings.put( + classFromName, + Objects.requireNonNull(classDef.getName(toM), "Null to name: " + classFromName) + ); for (MappingTree.MethodMapping methodDef : classDef.getMethods()) { methodMappings.put( - new MethodKey(classDef.getName(fromM), methodDef.getName(fromM), methodDef.getDesc(fromM)), - methodDef.getName(toM) + new MethodKey( + Objects.requireNonNull(classFromName, "Null dst name: " + classDef.getSrcName()), + Objects.requireNonNull(methodDef.getName(fromM), "Null dst name: " + methodDef.getSrcName()), + Objects.requireNonNull(methodDef.getDesc(fromM), "Null dst name: " + methodDef.getSrcName()) + ), + Objects.requireNonNull(methodDef.getName(toM), "Null to name: " + methodDef.getSrcName()) ); } for (MappingTree.FieldMapping fieldDef : classDef.getFields()) { fieldMappings.put( - new FieldKey(classDef.getName(fromM), fieldDef.getName(fromM)), - fieldDef.getName(toM) + new FieldKey( + Objects.requireNonNull(classFromName, "Null dst name: " + classDef.getSrcName()), + Objects.requireNonNull(fieldDef.getName(fromM), "Null dst name: " + fieldDef.getSrcName()) + ), + Objects.requireNonNull(fieldDef.getName(toM), "Null to name: " + fieldDef.getSrcName()) ); } }