Refine nullability annotations in HierarchyClassWriter and JarPatcher for consistency and clarity.
This commit is contained in:
1 parent
30b0b0572f
commit
600373dc61
2 files changed
+7
-5
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package dev.overlord.zomboidforge.patcher;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
@@ -21,13 +23,13 @@ import java.util.function.Function;
|
||||
final class HierarchyClassWriter extends ClassWriter {
|
||||
private static final String OBJECT = "java/lang/Object";
|
||||
|
||||
private record Header(String superName, boolean isInterface) {}
|
||||
private record Header(@Nullable String superName, boolean isInterface) {}
|
||||
|
||||
private final Function<String, byte[]> jarClasses;
|
||||
private final Function<String, byte @Nullable []> jarClasses;
|
||||
private final Map<String, Header> headers = new HashMap<>();
|
||||
|
||||
/** @param jarClasses bytes of a class in the jar being patched, or {@code null} */
|
||||
HierarchyClassWriter(Function<String, byte[]> jarClasses) {
|
||||
HierarchyClassWriter(Function<String, byte @Nullable []> jarClasses) {
|
||||
super(COMPUTE_FRAMES);
|
||||
this.jarClasses = jarClasses;
|
||||
}
|
||||
@@ -60,7 +62,7 @@ final class HierarchyClassWriter extends ClassWriter {
|
||||
|
||||
private byte[] bytes(String internalName)
|
||||
{
|
||||
byte[] bytes = jarClasses.apply(internalName);
|
||||
byte @Nullable [] bytes = jarClasses.apply(internalName);
|
||||
if (bytes != null) return bytes;
|
||||
|
||||
// JDK (or other non-jar) class.
|
||||
|
||||
@@ -208,7 +208,7 @@ public final class JarPatcher
|
||||
patch.apply(node);
|
||||
}
|
||||
|
||||
HierarchyClassWriter writer = new HierarchyClassWriter(name -> Objects.requireNonNull(JarPatcher.read(jar, name + ".class")));
|
||||
HierarchyClassWriter writer = new HierarchyClassWriter(name -> JarPatcher.read(jar, name + ".class"));
|
||||
node.accept(writer);
|
||||
|
||||
return writer.toByteArray();
|
||||
|
||||
Reference in new issue
Block a user