Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix java8 compatibility #390

Merged
merged 4 commits into from Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion build.sbt
Expand Up @@ -27,7 +27,14 @@ ThisBuild / dynverSeparator := "-"
ThisBuild / scalaVersion := "2.12.11"

// For building jars for JDK8
ThisBuild / javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
ThisBuild / javacOptions ++= {
if (scala.util.Properties.isJavaAtLeast("9")) {
// --release 8 option is not available in JDK8
Seq("--release", "8")
} else {
Seq.empty
}
}
Compile / compile / javacOptions ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation")

doc / javacOptions := {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/xerial/snappy/Snappy.java
Expand Up @@ -28,6 +28,7 @@
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.Properties;
Expand Down Expand Up @@ -154,7 +155,7 @@ public static int compress(ByteBuffer uncompressed, ByteBuffer compressed)

// pos limit
// [ ......BBBBBBB.........]
compressed.limit(cPos + compressedSize);
((Buffer) compressed).limit(cPos + compressedSize);

return compressedSize;
}
Expand Down