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

RATIS-2121. Set javac --release when compiling with JDK 9+ #1119

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

adoroszlai
Copy link
Contributor

@adoroszlai adoroszlai commented Jun 29, 2024

What changes were proposed in this pull request?

Java 9 introduced new javac option --release, which helps ensure compatibility with the given Java version (blog with great explanation). The goal of this change is to set this option when compiling with JDK 9+, instead of --source and --target.

--release expects version without the old-style 1. prefix (i.e. 8 instead of 1.8). maven-enforcer-plugin added support for the same in version 3.2.1, so we also need to bump the plugin.

https://issues.apache.org/jira/browse/RATIS-2121

How was this patch tested?

Compiled Ratis with JDK versions 8, 11, 17, targeting versions up to that of the JDK. Verified class file version.

for target in 8 11 17; do
  major=$(( target + 44 ))
  for jdk in 8 11 17; do
    if [[ $jdk -lt $target ]]; then break; fi
    JAVA_HOME=/usr/lib/jvm/java-${jdk}-openjdk-amd64 mvn -B -V -DskipTests clean package -Djavac.version=${target}
    javap -verbose ratis-common/target/classes/org/apache/ratis/RaftConfigKeys.class | grep "major version: $major"
  done
done

CI:
https://github.com/adoroszlai/ratis/actions/runs/9722037600

@adoroszlai adoroszlai self-assigned this Jun 29, 2024
@adoroszlai adoroszlai requested a review from szetszwo June 29, 2024 12:42
Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good.

@adoroszlai adoroszlai merged commit eeaf6a4 into apache:master Jul 1, 2024
12 checks passed
@adoroszlai adoroszlai deleted the RATIS-2121 branch July 1, 2024 05:41
@adoroszlai
Copy link
Contributor Author

Thanks @szetszwo for the review.

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