Changeset 18580 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2022-10-24T19:55:28+02:00 (2 years ago)
Author:
taylor.smock
Message:

See #17858: start linking to Java 17 for Java updates.

The link for the Java download page now goes to azul.com, and attempts to pre-fill as
much of the download form as possible.

This also adds a method to warn users running Java 10 or earlier that their version
of Java will soon be unsupported by JOSM. This only affects users using Java 10 or
earlier if they are not running JOSM using WebStart.

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r18116 r18580  
    301301            if (latestVersion == null || !latestVersion.equalsIgnoreCase(currentVersion)) {
    302302                callback.askUpdateJava(latestVersion != null ? latestVersion : "latest",
    303                         Config.getPref().get("java.update.url", "https://www.java.com/download"),
     303                        Config.getPref().get("java.update.url", getJavaUrl()),
    304304                        DateUtils.getDateFormat(DateFormat.MEDIUM).format(expiration), false);
    305305            }
    306306        }
     307    }
     308
     309    /**
     310     * Checks if we will soon not be supporting the running version of Java
     311     * @param callback Java expiration callback
     312     * @since 18580
     313     */
     314    default void warnSoonToBeUnsupportedJava(JavaExpirationCallback callback) {
     315        // Java 11 is our next minimum version, and OpenWebStart should be replacing Oracle WebStart
     316        // We'd go to 17, but some Linux distributions (Debian) default to Java 11.
     317        // And OpenWebStart currently doesn't have Java 17 JREs.
     318        if (Utils.getJavaVersion() < 11 && !Utils.isRunningWebStart()) {
     319            String latestVersion = Utils.getJavaLatestVersion();
     320            String currentVersion = Utils.getSystemProperty("java.version");
     321            // #17831 WebStart may be launched with an expired JRE but then launching JOSM with up-to-date JRE
     322            if (latestVersion == null || !latestVersion.equalsIgnoreCase(currentVersion)) {
     323                callback.askUpdateJava(latestVersion != null ? latestVersion : "latest",
     324                        Config.getPref().get("java.update.url", getJavaUrl()),
     325                        null, Utils.getJavaVersion() < 17);
     326            }
     327        }
     328    }
     329
     330    /**
     331     * Get the Java download URL (really shouldn't be used outside of JOSM startup checks)
     332     * @return The download URL to use.
     333     * @since 18580
     334     */
     335    default String getJavaUrl() {
     336        StringBuilder defaultDownloadUrl = new StringBuilder("https://www.azul.com/downloads/?version=java-17-lts&package=jre-fx");
     337        if (PlatformManager.isPlatformWindows()) {
     338            defaultDownloadUrl.append("&os=windows");
     339        } else if (PlatformManager.isPlatformOsx()) {
     340            defaultDownloadUrl.append("&os=macos");
     341        } // else probably `linux`, but they should be using a package manager.
     342        // For available architectures, see
     343        // https://github.com/openjdk/jdk/blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java#L53
     344        String osArch = System.getProperty("os.arch");
     345        if (osArch != null) {
     346            // See https://learn.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details#environment-variables
     347            // for PROCESSOR_ARCHITEW6432
     348            if ("x86_64".equals(osArch) || "amd64".equals(osArch)
     349                    || "AMD64".equalsIgnoreCase(System.getenv("PROCESSOR_ARCHITEW6432"))) {
     350                defaultDownloadUrl.append("&architecture=x86-64-bit");
     351            } else if ("aarch64".equals(osArch)) {
     352                defaultDownloadUrl.append("&architecture=arm-64-bit");
     353            } else if ("x86".equals(osArch)) {
     354                // Honestly, just about everyone should be on x86_64 at this point. But just in case someone
     355                // is running JOSM on a 10-year-old computer. They'd probably be better off running a RPi.
     356                defaultDownloadUrl.append("&architecture=x86-32-bit");
     357            } // else user will have to figure it out themselves.
     358        }
     359        defaultDownloadUrl.append("#download-openjdk"); // Scrolls to download section
     360        return defaultDownloadUrl.toString();
    307361    }
    308362
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r18141 r18580  
    9595            Logging.warn("Failed to register with macOS: " + ex);
    9696        }
     97        warnSoonToBeUnsupportedJava(javaCallback);
    9798        checkExpiredJava(javaCallback);
    9899        checkWebStartMigration(webStartCallback);
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r18211 r18580  
    189189        } else if (home.contains("java-11-openjdk")) {
    190190            return getPackageDetails("openjdk-11-jre", "java-11-openjdk");
     191        } else if (home.contains("java-17-openjdk")) {
     192            return getPackageDetails("openjdk-17-jre", "java-17-openjdk");
    191193        } else if (home.contains("java-openjdk")) {
    192194            return getPackageDetails("java-openjdk");
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r18208 r18580  
    155155    @Override
    156156    public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) {
     157        warnSoonToBeUnsupportedJava(javaCallback);
    157158        checkExpiredJava(javaCallback);
    158159        checkWebStartMigration(webStartCallback);
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r18556 r18580  
    18061806                            Config.getUrls().getJOSMWebsite() + "/remote/oracle-java-update-baseline.version")))
    18071807                    .connect().fetchContent().split("\n", -1);
    1808             if (getJavaVersion() <= 8) {
     1808            if (getJavaVersion() <= 11 && isRunningWebStart()) { // OpenWebStart currently only has Java 11
    18091809                for (String version : versions) {
    1810                     if (version.startsWith("1.8")) {
     1810                    if (version.startsWith("11")) {
     1811                        return version;
     1812                    }
     1813                }
     1814            } else if (getJavaVersion() <= 17) {
     1815                for (String version : versions) {
     1816                    if (version.startsWith("17")) { // Use current Java LTS
    18111817                        return version;
    18121818                    }
Note: See TracChangeset for help on using the changeset viewer.