-
Notifications
You must be signed in to change notification settings - Fork 56
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
test: use Java 17 to produce Java 8-compatible bytecode #1681
Conversation
suztomo
commented
May 15, 2023
•
edited
Loading
edited
- To use Maven surefire plugin's "jvm" option to run the tests on Java 8. https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jvm
- To use Java 17 to produce Java 8-compatible bytecode.
"build(8) except for gapic-generator-java" was stuck:
Retrying. |
@@ -84,7 +84,7 @@ static ChannelPool create(ChannelPoolSettings settings, ChannelFactory channelFa | |||
throws IOException { | |||
|
|||
// ProcessHandle was introduced in Java 9 | |||
System.out.println("ProcessHandle: " + java.lang.ProcessHandle.current()); | |||
System.out.println("org.graalvm.home.Version: " + org.graalvm.home.Version.parse("1.2.3")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This org.graalvm.home.Version
class is compiled for Java 11. Java 8 shouldn't be able to load it.
When using openjdk version "17.0.6" 2023-01-17
, the Maven test sdk-platform-java$ mvn test -am -pl gax-java/gax-grpc
(without the jvm property) succeeds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Java 8 check https://github.com/googleapis/sdk-platform-java/actions/runs/4982584325/jobs/8918462230?pr=1681 successfully detected this gap:
Error: Errors:
Error: ChannelPoolTest.callShouldCompleteAfterCreation:254 » UnsupportedClassVersion org/graalvm/home/Version has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Error: ChannelPoolTest.callShouldCompleteAfterStarted:303 » UnsupportedClassVersion org/graalvm/home/Version has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
"build(8) except for gapic-generator-java" passed: https://github.com/googleapis/sdk-platform-java/actions/runs/4982039825/jobs/8918034299 |
- name: Run test with Java 8 for all modules except gapic-generator-java | ||
shell: bash | ||
run: | | ||
set -x | ||
export JAVA_HOME=$JAVA8_HOME | ||
export PATH=${JAVA_HOME}/bin:$PATH | ||
# useIncrementalCompilation=false to avoid recompiling classes | ||
# generated by Java 11 compiler above. | ||
mvn -B -ntp test --projects '!gapic-generator-java' \ | ||
-Dcheckstyle.skip -Dmaven.compiler.useIncrementalCompilation=false \ | ||
-Dfmt.skip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: We used to run two Maven commands, one to compile and the other to run tests. However, the same thing can be done in one Maven command with surefire's jvm system property. This pull request includes that simplification.
value: "gcr.io/cloud-devrel-kokoro-resources/java11" | ||
value: "gcr.io/cloud-devrel-kokoro-resources/java17" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll produce Java 8-compatible bytecode using Java 17.
[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed! |
[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed! |
[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed! |
Confirming without a real release. Build ID b0a899d7-ed51-4b8b-b32b-0fb91876eac6 |
I confirmed the generated class files are for Java 8.
|