From f7d8a473aa5d92bcadff6c6df5a6960afaa099ce Mon Sep 17 00:00:00 2001 From: ZekerZhayard Date: Mon, 8 Aug 2022 16:58:14 +0800 Subject: [PATCH] Fix NoSuchMethodError when compiling with Java 9+ (#1585) --- .../main/java/org/jackhuang/hmcl/util/io/CompressingUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/CompressingUtils.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/CompressingUtils.java index 1c5b42b7c..1281743d7 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/CompressingUtils.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/CompressingUtils.java @@ -23,6 +23,7 @@ import org.jackhuang.hmcl.util.platform.OperatingSystem; import java.io.File; import java.io.IOException; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.*; @@ -72,7 +73,7 @@ public final class CompressingUtils { int clen = (int)(ba.length * cd.maxCharsPerByte()); if (clen == 0) continue; if (clen <= cb.capacity()) - cb.clear(); + ((Buffer) cb).clear(); // cast to prevent "java.lang.NoSuchMethodError: java.nio.CharBuffer.clear()Ljava/nio/CharBuffer;" when compiling with Java 9+ else cb = CharBuffer.allocate(clen);