I guess 1.3.21 on Maven Central was compiled using Java 9+, as I get this error (doesn't happen with 1.3.20):
java.lang.NoSuchMethodError: java.nio.MappedByteBuffer.position(I)Ljava/nio/MappedByteBuffer;
at com.lowagie.text.pdf.MappedRandomAccessFile.seek(MappedRandomAccessFile.java:167)
at com.lowagie.text.pdf.RandomAccessFileOrArray.seek(RandomAccessFileOrArray.java:329)
at com.lowagie.text.pdf.PRTokeniser.getStartxref(PRTokeniser.java:221)
at com.lowagie.text.pdf.PdfReader.readXref(PdfReader.java:1369)
at com.lowagie.text.pdf.PdfReader.readPdf(PdfReader.java:600)
I guess the reason is that targeting the compiler to Java 8 is not enough, as the libraries are different and the method MappedByteBuffer.position(int) is new in Java9.
(I'm opening this as a reminder, but I didn't look into a way to resolve it, yet)
JEP-247 should address exactly this problem:
javac --release Nis equivalent to-source N -target N -bootclasspath <bootclasspath-from-N>
…but I see we're already using that parameter:
<configuration>
<release>9</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
Java 8 is still a must. Ich build it using java 11. @prashantbhat: Can you take a look at it?
Introduced with MR #395
I'm not good with Maven… but reading it again it might be that the <release>9</release> tag is only used for the module file in the java9 folder, while around line 166 the usual (old) target is used:
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
and we should add <release>8</release> there too.
(I'm not sure about MAven, but Ant automatically ignores it when using it on a JVM that doesn't support it)
It is working with the following default configuration in JDK9+ profile. (Btw, when I tried using <release>8</release> directly on maven compiler options using JDK8, it failed!)
<configuration>
<release>8</release>
</configuration>
After building with this change using Java 11, all tests have completed successfully running on Java 8.
I'll send a PR for this.
(Btw, when I tried using
<release>8</release>directly on maven compiler options using JDK8, it failed!)
I guess needing Java 9+ to build is fine, as long as the generated JAR runs on Java 8. 👍🏼
Cool, may we have a release with this fix, please?
Today, I'll to it again :-)
Most helpful comment
Cool, may we have a release with this fix, please?