[base] Update java-commons again, hopefully fixing the API
This commit is contained in:
parent
3155392ed3
commit
4ea93941f5
|
@ -1,8 +1,8 @@
|
|||
# https://fabricmc.net/develop/
|
||||
minecraft_version=1.19
|
||||
yarn_mappings=build.1
|
||||
loader_version=0.14.6
|
||||
fabric_version=0.55.1+1.19
|
||||
yarn_mappings=build.4
|
||||
loader_version=0.14.8
|
||||
fabric_version=0.56.1+1.19
|
||||
|
||||
maven_group=io.gitlab.jfronny.libjf
|
||||
archive_base_name=libjf
|
||||
|
@ -13,4 +13,4 @@ modrinth_optional_dependencies=P7dR8mSH
|
|||
curseforge_id=482600
|
||||
curseforge_optional_dependencies=fabric-api
|
||||
|
||||
commons_version=2022.6.21+16-38-52
|
||||
commons_version=2022.6.23+15-19-23
|
|
@ -1,10 +1,11 @@
|
|||
package io.gitlab.jfronny.libjf;
|
||||
|
||||
import io.gitlab.jfronny.commons.log.*;
|
||||
import io.gitlab.jfronny.commons.serialize.gson.api.*;
|
||||
import io.gitlab.jfronny.gson.*;
|
||||
import io.gitlab.jfronny.libjf.gson.*;
|
||||
import net.fabricmc.loader.api.*;
|
||||
import io.gitlab.jfronny.commons.log.Logger;
|
||||
import io.gitlab.jfronny.commons.serialize.gson.api.GsonHolder;
|
||||
import io.gitlab.jfronny.gson.GsonBuilder;
|
||||
import io.gitlab.jfronny.libjf.gson.GsonAdapter;;
|
||||
import io.gitlab.jfronny.libjf.gson.HiddenAnnotationExclusionStrategy;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
public class LibJf {
|
||||
private LibJf() {
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.0",
|
||||
"minecraft": "*"
|
||||
"minecraft": "*",
|
||||
"fabric-lifecycle-events-v1": "*"
|
||||
},
|
||||
"entrypoints": {
|
||||
"main": ["io.gitlab.jfronny.libjf.coprocess.CoProcessManager"]
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
"depends": {
|
||||
"fabricloader": ">=0.12.0",
|
||||
"minecraft": "*",
|
||||
"fabric-resource-loader-v0": "*",
|
||||
"fabric-command-api-v2": "*",
|
||||
"libjf-base": ">=${version}",
|
||||
"libjf-unsafe-v0": ">=${version}"
|
||||
},
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"depends": {
|
||||
"fabricloader": ">=0.12.0",
|
||||
"minecraft": "*",
|
||||
"fabric-resource-loader-v0": "*",
|
||||
"libjf-base": ">=${version}"
|
||||
},
|
||||
"custom": {
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
archivesBaseName = "libjf-legacy-v0"
|
||||
|
||||
dependencies {
|
||||
moduleDependencies(project, ["libjf-base", "libjf-unsafe-v0"])
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package io.gitlab.jfronny.libjf.legacy;
|
||||
|
||||
import io.gitlab.jfronny.libjf.unsafe.asm.AsmConfig;
|
||||
import io.gitlab.jfronny.libjf.unsafe.asm.patch.Patch;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class LegacyPatcher implements AsmConfig {
|
||||
@Override
|
||||
public Set<String> skipClasses() {
|
||||
return Set.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Patch> getPatches() {
|
||||
return Set.of(klazz -> {
|
||||
if (!klazz.name.startsWith("io/gitlab/jfronny/")) return;
|
||||
for (MethodNode method : klazz.methods) {
|
||||
for (AbstractInsnNode insn : method.instructions) {
|
||||
if (!(insn instanceof MethodInsnNode node)) continue;
|
||||
if (!node.owner.equals("io/gitlab/jfronny/commons/log/Logger")) continue;
|
||||
node.itf = false;
|
||||
if (node.getOpcode() == Opcodes.INVOKEINTERFACE) node.setOpcode(Opcodes.INVOKEVIRTUAL);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "libjf-legacy-v0",
|
||||
"name": "LibJF Legacy Compatibility",
|
||||
"version": "${version}",
|
||||
"authors": [
|
||||
"JFronny"
|
||||
],
|
||||
"contact": {
|
||||
"website": "https://jfronny.gitlab.io",
|
||||
"repo": "https://gitlab.com/jfmods/libjf"
|
||||
},
|
||||
"license": "MIT",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"libjf:asm": [
|
||||
"io.gitlab.jfronny.libjf.legacy.LegacyPatcher"
|
||||
]
|
||||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.0",
|
||||
"minecraft": "*",
|
||||
"libjf-base": ">=${version}",
|
||||
"libjf-unsafe-v0": ">=${version}"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"parent": "libjf",
|
||||
"badges": ["library"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import io.gitlab.jfronny.commons.log.LogStrategy;
|
||||
import io.gitlab.jfronny.commons.log.Logger;
|
||||
import net.fabricmc.loader.impl.util.log.Log;
|
||||
import net.fabricmc.loader.impl.util.log.LogCategory;
|
||||
|
||||
public class FLLogger implements LogStrategy {
|
||||
public class FLLogger implements Logger {
|
||||
private final LogCategory category;
|
||||
|
||||
public FLLogger(String context, String... names) {
|
||||
|
|
|
@ -17,7 +17,7 @@ public class JfLanguageAdapter implements LanguageAdapter {
|
|||
public native <T> T create(net.fabricmc.loader.api.ModContainer mod, String value, Class<T> type);
|
||||
|
||||
static {
|
||||
Logger.updateStrategy(FLLogger::new); // Reset in SafeLog entrypoint
|
||||
Logger.registerFactory(FLLogger::new); // Reset in SafeLog entrypoint
|
||||
Set<Flags.BooleanFlag> flags = Flags.getBoolFlags("unsafe.unlock");
|
||||
if (flags.stream().map(Flags.BooleanFlag::value).reduce(false, (left, right) -> left || right)) {
|
||||
SafeLog.warn("Unlocking classpath due to: " + flags.stream().map(Flags.BooleanFlag::source).collect(Collectors.joining(", ")));
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import io.gitlab.jfronny.libjf.unsafe.asm.*;
|
||||
import org.objectweb.asm.tree.*;
|
||||
import org.spongepowered.asm.mixin.extensibility.*;
|
||||
import org.spongepowered.asm.mixin.transformer.*;
|
||||
import sun.misc.*;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.IMixinTransformer;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
public class MixinPlugin implements IMixinConfigPlugin {
|
||||
|
@ -24,11 +24,7 @@ public class MixinPlugin implements IMixinConfigPlugin {
|
|||
Field mixinTransformerField = delegateClass.getDeclaredField("mixinTransformer");
|
||||
mixinTransformerField.setAccessible(true);
|
||||
|
||||
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
unsafeField.setAccessible(true);
|
||||
Unsafe unsafe = (Unsafe) unsafeField.get(null);
|
||||
|
||||
AsmTransformer.INSTANCE = (AsmTransformer) unsafe.allocateInstance(AsmTransformer.class);
|
||||
AsmTransformer.INSTANCE = Unsafe.allocateInstance(AsmTransformer.class);
|
||||
AsmTransformer.INSTANCE.delegate = (IMixinTransformer) mixinTransformerField.get(delegate);
|
||||
AsmTransformer.INSTANCE.asmConfigs = new HashSet<>();
|
||||
DynamicEntry.execute("libjf:asm", AsmConfig.class, s -> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import io.gitlab.jfronny.commons.log.Logger;
|
||||
import net.fabricmc.api.*;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
public class SafeLog implements ModInitializer {
|
||||
private static Logger BACKEND = Logger.forName("LibJF");
|
||||
|
@ -28,7 +28,7 @@ public class SafeLog implements ModInitializer {
|
|||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Logger.resetStrategy();
|
||||
Logger.resetFactory();
|
||||
BACKEND = Logger.forName("libjf");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,347 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import io.gitlab.jfronny.commons.throwable.Try;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
public class Unsafe {
|
||||
public static final sun.misc.Unsafe theUnsafe = Try.orThrow(() -> {
|
||||
Field unsafeField = Try.orThrow(() -> sun.misc.Unsafe.class.getDeclaredField("theUnsafe"));
|
||||
unsafeField.setAccessible(true);
|
||||
return (sun.misc.Unsafe) unsafeField.get(null);
|
||||
});
|
||||
|
||||
public static int getInt(Object o, long offset) {
|
||||
return theUnsafe.getInt(o, offset);
|
||||
}
|
||||
|
||||
public static void putInt(Object o, long offset, int x) {
|
||||
theUnsafe.putInt(o, offset, x);
|
||||
}
|
||||
|
||||
public static <T> T getObject(Object o, long offset) {
|
||||
return (T) theUnsafe.getObject(o, offset);
|
||||
}
|
||||
|
||||
public static void putObject(Object o, long offset, Object x) {
|
||||
theUnsafe.putObject(o, offset, x);
|
||||
}
|
||||
|
||||
public static boolean getBoolean(Object o, long offset) {
|
||||
return theUnsafe.getBoolean(o, offset);
|
||||
}
|
||||
|
||||
public static void putBoolean(Object o, long offset, boolean x) {
|
||||
theUnsafe.putBoolean(o, offset, x);
|
||||
}
|
||||
|
||||
public static byte getByte(Object o, long offset) {
|
||||
return theUnsafe.getByte(o, offset);
|
||||
}
|
||||
|
||||
public static void putByte(Object o, long offset, byte x) {
|
||||
theUnsafe.putByte(o, offset, x);
|
||||
}
|
||||
|
||||
public static short getShort(Object o, long offset) {
|
||||
return theUnsafe.getShort(o, offset);
|
||||
}
|
||||
|
||||
public static void putShort(Object o, long offset, short x) {
|
||||
theUnsafe.putShort(o, offset, x);
|
||||
}
|
||||
|
||||
public static char getChar(Object o, long offset) {
|
||||
return theUnsafe.getChar(o, offset);
|
||||
}
|
||||
|
||||
public static void putChar(Object o, long offset, char x) {
|
||||
theUnsafe.putChar(o, offset, x);
|
||||
}
|
||||
|
||||
public static long getLong(Object o, long offset) {
|
||||
return theUnsafe.getLong(o, offset);
|
||||
}
|
||||
|
||||
public static void putLong(Object o, long offset, long x) {
|
||||
theUnsafe.putLong(o, offset, x);
|
||||
}
|
||||
|
||||
public static float getFloat(Object o, long offset) {
|
||||
return theUnsafe.getFloat(o, offset);
|
||||
}
|
||||
|
||||
public static void putFloat(Object o, long offset, float x) {
|
||||
theUnsafe.putFloat(o, offset, x);
|
||||
}
|
||||
|
||||
public static double getDouble(Object o, long offset) {
|
||||
return theUnsafe.getDouble(o, offset);
|
||||
}
|
||||
|
||||
public static void putDouble(Object o, long offset, double x) {
|
||||
theUnsafe.putDouble(o, offset, x);
|
||||
}
|
||||
|
||||
public static byte getByte(long address) {
|
||||
return theUnsafe.getByte(address);
|
||||
}
|
||||
|
||||
public static void putByte(long address, byte x) {
|
||||
theUnsafe.putByte(address, x);
|
||||
}
|
||||
|
||||
public static short getShort(long address) {
|
||||
return theUnsafe.getShort(address);
|
||||
}
|
||||
|
||||
public static void putShort(long address, short x) {
|
||||
theUnsafe.putShort(address, x);
|
||||
}
|
||||
|
||||
public static char getChar(long address) {
|
||||
return theUnsafe.getChar(address);
|
||||
}
|
||||
|
||||
public static void putChar(long address, char x) {
|
||||
theUnsafe.putChar(address, x);
|
||||
}
|
||||
|
||||
public static int getInt(long address) {
|
||||
return theUnsafe.getInt(address);
|
||||
}
|
||||
|
||||
public static void putInt(long address, int x) {
|
||||
theUnsafe.putInt(address, x);
|
||||
}
|
||||
|
||||
public static long getLong(long address) {
|
||||
return theUnsafe.getLong(address);
|
||||
}
|
||||
|
||||
public static void putLong(long address, long x) {
|
||||
theUnsafe.putLong(address, x);
|
||||
}
|
||||
|
||||
public static float getFloat(long address) {
|
||||
return theUnsafe.getFloat(address);
|
||||
}
|
||||
|
||||
public static void putFloat(long address, float x) {
|
||||
theUnsafe.putFloat(address, x);
|
||||
}
|
||||
|
||||
public static double getDouble(long address) {
|
||||
return theUnsafe.getDouble(address);
|
||||
}
|
||||
|
||||
public static void putDouble(long address, double x) {
|
||||
theUnsafe.putDouble(address, x);
|
||||
}
|
||||
|
||||
public static long getAddress(long address) {
|
||||
return theUnsafe.getAddress(address);
|
||||
}
|
||||
|
||||
public static void putAddress(long address, long x) {
|
||||
theUnsafe.putAddress(address, x);
|
||||
}
|
||||
|
||||
public static long allocateMemory(long bytes) {
|
||||
return theUnsafe.allocateMemory(bytes);
|
||||
}
|
||||
|
||||
public static long reallocateMemory(long address, long bytes) {
|
||||
return theUnsafe.reallocateMemory(address, bytes);
|
||||
}
|
||||
|
||||
public static void setMemory(Object o, long offset, long bytes, byte value) {
|
||||
theUnsafe.setMemory(o, offset, bytes, value);
|
||||
}
|
||||
|
||||
public static void setMemory(long address, long bytes, byte value) {
|
||||
theUnsafe.setMemory(address, bytes, value);
|
||||
}
|
||||
|
||||
public static void copyMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes) {
|
||||
theUnsafe.copyMemory(srcBase, srcOffset, destBase, destOffset, bytes);
|
||||
}
|
||||
|
||||
public static void copyMemory(long srcAddress, long destAddress, long bytes) {
|
||||
theUnsafe.copyMemory(srcAddress, destAddress, bytes);
|
||||
}
|
||||
|
||||
public static void freeMemory(long address) {
|
||||
theUnsafe.freeMemory(address);
|
||||
}
|
||||
|
||||
public static int arrayBaseOffset(Class<?> arrayClass) {
|
||||
return theUnsafe.arrayBaseOffset(arrayClass);
|
||||
}
|
||||
|
||||
public static int arrayIndexScale(Class<?> arrayClass) {
|
||||
return theUnsafe.arrayIndexScale(arrayClass);
|
||||
}
|
||||
|
||||
public static int addressSize() {
|
||||
return theUnsafe.addressSize();
|
||||
}
|
||||
|
||||
public static int pageSize() {
|
||||
return theUnsafe.pageSize();
|
||||
}
|
||||
|
||||
public static <T> T allocateInstance(Class<T> cls) throws InstantiationException {
|
||||
return (T) theUnsafe.allocateInstance(cls);
|
||||
}
|
||||
|
||||
public static void throwException(Throwable ee) {
|
||||
theUnsafe.throwException(ee);
|
||||
}
|
||||
|
||||
public static boolean compareAndSwapObject(Object o, long offset, Object expected, Object x) {
|
||||
return theUnsafe.compareAndSwapObject(o, offset, expected, x);
|
||||
}
|
||||
|
||||
public static boolean compareAndSwapInt(Object o, long offset, int expected, int x) {
|
||||
return theUnsafe.compareAndSwapInt(o, offset, expected, x);
|
||||
}
|
||||
|
||||
public static boolean compareAndSwapLong(Object o, long offset, long expected, long x) {
|
||||
return theUnsafe.compareAndSwapLong(o, offset, expected, x);
|
||||
}
|
||||
|
||||
public static <T> T getObjectVolatile(Object o, long offset) {
|
||||
return (T) theUnsafe.getObjectVolatile(o, offset);
|
||||
}
|
||||
|
||||
public static void putObjectVolatile(Object o, long offset, Object x) {
|
||||
theUnsafe.putObjectVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public static int getIntVolatile(Object o, long offset) {
|
||||
return theUnsafe.getIntVolatile(o, offset);
|
||||
}
|
||||
|
||||
public static void putIntVolatile(Object o, long offset, int x) {
|
||||
theUnsafe.putIntVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public static boolean getBooleanVolatile(Object o, long offset) {
|
||||
return theUnsafe.getBooleanVolatile(o, offset);
|
||||
}
|
||||
|
||||
public static void putBooleanVolatile(Object o, long offset, boolean x) {
|
||||
theUnsafe.putBooleanVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public static byte getByteVolatile(Object o, long offset) {
|
||||
return theUnsafe.getByteVolatile(o, offset);
|
||||
}
|
||||
|
||||
public static void putByteVolatile(Object o, long offset, byte x) {
|
||||
theUnsafe.putByteVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public static short getShortVolatile(Object o, long offset) {
|
||||
return theUnsafe.getShortVolatile(o, offset);
|
||||
}
|
||||
|
||||
public static void putShortVolatile(Object o, long offset, short x) {
|
||||
theUnsafe.putShortVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public static char getCharVolatile(Object o, long offset) {
|
||||
return theUnsafe.getCharVolatile(o, offset);
|
||||
}
|
||||
|
||||
public static void putCharVolatile(Object o, long offset, char x) {
|
||||
theUnsafe.putCharVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public static long getLongVolatile(Object o, long offset) {
|
||||
return theUnsafe.getLongVolatile(o, offset);
|
||||
}
|
||||
|
||||
public static void putLongVolatile(Object o, long offset, long x) {
|
||||
theUnsafe.putLongVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public static float getFloatVolatile(Object o, long offset) {
|
||||
return theUnsafe.getFloatVolatile(o, offset);
|
||||
}
|
||||
|
||||
public static void putFloatVolatile(Object o, long offset, float x) {
|
||||
theUnsafe.putFloatVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public static double getDoubleVolatile(Object o, long offset) {
|
||||
return theUnsafe.getDoubleVolatile(o, offset);
|
||||
}
|
||||
|
||||
public static void putDoubleVolatile(Object o, long offset, double x) {
|
||||
theUnsafe.putDoubleVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public static void putOrderedObject(Object o, long offset, Object x) {
|
||||
theUnsafe.putOrderedObject(o, offset, x);
|
||||
}
|
||||
|
||||
public static void putOrderedInt(Object o, long offset, int x) {
|
||||
theUnsafe.putOrderedInt(o, offset, x);
|
||||
}
|
||||
|
||||
public static void putOrderedLong(Object o, long offset, long x) {
|
||||
theUnsafe.putOrderedLong(o, offset, x);
|
||||
}
|
||||
|
||||
public static void unpark(Object thread) {
|
||||
theUnsafe.unpark(thread);
|
||||
}
|
||||
|
||||
public static void park(boolean isAbsolute, long time) {
|
||||
theUnsafe.park(isAbsolute, time);
|
||||
}
|
||||
|
||||
public static int getLoadAverage(double[] loadavg, int nelems) {
|
||||
return theUnsafe.getLoadAverage(loadavg, nelems);
|
||||
}
|
||||
|
||||
public static int getAndAddInt(Object o, long offset, int delta) {
|
||||
return theUnsafe.getAndAddInt(o, offset, delta);
|
||||
}
|
||||
|
||||
public static long getAndAddLong(Object o, long offset, long delta) {
|
||||
return theUnsafe.getAndAddLong(o, offset, delta);
|
||||
}
|
||||
|
||||
public static int getAndSetInt(Object o, long offset, int newValue) {
|
||||
return theUnsafe.getAndSetInt(o, offset, newValue);
|
||||
}
|
||||
|
||||
public static long getAndSetLong(Object o, long offset, long newValue) {
|
||||
return theUnsafe.getAndSetLong(o, offset, newValue);
|
||||
}
|
||||
|
||||
public static <T> T getAndSetObject(Object o, long offset, T newValue) {
|
||||
return (T) theUnsafe.getAndSetObject(o, offset, newValue);
|
||||
}
|
||||
|
||||
public static void loadFence() {
|
||||
theUnsafe.loadFence();
|
||||
}
|
||||
|
||||
public static void storeFence() {
|
||||
theUnsafe.storeFence();
|
||||
}
|
||||
|
||||
public static void fullFence() {
|
||||
theUnsafe.fullFence();
|
||||
}
|
||||
|
||||
public static void invokeCleaner(ByteBuffer directBuffer) {
|
||||
theUnsafe.invokeCleaner(directBuffer);
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@
|
|||
"minecraft": "*",
|
||||
"libjf-base": ">=${version}",
|
||||
"libjf-config-v0": ">=${version}",
|
||||
"fabric-lifecycle-events-v1": "*",
|
||||
"fabric-command-api-v2": "*"
|
||||
},
|
||||
"custom": {
|
||||
|
|
|
@ -16,7 +16,6 @@ include 'libjf-config-v0'
|
|||
include 'libjf-data-v0'
|
||||
include 'libjf-data-manipulation-v0'
|
||||
include 'libjf-devutil-v0'
|
||||
include 'libjf-legacy-v0'
|
||||
include 'libjf-translate-v1'
|
||||
include 'libjf-unsafe-v0'
|
||||
include 'libjf-web-v0'
|
Loading…
Reference in New Issue