Skip to content

Compile the driver with Java17 - #2096

Open
absurdfarce wants to merge 8 commits into
apache:trunkfrom
absurdfarce:500_prep
Open

Compile the driver with Java17#2096
absurdfarce wants to merge 8 commits into
apache:trunkfrom
absurdfarce:500_prep

Conversation

@absurdfarce

Copy link
Copy Markdown
Contributor

Change the build to use Java17 for compiling the driver

Comment thread pom.xml
<module>bom</module>
</modules>
<properties>
<maven.compiler.release>17</maven.compiler.release>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change replaces the source + target designations used in earlier Maven builds

Comment thread pom.xml
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>javac-with-errorprone</compilerId>
<forceJavacCompilerUse>true</forceJavacCompilerUse>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced by "forceLegacyJavaApi" use below

Comment thread pom.xml
<compilerArg>-Xep:AnnotateFormatMethod:OFF</compilerArg>
<compilerArg>-Xep:WildcardImport:WARN</compilerArg>
<compilerArg>-XepExcludedPaths:.*/target/(?:generated-sources|generated-test-sources)/.*</compilerArg>
</compilerArgs>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler args above were removed because they didn't seem to be supported on Java17 javac. I need to run back through these again to see if I missed something here.

Comment thread pom.xml
<forceLegacyJavacApi>true</forceLegacyJavacApi>
<showWarnings>true</showWarnings>
<failOnWarning>true</failOnWarning>
<failOnWarning>false</failOnWarning>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this change but I couldn't find another way around it.

Without this change the build fails as follows:

[INFO] --- compiler:3.15.0:compile (default-compile) @ java-driver-core ---
[INFO] Compiling 799 source files with javac-with-errorprone [debug release 17] to target/classes
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING : 
[INFO] -------------------------------------------------------------
[WARNING] Supported source version 'RELEASE_8' from annotation processor 'org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDslProcessor' less than -source '17'
[INFO] 1 warning
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error: warnings found and -Werror specified
[INFO] 1 error

Problem here stems from the GremlinDsl usage in the graph test code. The annotation processor for the version of Tinkerpop we use states that it produces Java8 code and apparently Maven considers this a warning.

Thing is that upgrading Tinkerpop is a fairly involved process... and perhaps more importantly newer versions of the annotation processor aren't any different. I'm not opposed to a Tinkerpop upgrade in general but I don't think it'll help much for this specific issue.

Comment thread pom.xml
</additionalJOptions>
<useStandardDocletOptions>false</useStandardDocletOptions>
</configuration>
</execution>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I had to remove the api-plumber-doclet ref entirely.

Using the version that was in the build (version 1.0.0) gives the following errors now:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.348 s
[INFO] Finished at: 2026-08-17T12:36:17-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc (check-api-leaks) on project java-driver-guava-shaded: An error has occurred in Javadoc report generation: 
[ERROR] Exit code: 1 - error: Class com.datastax.oss.doclet.ApiPlumber is not a valid doclet.
[ERROR]   Note: As of JDK 13, the com.sun.javadoc API is no longer supported.
[ERROR] 
[ERROR] Command line was: /home/mersault/.jabba/jdk/openjdk@17.0.2/bin/javadoc -preventleak com.datastax.oss.driver.internal com.datastax.dse.driver.internal -preventleak com.datastax.oss.driver.shaded -preventleak com.typesafe.config -preventleak com.codahale.metrics -preventleak org.HdrHistogram -preventleak io.netty -preventleak jnr -preventleak com.kenai.constantine -preventleak com.kenai.jffi -preventleak com.kenai.jnr -preventleak net.jpountz -preventleak org.xerial.snappy @options @packages
[ERROR] 
[ERROR] Refer to the generated Javadoc files in '/home/mersault/work/git/cassandra-java-driver-absurdfarce/guava-shaded/target/site/apidocs' dir.
[ERROR] 
[ERROR] -> [Help 1]

Version 2.0.0 of the doclet was intended to address exactly this issue but it also seems to run aground:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.342 s
[INFO] Finished at: 2026-08-17T12:38:57-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc (check-api-leaks) on project java-driver-guava-shaded: An error has occurred in Javadoc report generation: 
[ERROR] Exit code: 2 - error: No source files for package com.datastax.dse.driver.internal
[ERROR] 1 error
[ERROR] 
[ERROR] Command line was: /home/mersault/.jabba/jdk/openjdk@17.0.2/bin/javadoc -preventleak com.datastax.oss.driver.internal com.datastax.dse.driver.internal -preventleak com.datastax.oss.driver.shaded -preventleak com.typesafe.config -preventleak com.codahale.metrics -preventleak org.HdrHistogram -preventleak io.netty -preventleak jnr -preventleak com.kenai.constantine -preventleak com.kenai.jffi -preventleak com.kenai.jnr -preventleak net.jpountz -preventleak org.xerial.snappy @options @packages
[ERROR] 
[ERROR] Refer to the generated Javadoc files in '/home/mersault/work/git/cassandra-java-driver-absurdfarce/guava-shaded/target/site/apidocs' dir.
[ERROR] 
[ERROR] -> [Help 1]

I'm wondering if the underlying issue here isn't just that there's no real source in guava-shaded and if that's causing the plugin to barf.

For now I've simply disabled this doclet all together. This is another change I'd like to revisit (and ideally revert) at some point in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant