diff --git a/build/build.xml b/build/build.xml index 1da3f484c..c0ff1817f 100644 --- a/build/build.xml +++ b/build/build.xml @@ -372,7 +372,6 @@ platform="${target-platform}${jdk.data.model}" update="${jdk.update}" build="${jdk.build}" - hash="${jdk.hash}" component="JDK" flavor="${jdk.downloader}" path="${jdk.tgz.path}" /> diff --git a/build/jre/.classpath b/build/jre/.classpath index c80e3eaa9..9dae3ca4c 100644 --- a/build/jre/.classpath +++ b/build/jre/.classpath @@ -1,7 +1,11 @@ - + + + + + diff --git a/build/jre/.settings/org.eclipse.jdt.core.prefs b/build/jre/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..7adc0fb9a --- /dev/null +++ b/build/jre/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/build/jre/src/AdoptOpenJdkDownloadUrlGenerator.java b/build/jre/src/AdoptOpenJdkDownloadUrlGenerator.java index 7ede8c52b..92b40e1b6 100644 --- a/build/jre/src/AdoptOpenJdkDownloadUrlGenerator.java +++ b/build/jre/src/AdoptOpenJdkDownloadUrlGenerator.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2019 The Processing Foundation + Copyright (c) 2019-20 The Processing Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,12 +23,14 @@ * Utility to generate download URLs from AdoptOpenJDK. */ public class AdoptOpenJdkDownloadUrlGenerator extends DownloadUrlGenerator { + static private final String BASE_URL = + "https://github.com/AdoptOpenJDK/openjdk%d-binaries/releases/download/jdk-%d.%d.%d%%2B%d/OpenJDK%dU-%s_%d.%d.%d_%d.%s"; - private static final String BASE_URL = "https://github.com/AdoptOpenJDK/openjdk%d-binaries/releases/download/jdk-%d.%d.%d%%2B%d/OpenJDK%dU-%s_%d.%d.%d_%d.%s"; @Override - public String buildUrl(String platform, String component, int train, int version, int update, - int build, String flavor, String hash) { + public String buildUrl(String platform, String component, + int train, int version, int update, + int build, String flavor) { if (!component.equalsIgnoreCase("jdk")) { throw new RuntimeException("Can only generate JDK download URLs for AdoptOpenJDK."); @@ -53,6 +55,7 @@ public class AdoptOpenJdkDownloadUrlGenerator extends DownloadUrlGenerator { ); } + /** * Build a the filename (the "flavor") that is expected on AdoptOpenJDK. * @@ -72,6 +75,7 @@ public class AdoptOpenJdkDownloadUrlGenerator extends DownloadUrlGenerator { } } + /** * Determine the download file extension. * diff --git a/build/jre/src/DownloadUrlGenerator.java b/build/jre/src/DownloadUrlGenerator.java index 02e0d62c4..08e3541d1 100644 --- a/build/jre/src/DownloadUrlGenerator.java +++ b/build/jre/src/DownloadUrlGenerator.java @@ -40,8 +40,9 @@ public abstract class DownloadUrlGenerator { * @param flavor The flavor like "macosx-x64.dmg". * @param hash The hash like "d54c1d3a095b4ff2b6607d096fa80163". */ - public abstract String buildUrl(String platform, String component, int train, int version, - int update, int build, String flavor, String hash); + public abstract String buildUrl(String platform, String component, + int train, int version, int update, + int build, String flavor); /** * Get the cookie that should be used in downloading the target component. @@ -64,10 +65,10 @@ public abstract class DownloadUrlGenerator { * @param update The update (like 13). * @param build The build number (like 133). * @param flavor The flavor like "macosx-x64.dmg". - * @param hash The hash like "d54c1d3a095b4ff2b6607d096fa80163". */ - public String getLocalFilename(String downloadPlatform, String component, int train, int version, - int update, int build, String flavor, String hash) { + public String getLocalFilename(String downloadPlatform, String component, + int train, int version, int update, + int build, String flavor) { String baseFilename = component.toLowerCase(); diff --git a/build/jre/src/Downloader.java b/build/jre/src/Downloader.java index 8828cb595..575faa824 100644 --- a/build/jre/src/Downloader.java +++ b/build/jre/src/Downloader.java @@ -33,20 +33,14 @@ import org.apache.tools.ant.Task; public class Downloader extends Task { private static final boolean PRINT_LOGGING = true; - private boolean openJdk; // If using openJDK. private String platform; // macos private int train; // Java 11 (was 1 through Java 8) private int version; // 0 (was 8 prior to Java 9) - private int update; // Update 131 - private int build; // Build 11 - // https://gist.github.com/P7h/9741922 - // http://stackoverflow.com/q/10268583 - private String hash; // d54c1d3a095b4ff2b6607d096fa80163 - - private String component; // "JRE", "JDK", or "JFX" - - private String flavor; // Like "zip" + private int update; // Update 131 + private int build; // Build 11 + private String component; // "jre", "jdk", or "jfx" + private String flavor; // Like "zip" private String path; // target path @@ -55,6 +49,7 @@ public class Downloader extends Task { **/ public Downloader() { } + /** * Set the platform being used. * @@ -64,14 +59,6 @@ public class Downloader extends Task { this.platform = platform; } - /** - * Indicate if the OpenJDK is being used. - * - * @param openJdk True if OpenJDK is being used. False if Oracle JDK is being used. - */ - public void setOpenJdk(boolean openJdk) { - this.openJdk = openJdk; - } /** * Specify the build train being used. @@ -82,6 +69,7 @@ public class Downloader extends Task { this.train = train; } + /** * Set the version to download within the given build train. * @@ -91,6 +79,7 @@ public class Downloader extends Task { this.version = version; } + /** * Set the update number to download within the given build train. * @@ -100,6 +89,7 @@ public class Downloader extends Task { this.update = update; } + /** * Set the build number to download. * @@ -109,14 +99,6 @@ public class Downloader extends Task { this.build = build; } - /** - * Set the expected hash of the download. - * - * @param hash The hash set. - */ - public void setHash(String hash) { - this.hash = hash; - } /** * Indicate what component or release type of Java is being downloaded. @@ -127,6 +109,7 @@ public class Downloader extends Task { this.component = component; } + /** * Indicate the file flavor to be downloaded. * @@ -136,6 +119,7 @@ public class Downloader extends Task { this.flavor = flavor; } + /** * Set the path to which the file should be downloaded. * @@ -145,6 +129,7 @@ public class Downloader extends Task { this.path = path; } + /** * Download the JDK or JRE. */ @@ -167,11 +152,6 @@ public class Downloader extends Task { throw new BuildException("You've gotta choose a flavor (macosx-x64.dmg, windows-x64.exe...)"); } - if (update >= 121 && hash == null) { - throw new BuildException("Starting with 8u121, a hash is required, see https://gist.github.com/P7h/9741922"); - } - - //download(path, jdk, platform, bits, version, update, build); try { download(); } catch (IOException e) { @@ -179,6 +159,7 @@ public class Downloader extends Task { } } + /** * Download the package from AdoptOpenJDK or Oracle. */ @@ -310,17 +291,9 @@ public class Downloader extends Task { // Determine url generator if (isJavaDownload) { - if (openJdk) { - downloadUrlGenerator = new AdoptOpenJdkDownloadUrlGenerator(); - } else { - downloadUrlGenerator = new OracleDownloadUrlGenerator(); - } + downloadUrlGenerator = new AdoptOpenJdkDownloadUrlGenerator(); } else if (isJfxDownload) { - if (openJdk) { - downloadUrlGenerator = new GluonHqDownloadUrlGenerator(); - } else { - return Optional.empty(); // Nothing to download - } + downloadUrlGenerator = new GluonHqDownloadUrlGenerator(); } else { throw new RuntimeException("Do not know how to download: " + component); } @@ -333,8 +306,7 @@ public class Downloader extends Task { version, update, build, - flavor, - hash + flavor ); String url = downloadUrlGenerator.buildUrl( @@ -344,8 +316,7 @@ public class Downloader extends Task { version, update, build, - flavor, - hash + flavor ); return Optional.of(new DownloadItem(url, path, downloadUrlGenerator.getCookie())); diff --git a/build/jre/src/GluonHqDownloadUrlGenerator.java b/build/jre/src/GluonHqDownloadUrlGenerator.java index d11fc5df3..77ef62677 100644 --- a/build/jre/src/GluonHqDownloadUrlGenerator.java +++ b/build/jre/src/GluonHqDownloadUrlGenerator.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2014-19 The Processing Foundation + Copyright (c) 2014-20 The Processing Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -29,7 +29,7 @@ public class GluonHqDownloadUrlGenerator extends DownloadUrlGenerator { @Override public String buildUrl(String platform, String component, int train, int version, int update, - int build, String flavor, String hash) { + int build, String flavor) { String platformLower = platform.toLowerCase(); diff --git a/build/jre/src/OracleDownloadUrlGenerator.java b/build/jre/src/OracleDownloadUrlGenerator.java deleted file mode 100644 index 2984bfa1c..000000000 --- a/build/jre/src/OracleDownloadUrlGenerator.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2014-19 The Processing Foundation - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -import java.util.Optional; - -/** - * Utility to generate the download URL from Oracle. - */ -public class OracleDownloadUrlGenerator extends DownloadUrlGenerator { - private static final String COOKIE = - "oraclelicense=accept-securebackup-cookie"; - - - @Override - public String buildUrl(String platform, String component, int train, int version, int update, - int build, String flavor, String hash) { - - if (!component.equalsIgnoreCase("jdk")) { - throw new RuntimeException("Can only generate JDK download URLs for Oracle."); - } - - String filename = getLocalFilename( - platform, - component, - train, - version, - update, - build, - flavor, - hash - ); - - String url = "http://download.oracle.com/otn-pub/java/jdk/" + - (update == 0 ? - String.format("%d-b%02d/", version, build) : - String.format("%du%d-b%02d/", version, update, build)); - - // URL format changed starting with 8u121 - if (update >= 121) { - url += hash + "/"; - } - - // Finally, add the filename to the end - url += filename; - - return url; - } - - public Optional getCookie() { - return Optional.of(COOKIE); - } - -}