diff --git a/native/src/main/c/jni_zlib_deflate.c b/native/src/main/c/jni_zlib_deflate.c index 8dcd60f09..809a7f857 100644 --- a/native/src/main/c/jni_zlib_deflate.c +++ b/native/src/main/c/jni_zlib_deflate.c @@ -27,7 +27,7 @@ Java_com_velocitypowered_natives_compression_NativeZlibDeflate_free(JNIEnv *env, libdeflate_free_compressor((struct libdeflate_compressor *) ctx); } -JNIEXPORT jboolean JNICALL +JNIEXPORT jlong JNICALL Java_com_velocitypowered_natives_compression_NativeZlibDeflate_process(JNIEnv *env, jclass clazz, jlong ctx, diff --git a/native/src/main/java/com/velocitypowered/natives/compression/LibdeflateVelocityCompressor.java b/native/src/main/java/com/velocitypowered/natives/compression/LibdeflateVelocityCompressor.java index aedb221c0..2976d627d 100644 --- a/native/src/main/java/com/velocitypowered/natives/compression/LibdeflateVelocityCompressor.java +++ b/native/src/main/java/com/velocitypowered/natives/compression/LibdeflateVelocityCompressor.java @@ -70,11 +70,13 @@ public class LibdeflateVelocityCompressor implements VelocityCompressor { destinationAddress, destination.writableBytes()); if (produced > 0) { destination.writerIndex(destination.writerIndex() + produced); - return; + break; + } else if (produced == 0) { + // Insufficient room - enlarge the buffer. + destination.capacity(destination.capacity() * 2); + } else { + throw new DataFormatException("libdeflate returned unknown code " + produced); } - - // Insufficient room - enlarge the buffer. - destination.capacity(destination.capacity() * 2); } } diff --git a/native/src/main/java/com/velocitypowered/natives/util/NativeConstraints.java b/native/src/main/java/com/velocitypowered/natives/util/NativeConstraints.java index e42bcfb91..ac74c3b4a 100644 --- a/native/src/main/java/com/velocitypowered/natives/util/NativeConstraints.java +++ b/native/src/main/java/com/velocitypowered/natives/util/NativeConstraints.java @@ -39,7 +39,8 @@ public class NativeConstraints { // HotSpot on Intel macOS prefers x86_64, but OpenJ9 on macOS and HotSpot/OpenJ9 elsewhere // give amd64. IS_AMD64 = osArch.equals("amd64") || osArch.equals("x86_64"); - IS_AARCH64 = osArch.equals("aarch64"); + IS_AARCH64 = osArch.equals("aarch64") || osArch.equals("arm64"); + System.out.println(System.getProperty("os.name", "")); } static final BooleanSupplier NATIVE_BASE = () -> NATIVES_ENABLED && CAN_GET_MEMORYADDRESS; @@ -52,6 +53,7 @@ public class NativeConstraints { && System.getProperty("os.name", "").equalsIgnoreCase("Linux") && IS_AARCH64; - static final BooleanSupplier JAVA_11 = () -> Double.parseDouble( - System.getProperty("java.specification.version")) >= 11; + static final BooleanSupplier MACOS_AARCH64 = () -> NATIVE_BASE.getAsBoolean() + && System.getProperty("os.name", "").equalsIgnoreCase("Mac OS X") + && IS_AARCH64; }