From 46dbad5b9b7fd92ac74dddb0918fba3b0c27c26f Mon Sep 17 00:00:00 2001 From: Col-E Date: Thu, 8 Jun 2023 08:02:02 -0400 Subject: [PATCH] Fix runtime exception on Java 8 in BufferData.get --- pom.xml | 2 +- .../java/software/coley/llzip/util/BufferData.java | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index f50f174..5b48f7c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.coley lljzip - 1.3.0 + 1.3.1 LL Java ZIP Lower level ZIP support for Java diff --git a/src/main/java/software/coley/llzip/util/BufferData.java b/src/main/java/software/coley/llzip/util/BufferData.java index 0f6454d..2de6094 100644 --- a/src/main/java/software/coley/llzip/util/BufferData.java +++ b/src/main/java/software/coley/llzip/util/BufferData.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -39,11 +40,13 @@ public byte get(long position) { @Override public void get(long position, byte[] b, int off, int len) { ensureOpen(); + // Left intentionally as unchained calls due to API differences across Java versions + // and how the compiler changes output. ByteBuffer buffer = this.buffer; - ((ByteBuffer) buffer.slice() - .order(buffer.order()) - .position(validate(position))) - .get(b, off, len); + buffer.slice(); + buffer.order(buffer.order()); + buffer.position(validate(position)); + buffer.get(b, off, len); } @Override