Fix java8 compatibility (#390)
* ByteBuffer.limit() compiled with JDK9+ shows java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer; error in JDK8 * Set --release 8 JDK option * Do not use --release 8 option in JDK8
This commit is contained in:
parent
5ad862e802
commit
39160ac5d2
|
@ -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 := {
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
|||
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;
|
||||
|
@ -154,7 +155,7 @@ public class Snappy
|
|||
|
||||
// pos limit
|
||||
// [ ......BBBBBBB.........]
|
||||
compressed.limit(cPos + compressedSize);
|
||||
((Buffer) compressed).limit(cPos + compressedSize);
|
||||
|
||||
return compressedSize;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue