Skip to content

Commit 46dbad5

Browse files
committed
Fix runtime exception on Java 8 in BufferData.get
1 parent 5896377 commit 46dbad5

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.coley</groupId>
88
<artifactId>lljzip</artifactId>
9-
<version>1.3.0</version>
9+
<version>1.3.1</version>
1010

1111
<name>LL Java ZIP</name>
1212
<description>Lower level ZIP support for Java</description>

src/main/java/software/coley/llzip/util/BufferData.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.IOException;
44
import java.io.OutputStream;
5+
import java.nio.Buffer;
56
import java.nio.ByteBuffer;
67
import java.nio.ByteOrder;
78

@@ -39,11 +40,13 @@ public byte get(long position) {
3940
@Override
4041
public void get(long position, byte[] b, int off, int len) {
4142
ensureOpen();
43+
// Left intentionally as unchained calls due to API differences across Java versions
44+
// and how the compiler changes output.
4245
ByteBuffer buffer = this.buffer;
43-
((ByteBuffer) buffer.slice()
44-
.order(buffer.order())
45-
.position(validate(position)))
46-
.get(b, off, len);
46+
buffer.slice();
47+
buffer.order(buffer.order());
48+
buffer.position(validate(position));
49+
buffer.get(b, off, len);
4750
}
4851

4952
@Override

0 commit comments

Comments
 (0)