Skip to content

test: use Java 17 to produce Java 8-compatible bytecode#1681

Merged
suztomo merged 5 commits intogoogleapis:mainfrom
suztomo:main
May 15, 2023
Merged

test: use Java 17 to produce Java 8-compatible bytecode#1681
suztomo merged 5 commits intogoogleapis:mainfrom
suztomo:main

Conversation

@suztomo
Copy link
Member

@suztomo suztomo commented May 15, 2023

@suztomo suztomo requested a review from a team May 15, 2023 15:08
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label May 15, 2023
@suztomo suztomo changed the title test: java 8 when running Java 8 test test: use surefire's jvm property to run Java 8 tests May 15, 2023
@suztomo
Copy link
Member Author

suztomo commented May 15, 2023

"build(8) except for gapic-generator-java" was stuck:

[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.168 s - in com.google.api.gax.grpc.GrpcLongRunningTest
[INFO] Running com.google.api.gax.grpc.GrpcDirectStreamControllerTest
Error: The operation was canceled.

Retrying.


// 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"));
Copy link
Member Author

@suztomo suztomo May 15, 2023

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.

Copy link
Member Author

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

@suztomo
Copy link
Member Author

suztomo commented May 15, 2023

@suztomo suztomo changed the title test: use surefire's jvm property to run Java 8 tests test: use Java 17 to produce Java 8-compatible bytecode May 15, 2023
Comment on lines -81 to -91
- 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
Copy link
Member Author

@suztomo suztomo May 15, 2023

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.

env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java11"
value: "gcr.io/cloud-devrel-kokoro-resources/java17"
Copy link
Member Author

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.

@sonarqubecloud
Copy link

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@suztomo suztomo added the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2023
@sonarqubecloud
Copy link

[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarqubecloud
Copy link

[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@suztomo suztomo merged commit cc5724f into googleapis:main May 15, 2023
@suztomo
Copy link
Member Author

suztomo commented May 22, 2023

Confirming without a real release. Build ID b0a899d7-ed51-4b8b-b32b-0fb91876eac6

@suztomo
Copy link
Member Author

suztomo commented May 22, 2023

I confirmed the generated class files are for Java 8.

suztomo@suztomo2:~/sdk-platform-java$ javap -v -cp ~/.m2/repository/com/google/api/gapic-generator-java/2.19.1-SNAPSHOT/gapic-generator-java-2.19.1-SNAPSHOT.jar com/google/api/generator/Main |head
Classfile jar:file:///usr/local/google/home/suztomo/.m2/repository/com/google/api/gapic-generator-java/2.19.1-SNAPSHOT/gapic-generator-java-2.19.1-SNAPSHOT.jar!/com/google/api/generator/Main.class
  Last modified May 22, 2023; size 1754 bytes
  SHA-256 checksum bdb9b512c7a2ddc82beb46de8b47f47b9d825028d54d49c851f077f206ec529a
  Compiled from "Main.java"
public class com.google.api.generator.Main
  minor version: 0
  major version: 52
  flags: (0x0021) ACC_PUBLIC, ACC_SUPER
  this_class: #47                         // com/google/api/generator/Main
  super_class: #2                         // java/lang/Object

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

Labels

size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants