The use of ByteBuffer & CharBuffer breaks cljam's binary compatibility
athos opened this issue · comments
Once you build cljam on a Java 9+ environmont:
$ java -version
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)
$ lein uberjar
Compiling cljam.tools.main
Compiling cljam.tools.cli
Compiling cljam.util.region
Compiling cljam.util.chromosome
Compiling cljam.util.whole-genome
...
Created /Users/sohta/work/cljam/target/cljam-0.7.1-SNAPSHOT.jar
Created /Users/sohta/work/cljam/target/cljam-0.7.1-SNAPSHOT-standalone.jar
$
And use the generated JAR on Java 8, you'll run into a NoSuchMethodError
:
$ java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
$ lein repl
user=> (require '[cljam.io.sam.util.quality :as sam-qual])
nil
user=> (sam-qual/phred-bytes->fastq (.getBytes "A"))
NoSuchMethodError java.nio.CharBuffer.flip()Ljava/nio/CharBuffer; cljam.io.sam.util.quality/phred-bytes->fastq (quality.clj:30)
user=>
The root cause of this issue is that Java 9 introduced some overriden methods for ByteBuffer
and other Buffer
impl classes, and that may sometimes break binary-level compatibility. See the links below for more details on the issue itself: