Annotate interfaces and methods with proper nullability and internal use annotations, and clean up formatting.

This commit is contained in:
Overlord committed 2026-10-01 09:22:43 +02:00
1 parent 2b94a49352
commit abc6c6c53e
3 files changed
+9 -6

No files matched your search

@@ -36,9 +36,7 @@ public sealed interface Anchor
} }
@Override @Override
public void verify(ClassNode node) { public void verify(ClassNode node) { this.resolve(node); }
this.resolve(node);
}
} }
/** A static or instance call to {@code owner.name desc} inside the method {@code in}. */ /** A static or instance call to {@code owner.name desc} inside the method {@code in}. */
@@ -1,9 +1,12 @@
package dev.overlord.zomboidforge.patcher; package dev.overlord.zomboidforge.patcher;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.ApiStatus.Internal;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
/** A build-time change to one class of the vanilla server jar. */ /** A build-time change to one class of the vanilla server jar. */
@Internal
public interface ClassPatch { public interface ClassPatch {
/** Internal name of the class to patch, e.g. {@code zombie/network/GameServer}. */ /** Internal name of the class to patch, e.g. {@code zombie/network/GameServer}. */
String target(); String target();
@@ -1,5 +1,7 @@
package dev.overlord.zomboidforge.patcher; package dev.overlord.zomboidforge.patcher;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodInsnNode;
@@ -19,7 +21,7 @@ public abstract class HookInjectionPatch implements ClassPatch
private final Anchor.Call anchor; private final Anchor.Call anchor;
private final Hook hook; private final Hook hook;
protected HookInjectionPatch(String target, Anchor.Call anchor, Hook hook) protected HookInjectionPatch(String target, Anchor.Call anchor, @NotNull Hook hook)
{ {
if (!hook.desc().equals(HookInjectionPatch.HOOK_DESC)) if (!hook.desc().equals(HookInjectionPatch.HOOK_DESC))
throw new IllegalArgumentException("Hook '" + hook + "' must have descriptor '" + HookInjectionPatch.HOOK_DESC + "'."); throw new IllegalArgumentException("Hook '" + hook + "' must have descriptor '" + HookInjectionPatch.HOOK_DESC + "'.");
@@ -34,7 +36,7 @@ public abstract class HookInjectionPatch implements ClassPatch
@Override @Override
public final Anchor.Call anchor() { return this.anchor; } public final Anchor.Call anchor() { return this.anchor; }
@Override @Override
public final Hook hook() { return this.hook; } public final @NotNull Hook hook() { return this.hook; }
@Override @Override
public final void apply(ClassNode node) public final void apply(ClassNode node)
@@ -42,7 +44,7 @@ public abstract class HookInjectionPatch implements ClassPatch
MethodInsnNode call = this.anchor.resolve(node); MethodInsnNode call = this.anchor.resolve(node);
this.anchor.in().resolve(node).instructions.insert( this.anchor.in().resolve(node).instructions.insert(
call, new MethodInsnNode( call, new MethodInsnNode(
Opcodes.INVOKESTATIC, Opcodes.INVOKESTATIC,
this.hook.owner(), this.hook.owner(),
this.hook.name(), this.hook.name(),