From 99c3ef8a57ed9064c2fa87ea5e97eb25a5c8001f Mon Sep 17 00:00:00 2001 From: Glavo Date: Sun, 20 Oct 2024 22:26:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20Java=20=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20(#3369)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update * update * update --- .../hmcl/download/java/JavaPackageType.java | 6 ++--- .../java/disco/DiscoFetchJavaListTask.java | 22 ++++++++++++++----- .../java/disco/DiscoJavaDistribution.java | 12 +++++++--- .../java/disco/DiscoJavaRemoteVersion.java | 2 +- .../org/jackhuang/hmcl/java/JavaInfo.java | 1 + 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/JavaPackageType.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/JavaPackageType.java index 42cc195d8..1512a1705 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/JavaPackageType.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/JavaPackageType.java @@ -21,10 +21,10 @@ package org.jackhuang.hmcl.download.java; * @author Glavo */ public enum JavaPackageType { - JDK(true, false), JRE(false, false), - JDKFX(true, true), - JREFX(false, true); + JDK(true, false), + JREFX(false, true), + JDKFX(true, true); private final boolean jdk; private final boolean javafx; diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoFetchJavaListTask.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoFetchJavaListTask.java index d4f333b34..adfd14cde 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoFetchJavaListTask.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoFetchJavaListTask.java @@ -46,22 +46,27 @@ public final class DiscoFetchJavaListTask extends Task fetchPackagesTask; public DiscoFetchJavaListTask(DownloadProvider downloadProvider, DiscoJavaDistribution distribution, Platform platform, JavaPackageType packageType) { this.distribution = distribution; + this.packageType = packageType.isJDK() ? "jdk" : "jre"; + this.isJavaFXBundled = packageType.isJavaFXBundled(); + this.archiveType = platform.getOperatingSystem() == OperatingSystem.WINDOWS ? "zip" : "tar.gz"; HashMap params = new HashMap<>(); params.put("distribution", distribution.getApiParameter()); - params.put("package", packageType.isJDK() ? "jdk" : "jre"); - params.put("javafx_bundled", Boolean.toString(packageType.isJavaFXBundled())); + params.put("package", this.packageType); + params.put("javafx_bundled", Boolean.toString(isJavaFXBundled)); params.put("operating_system", getOperatingSystemName(platform.getOperatingSystem())); params.put("architecture", getArchitectureName(platform.getArchitecture())); - params.put("archive_type", platform.getOperatingSystem() == OperatingSystem.WINDOWS ? "zip" : "tar.gz"); + params.put("archive_type", archiveType); params.put("directly_downloadable", "true"); - if (platform.getOperatingSystem() == OperatingSystem.LINUX) { + if (platform.getOperatingSystem() == OperatingSystem.LINUX) params.put("lib_c_type", "glibc"); - } this.fetchPackagesTask = new GetTask(downloadProvider.injectURLWithCandidates(NetworkUtils.withQuery(API_ROOT + "/packages", params))); } @@ -79,6 +84,13 @@ public final class DiscoFetchJavaListTask extends Task map = new TreeMap<>(); for (DiscoJavaRemoteVersion version : result) { + if (!distribution.getApiParameter().equals(version.getDistribution()) + || !version.isDirectlyDownloadable() + || !packageType.equals(version.getPackageType()) + || !archiveType.equals(version.getArchiveType()) + || isJavaFXBundled != version.isJavaFXBundled()) + continue; + if (!distribution.testVersion(version)) continue; diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoJavaDistribution.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoJavaDistribution.java index 52d013bf1..49a5005f3 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoJavaDistribution.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoJavaDistribution.java @@ -43,7 +43,7 @@ public enum DiscoJavaDistribution implements JavaDistribution