CASSJAVA-135 Update the build to use Java17 rather than Java8 - #2096
CASSJAVA-135 Update the build to use Java17 rather than Java8#2096absurdfarce wants to merge 15 commits into
Conversation
| <module>bom</module> | ||
| </modules> | ||
| <properties> | ||
| <maven.compiler.release>17</maven.compiler.release> |
There was a problem hiding this comment.
This change replaces the source + target designations used in earlier Maven builds
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <compilerId>javac-with-errorprone</compilerId> | ||
| <forceJavacCompilerUse>true</forceJavacCompilerUse> |
There was a problem hiding this comment.
Replaced by "forceLegacyJavaApi" use below
There was a problem hiding this comment.
Actually this is no longer needed now that we've moved to the new mechanism for deploying errorprone with Java17.
| <compilerArg>-Xep:AnnotateFormatMethod:OFF</compilerArg> | ||
| <compilerArg>-Xep:WildcardImport:WARN</compilerArg> | ||
| <compilerArg>-XepExcludedPaths:.*/target/(?:generated-sources|generated-test-sources)/.*</compilerArg> | ||
| </compilerArgs> |
There was a problem hiding this comment.
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.
| <forceLegacyJavacApi>true</forceLegacyJavacApi> | ||
| <showWarnings>true</showWarnings> | ||
| <failOnWarning>true</failOnWarning> | ||
| <failOnWarning>false</failOnWarning> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I've subsequently worked around the original issue by removing the annotation and bringing in static code (more on that elsewhere) but I'm inclined to keep "failOnWarning" set to false. With this setting we still try to run through the entire test suite meaning a single run can give us more useful info about the full range of test failures for the entire source at a given git commit. Perhaps as importantly it also prevents the build from cratering if a single "sketchy" test happens to act up during the current build.
| </additionalJOptions> | ||
| <useStandardDocletOptions>false</useStandardDocletOptions> | ||
| </configuration> | ||
| </execution> |
There was a problem hiding this comment.
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.
…otation processors for integration tests to handle everything except the SocialTraversalDsl case.
| <!-- for DriverBlockHoundIntegrationIT when using JDK 13+, see https://github.com/reactor/BlockHound/issues/33 --> | ||
| <blockhound.argline>-XX:+AllowRedefinitionToAddDeleteMethods</blockhound.argline> | ||
| <!-- allow deep reflection for mockito when using JDK 17+, see https://stackoverflow.com/questions/70993863/mockito-can-not-mock-random-in-java-17 --> | ||
| <mockitoopens.argline>--add-opens=java.base/jdk.internal.util.random=ALL-UNNAMED</mockitoopens.argline> |
There was a problem hiding this comment.
This was the configured setting for both Java17 and Java21 under the old regime of per-JVM settings. Folding these into the defaults since they're both common now... we can always break them out again if we need to (if Java25 needs something different, say).
| environment { | ||
| OS_VERSION = 'ubuntu/focal64/java-driver' | ||
| JABBA_SHELL = '/usr/lib/jabba/jabba.sh' | ||
| BUILD_JAVA_VERSION = "openjdk@1.17" |
There was a problem hiding this comment.
A significant simplification of what we had here. We define a single Java version used to build (and drive testing of) the driver here and all invocations elsewhere reference this. We were doing something functionally equivalent by passing the Java version for building the driver in as a param... this just simplifies everything in one place.
| else | ||
| SKIP_JAVADOCS=false | ||
| fi | ||
| jabba use ${BUILD_JAVA_VERSION} |
There was a problem hiding this comment.
We'll run Maven with the fixed Java version even though individual tests will be run via a (perhaps different) Java version passed in via the "testJavaHome" param.
| jabba which 1.8''', returnStdout: true).trim() | ||
| env.JAVA11_HOME = sh(label: 'Get JAVA11_HOME (in case ccm needs it)',script: '''#!/bin/bash -le | ||
| . ${JABBA_SHELL} | ||
| jabba which openjdk@11''', returnStdout: true).trim() |
There was a problem hiding this comment.
Adding Java11 for sake of completeness. I believe at some point we lose support for Java8 on some Cassandra servers so really we're just trying to get out in front of things here.
| import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; | ||
| import org.apache.tinkerpop.gremlin.structure.Vertex; | ||
|
|
||
| @GremlinDsl(traversalSource = "com.datastax.dse.driver.api.core.graph.SocialTraversalSourceDsl") |
There was a problem hiding this comment.
No longer necessary now that we've brought in static Java source to represent the generated source code... see below for more on this.
| @@ -0,0 +1,55 @@ | |||
| /* | |||
There was a problem hiding this comment.
DefaultSocialTraversal, SocialTraversal and SocialTraversalSource were extracted from a local Java8 build which generated these sources via the older GremlinDsl annotation. That annotation explicitly supports only Java8 (and is only used here for testing) so rather than shift to some new test DSL that might be more friendly to Java17 it seemed easiest to just fix the generated source in the repo and move on.
| import org.apache.tinkerpop.gremlin.process.traversal.Traversal; | ||
| import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; | ||
| import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; | ||
| import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; |
There was a problem hiding this comment.
All the usages of the anonymous traversal class (the "double underscore") leverage base functionality provided by the Tinkerpop version and don't obviously require the customized GremlinDsl generated version. In order to minimize the amount of generated code we want to preserve in amber here it seemed worthwhile to just drop the anonymous traversal stuff all together.
|
These changes got to a nearly green run on DataStax/IBM Jenkins. There were a few test failures for things like ccm timeouts and approximations of zero in a few places but they all look spurious to me (I'll very likely be creating tickets for one or two of them to avoid them returning). |
|
Ping @tolbertam for discovery... for some reason I couldn't add you as a reviewer. |
Change the build to use Java17 for compiling the driver