Skip to content

Commit

Permalink
Fix GitHub actions (#998)
Browse files Browse the repository at this point in the history
Add workaround for JDK-8240734
Closes #995
  • Loading branch information
tresf authored Aug 4, 2022
1 parent edcfa39 commit aeadb1b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/qz/build/JLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public JLink(String targetPlatform, String arch, String gcEngine) throws IOExcep
this.javaVendor = getJavaVendor(arch);
this.targetPlatform = targetPlatform;

// jdeps and jlink require matching major JDK versions. Download if needed.
if(Constants.JAVA_VERSION.getMajorVersion() != Integer.parseInt(JAVA_MAJOR)) {
if(needsDownload(SystemUtilities.getJavaVersion(JAVA_VERSION), Constants.JAVA_VERSION)) {
log.warn("Java versions are incompatible, locating a suitable runtime for Java " + JAVA_MAJOR + "...");
String hostArch = System.getProperty("os.arch");
String hostJdk = downloadJdk(getJavaVendor(hostArch), null, hostArch, gcEngine);
Expand Down Expand Up @@ -83,6 +82,26 @@ public static void main(String ... args) throws IOException {
args.length > 2 ? args[2] : null);
}

/**
* Handle incompatibilities between JDKs, download a fresh one if needed
*/
private static boolean needsDownload(Version want, Version installed) {
// jdeps and jlink historically require matching major JDK versions. Download if needed.
boolean downloadJdk = installed.getMajorVersion() != want.getMajorVersion();

// Per JDK-8240734: Major versions checks aren't enough starting with 11.0.16+8
// see also https://github.com/adoptium/adoptium-support/issues/557
Version bad = SystemUtilities.getJavaVersion("11.0.16+8");
if(installed.greaterThanOrEqualTo(bad)) {
if(want.lessThan(bad)) {
// Force download
// Fixes "Hash of java.rmi differs from expected hash"
downloadJdk = true;
}
}
return downloadJdk;
}

private String getJavaVendor(String arch) {
String vendor;
switch(SystemUtilities.getJreArch(arch)) {
Expand Down

0 comments on commit aeadb1b

Please sign in to comment.