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

1.3.21 (on Maven Central) is broken on Java 8 #411

Closed
lapo-luchini opened this issue Sep 22, 2020 · 8 comments
Closed

1.3.21 (on Maven Central) is broken on Java 8 #411

lapo-luchini opened this issue Sep 22, 2020 · 8 comments

Comments

@lapo-luchini
Copy link
Contributor

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)

@lapo-luchini
Copy link
Contributor Author

JEP-247 should address exactly this problem:

javac --release N is equivalent to -source N -target N -bootclasspath <bootclasspath-from-N>

@lapo-luchini
Copy link
Contributor Author

…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>

@asturio
Copy link
Member

asturio commented Sep 22, 2020

Java 8 is still a must. Ich build it using java 11. @prashantbhat: Can you take a look at it?

Introduced with MR #395

@lapo-luchini
Copy link
Contributor Author

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)

@prashantbhat
Copy link
Contributor

prashantbhat commented Sep 22, 2020

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.

@lapo-luchini
Copy link
Contributor Author

(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. 👍🏼

@andreasrosdal
Copy link
Contributor

Cool, may we have a release with this fix, please?

@asturio
Copy link
Member

asturio commented Sep 23, 2020

Today, I'll to it again :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants