Changeset 18985 in josm
- Timestamp:
- 2024-02-14T18:11:54+01:00 (9 months ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r18974 r18985 77 77 <property name="dist-optimized.jar" location="${dist.dir}/josm-custom-optimized.jar"/> 78 78 <property name="dist-sources.jar" location="${dist.dir}/josm-custom-sources.jar"/> 79 <!-- When incrementing the minimum Java version, don't forget to update the Java versions users will update to 80 (PlatformHook#getJavaUrl, PlatformHook#startupSanityChecks and PlatformHook#warnSoonToBeUnsupportedJava) --> 79 81 <property name="java.lang.version" value="8" /> 80 82 <property name="test.headless" value="true" /> … … 300 302 <!-- Java 17 specific files (2021-09 LTS) --> 301 303 <call-javac-compile-mrjar release="17"/> 302 <!-- Java 18 specific files -->303 <call-javac-compile-mrjar release="18"/>304 <!-- Java 19 specific files -->305 <call-javac-compile-mrjar release="19"/>306 <!-- Java 20 specific files -->307 <call-javac-compile-mrjar release="20"/>308 304 <!-- Java 21 specific files (2023-09 LTS) --> 309 305 <call-javac-compile-mrjar release="21"/> -
trunk/native/linux/latest/DEBIAN/control
r18889 r18985 6 6 Priority: extra 7 7 Architecture: all 8 Depends: default-jre (>= 2:1.17) | java 8-runtime,8 Depends: default-jre (>= 2:1.17) | java11-runtime, 9 9 proj-data, fonts-noto, openjfx 10 10 Description: Editor for OpenStreetMap (daily development snapshot) -
trunk/native/linux/tested/DEBIAN/control
r18889 r18985 6 6 Priority: extra 7 7 Architecture: all 8 Depends: default-jre (>= 2:1.17) | java 8-runtime,8 Depends: default-jre (>= 2:1.17) | java11-runtime, 9 9 proj-data, fonts-noto, openjfx 10 10 Conflicts: josm-plugins -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r18801 r18985 58 58 import javax.swing.JOptionPane; 59 59 import javax.swing.JPanel; 60 import javax.swing.JTextPane; 60 61 import javax.swing.KeyStroke; 61 62 import javax.swing.LookAndFeel; … … 130 131 import org.openstreetmap.josm.gui.util.RedirectInputMap; 131 132 import org.openstreetmap.josm.gui.util.WindowGeometry; 133 import org.openstreetmap.josm.gui.widgets.TextContextualPopupMenu; 132 134 import org.openstreetmap.josm.gui.widgets.UrlLabel; 133 135 import org.openstreetmap.josm.io.CachedFile; … … 404 406 askUpdate(tr("Outdated Java WebStart version"), tr("Update to OpenWebStart"), "askUpdateWebStart", /* ICON */"presets/transport/rocket", content, url); 405 407 // CHECKSTYLE.ON: LineLength 408 } 409 410 /** 411 * Tells the user that a sanity check failed 412 * @param title The title of the message to show 413 * @param canContinue {@code true} if the failed sanity check(s) will not instantly kill JOSM when the user edits 414 * @param message The message parts to show the user (as a list) 415 */ 416 public static void sanityCheckFailed(String title, boolean canContinue, String... message) { 417 final ExtendedDialog ed; 418 if (canContinue) { 419 ed = new ExtendedDialog(mainFrame, title, tr("Stop"), tr("Continue")); 420 ed.setButtonIcons("cancel", "ok"); 421 } else { 422 ed = new ExtendedDialog(mainFrame, title, tr("Stop")); 423 ed.setButtonIcons("cancel"); 424 } 425 ed.setDefaultButton(1).setCancelButton(1); 426 // Check if the dialog has not already been permanently hidden by user 427 if (!ed.toggleEnable("sanityCheckFailed").toggleCheckState() || !canContinue) { 428 final String content = Arrays.stream(message).collect(Collectors.joining("</li><li>", 429 "<html><body><ul><li>", "</li></ul></body></html>")); 430 final JTextPane textField = new JTextPane(); 431 textField.setContentType("text/html"); 432 textField.setText(content); 433 TextContextualPopupMenu.enableMenuFor(textField, true); 434 ed.setMinimumSize(new Dimension(480, 300)); 435 ed.setIcon(JOptionPane.WARNING_MESSAGE); 436 ed.setContent(textField); 437 ed.showDialog(); 438 } 439 if (!canContinue || ed.getValue() <= 1) { // 0 == cancel (we want to stop) and 1 == stop 440 Lifecycle.exitJosm(true, -1); 441 } 406 442 } 407 443 -
trunk/src/org/openstreetmap/josm/gui/MainInitialization.java
r17679 r18985 72 72 new InitializationTask(tr("Starting file watcher"), FileWatcher.getDefaultInstance()::start), 73 73 new InitializationTask(tr("Executing platform startup hook"), 74 () -> PlatformManager.getPlatform().startupHook(MainApplication::askUpdateJava, MainApplication::askMigrateWebStart)), 74 () -> PlatformManager.getPlatform().startupHook(MainApplication::askUpdateJava, 75 MainApplication::askMigrateWebStart, MainApplication::sanityCheckFailed)), 75 76 new InitializationTask(tr("Building main menu"), application::initializeMainWindow), 76 77 new InitializationTask(tr("Updating user interface"), () -> { -
trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
r18790 r18985 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.awt.GraphicsEnvironment; … … 9 11 import java.io.IOException; 10 12 import java.io.InputStreamReader; 13 import java.lang.management.ManagementFactory; 11 14 import java.nio.charset.StandardCharsets; 12 15 import java.security.KeyStoreException; … … 15 18 import java.security.cert.X509Certificate; 16 19 import java.text.DateFormat; 20 import java.util.ArrayList; 17 21 import java.util.Collection; 18 22 import java.util.Collections; … … 87 91 * @param javaCallback Java expiration callback, providing GUI feedback 88 92 * @param webStartCallback WebStart migration callback, providing GUI feedback 89 * @since 1 7679 (signature)93 * @since 18985 90 94 */ 91 default void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) { 92 // Do nothing 95 default void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback, 96 SanityCheckCallback sanityCheckCallback) { 97 startupSanityChecks(sanityCheckCallback); 93 98 } 94 99 … … 288 293 289 294 /** 295 * Inform the user that a sanity check or checks failed 296 */ 297 @FunctionalInterface 298 interface SanityCheckCallback { 299 /** 300 * Tells the user that a sanity check failed 301 * @param title The title of the message to show 302 * @param canContinue {@code true} if the failed sanity check(s) will not instantly kill JOSM when the user edits 303 * @param message The message parts to show the user (as a list) 304 */ 305 void sanityCheckFailed(String title, boolean canContinue, String... message); 306 } 307 308 /** 290 309 * Checks if the running version of Java has expired, proposes to user to update it if needed. 291 310 * @param callback Java expiration callback … … 332 351 */ 333 352 default String getJavaUrl() { 334 StringBuilder defaultDownloadUrl = new StringBuilder("https://www.azul.com/downloads/?version=java- 17-lts");353 StringBuilder defaultDownloadUrl = new StringBuilder("https://www.azul.com/downloads/?version=java-21-lts"); 335 354 if (PlatformManager.isPlatformWindows()) { 336 355 defaultDownloadUrl.append("&os=windows"); … … 370 389 } 371 390 391 default void startupSanityChecks(SanityCheckCallback sanityCheckCallback) { 392 final String arch = System.getProperty("os.arch"); 393 final List<String> messages = new ArrayList<>(); 394 final String jvmArch = System.getProperty("sun.arch.data.model"); 395 boolean canContinue = true; 396 if (Utils.getJavaVersion() < 11) { 397 canContinue = false; 398 messages.add(tr("You must update Java to Java {0} or later in order to run this version of JOSM", 17)); 399 // Reset webstart/java update prompts 400 Config.getPref().put("askUpdateWebStart", null); 401 Config.getPref().put("askUpdateJava" + Utils.getJavaLatestVersion(), null); 402 Config.getPref().put("askUpdateJavalatest", null); 403 } 404 if (!"x86".equals(arch) && "32".equals(jvmArch)) { 405 messages.add(tr("Please use a 64 bit version of Java -- this will avoid out of memory errors")); 406 } 407 // Note: these might be able to be removed with the appropriate module-info.java settings. 408 final String[] expectedJvmArguments = { 409 "--add-exports=java.base/sun.security.action=ALL-UNNAMED", 410 "--add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED", 411 "--add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED" 412 }; 413 final List<String> vmArguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); 414 final StringBuilder missingArguments = new StringBuilder(); 415 for (String arg : expectedJvmArguments) { 416 if (!vmArguments.contains(arg)) { 417 if (missingArguments.length() > 0) { 418 missingArguments.append("<br>"); 419 } 420 missingArguments.append(arg); 421 } 422 } 423 if (missingArguments.length() > 0) { 424 final String args = missingArguments.toString(); 425 messages.add(tr("Missing JVM Arguments:<br>{0}", args)); 426 } 427 if (!messages.isEmpty()) { 428 if (canContinue) { 429 sanityCheckCallback.sanityCheckFailed(tr("JOSM may work improperly"), true, 430 messages.toArray(new String[0])); 431 } else { 432 sanityCheckCallback.sanityCheckFailed(tr("JOSM will be unable to work properly and will exit"), false, 433 messages.toArray(new String[0])); 434 } 435 } 436 } 437 372 438 /** 373 439 * Called when interfacing with native OS functions. Currently only used with macOS. -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r18771 r18985 69 69 70 70 @Override 71 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) { 71 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback, 72 SanityCheckCallback sanityCheckCallback) { 72 73 // Here we register callbacks for the menu entries in the system menu and file opening through double-click 73 74 // https://openjdk.java.net/jeps/272 … … 107 108 checkExpiredJava(javaCallback); 108 109 checkWebStartMigration(webStartCallback); 110 PlatformHook.super.startupHook(javaCallback, webStartCallback, sanityCheckCallback); 109 111 } 110 112 -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r18580 r18985 64 64 65 65 @Override 66 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) { 66 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback, 67 SanityCheckCallback sanityCheckCallback) { 67 68 checkWebStartMigration(webStartCallback); 69 PlatformHook.super.startupHook(javaCallback, webStartCallback, sanityCheckCallback); 68 70 } 69 71 -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r18801 r18985 154 154 155 155 @Override 156 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) { 156 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback, 157 SanityCheckCallback sanityCheckCallback) { 157 158 warnSoonToBeUnsupportedJava(javaCallback); 158 159 checkExpiredJava(javaCallback); 159 160 checkWebStartMigration(webStartCallback); 161 PlatformHook.super.startupHook(javaCallback, webStartCallback, sanityCheckCallback); 160 162 } 161 163 -
trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookOsxTest.java
r18853 r18985 35 35 @Test 36 36 void testStartupHook() { 37 hook.startupHook((a, b, c, d) -> System.out.println("java callback"), u -> System.out.println("webstart callback")); 37 hook.startupHook((a, b, c, d) -> System.out.println("java callback"), u -> System.out.println("webstart callback"), 38 (a, b, c) -> System.out.println("sanity check callback")); 38 39 } 39 40 -
trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java
r18893 r18985 47 47 final PlatformHook.JavaExpirationCallback javaCallback = (a, b, c, d) -> System.out.println("java callback"); 48 48 final PlatformHook.WebStartMigrationCallback webstartCallback = u -> System.out.println("webstart callback"); 49 assertDoesNotThrow(() -> hook.startupHook(javaCallback, webstartCallback)); 49 final PlatformHook.SanityCheckCallback sanityCheckCallback = (a, b, c) -> System.out.println("sanity check callback"); 50 assertDoesNotThrow(() -> hook.startupHook(javaCallback, webstartCallback, sanityCheckCallback)); 50 51 } 51 52
Note:
See TracChangeset
for help on using the changeset viewer.