Changeset 19541 in josm
- Timestamp:
- 2026-02-24T14:22:52+01:00 (22 hours ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 4 edited
-
PlatformHook.java (modified) (3 diffs)
-
PlatformHookOsx.java (modified) (1 diff)
-
PlatformHookWindows.java (modified) (1 diff)
-
Utils.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
r19139 r19541 17 17 import java.security.cert.CertificateException; 18 18 import java.security.cert.X509Certificate; 19 import java.text.DateFormat;20 19 import java.util.ArrayList; 21 20 import java.util.Collection; 22 21 import java.util.Collections; 23 import java.util.Date;24 22 import java.util.List; 25 23 … … 27 25 import org.openstreetmap.josm.io.CertificateAmendment.NativeCertAmend; 28 26 import org.openstreetmap.josm.spi.preferences.Config; 29 import org.openstreetmap.josm.tools.date.DateUtils;30 27 31 28 /** … … 292 289 */ 293 290 void sanityCheckFailed(String title, boolean canContinue, String... message); 294 }295 296 /**297 * Checks if the running version of Java has expired, proposes to user to update it if needed.298 * @param callback Java expiration callback299 * @since 12270 (signature)300 * @since 12219301 */302 default void checkExpiredJava(JavaExpirationCallback callback) {303 Date expiration = Utils.getJavaExpirationDate();304 if (expiration != null && expiration.before(new Date())) {305 String latestVersion = Utils.getJavaLatestVersion();306 String currentVersion = Utils.getSystemProperty("java.version");307 // #17831 WebStart may be launched with an expired JRE but then launching JOSM with up-to-date JRE308 if (latestVersion == null || !latestVersion.equalsIgnoreCase(currentVersion)) {309 callback.askUpdateJava(latestVersion != null ? latestVersion : "latest",310 Config.getPref().get("java.update.url", getJavaUrl()),311 DateUtils.getDateFormat(DateFormat.MEDIUM).format(expiration), false);312 }313 }314 291 } 315 292 -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r19205 r19541 91 91 } 92 92 warnSoonToBeUnsupportedJava(javaCallback); 93 checkExpiredJava(javaCallback);94 93 PlatformHook.super.startupHook(javaCallback, sanityCheckCallback); 95 94 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r19534 r19541 157 157 public void startupHook(JavaExpirationCallback javaCallback, SanityCheckCallback sanityCheckCallback) { 158 158 warnSoonToBeUnsupportedJava(javaCallback); 159 checkExpiredJava(javaCallback);160 159 PlatformHook.super.startupHook(javaCallback, sanityCheckCallback); 161 160 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r19437 r19541 32 32 import java.security.NoSuchAlgorithmException; 33 33 import java.text.Bidi; 34 import java.text.DateFormat;35 34 import java.text.MessageFormat; 36 35 import java.text.Normalizer; 37 import java.text.ParseException;38 36 import java.util.AbstractCollection; 39 37 import java.util.AbstractList; … … 42 40 import java.util.Collection; 43 41 import java.util.Collections; 44 import java.util.Date;45 42 import java.util.Iterator; 46 43 import java.util.List; … … 1706 1703 1707 1704 /** 1708 * Returns the JRE expiration date.1709 * @return the JRE expiration date, or null1710 * @since 122191711 */1712 public static Date getJavaExpirationDate() {1713 try {1714 Object value;1715 Class<?> c = Class.forName("com.sun.deploy.config.BuiltInProperties");1716 try {1717 value = c.getDeclaredField("JRE_EXPIRATION_DATE").get(null);1718 } catch (NoSuchFieldException e) {1719 // Field is gone with Java 9, there's a method instead1720 Logging.trace(e);1721 value = c.getDeclaredMethod("getProperty", String.class).invoke(null, "JRE_EXPIRATION_DATE");1722 }1723 if (value instanceof String) {1724 return DateFormat.getDateInstance(3, Locale.US).parse((String) value);1725 }1726 } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException | ParseException e) {1727 Logging.debug(e);1728 }1729 return null;1730 }1731 1732 /**1733 1705 * Returns the latest version of Java, from Oracle website. 1734 1706 * @return the latest version of Java, from Oracle website
Note:
See TracChangeset
for help on using the changeset viewer.
