Fix NPE in RemapUnpickDefinitionsTask.

Closes #3575

Co-authored-by: Cat Core <34719527+thecatcore@users.noreply.github.com>
This commit is contained in:
modmuss50 2023-08-02 18:34:24 +01:00
parent c073210031
commit 7dd0801da3
2 changed files with 23 additions and 6 deletions

View File

@ -1 +1 @@
filament_version=0.6.1 filament_version=0.6.2

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import javax.inject.Inject; import javax.inject.Inject;
@ -102,19 +103,35 @@ public abstract class RemapUnpickDefinitionsTask extends DefaultTask {
final int toM = mappingTree.getNamespaceId(getParameters().getTargetNamespace().get()); final int toM = mappingTree.getNamespaceId(getParameters().getTargetNamespace().get());
for (MappingTree.ClassMapping classDef : mappingTree.getClasses()) { 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()) { for (MappingTree.MethodMapping methodDef : classDef.getMethods()) {
methodMappings.put( methodMappings.put(
new MethodKey(classDef.getName(fromM), methodDef.getName(fromM), methodDef.getDesc(fromM)), new MethodKey(
methodDef.getName(toM) 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()) { for (MappingTree.FieldMapping fieldDef : classDef.getFields()) {
fieldMappings.put( fieldMappings.put(
new FieldKey(classDef.getName(fromM), fieldDef.getName(fromM)), new FieldKey(
fieldDef.getName(toM) 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())
); );
} }
} }