Index: /trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 19108)
+++ /trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 19109)
@@ -8,5 +8,4 @@
 
 import java.awt.AWTError;
-import java.awt.Color;
 import java.awt.Container;
 import java.awt.Dimension;
@@ -19,5 +18,4 @@
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Field;
 import java.net.Authenticator;
 import java.net.Inet6Address;
@@ -42,5 +40,4 @@
 import java.util.Objects;
 import java.util.Optional;
-import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.TreeSet;
@@ -165,7 +162,5 @@
 import org.openstreetmap.josm.tools.OsmUrlToBounds;
 import org.openstreetmap.josm.tools.PlatformHook.NativeOsCallback;
-import org.openstreetmap.josm.tools.PlatformHookWindows;
 import org.openstreetmap.josm.tools.PlatformManager;
-import org.openstreetmap.josm.tools.ReflectionUtils;
 import org.openstreetmap.josm.tools.Shortcut;
 import org.openstreetmap.josm.tools.Utils;
@@ -1069,17 +1064,4 @@
         Utils.updateSystemProperty("http.agent", Version.getInstance().getAgentString());
         Utils.updateSystemProperty("user.language", Config.getPref().get("language"));
-        // Workaround to fix a Java bug. This ugly hack comes from Sun bug database: https://bugs.openjdk.java.net/browse/JDK-6292739
-        // Force AWT toolkit to update its internal preferences (fix #6345).
-        // Does not work anymore with Java 9, to remove with Java 9 migration
-        if (Utils.getJavaVersion() < 9 && !GraphicsEnvironment.isHeadless()) {
-            try {
-                Field field = Toolkit.class.getDeclaredField("resources");
-                ReflectionUtils.setObjectsAccessible(field);
-                field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt"));
-            } catch (ReflectiveOperationException | RuntimeException e) { // NOPMD
-                // Catch RuntimeException in order to catch InaccessibleObjectException, new in Java 9
-                Logging.log(Logging.LEVEL_WARN, null, e);
-            }
-        }
         // Possibility to disable SNI (not by default) in case of misconfigured https servers
         // See #9875 + http://stackoverflow.com/a/14884941/2257172
@@ -1116,42 +1098,4 @@
     static void applyLaFWorkarounds() {
         final String laf = UIManager.getLookAndFeel().getID();
-        final int javaVersion = Utils.getJavaVersion();
-        // Workaround for JDK-8180379: crash on Windows 10 1703 with Windows L&F and java < 8u141 / 9+172
-        // To remove during Java 9 migration
-        if (getSystemProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows 10") &&
-                PlatformManager.getPlatform().getDefaultStyle().equals(LafPreference.LAF.get())) {
-            try {
-                String build = PlatformHookWindows.getCurrentBuild();
-                if (build != null) {
-                    final int currentBuild = Integer.parseInt(build);
-                    final int javaUpdate = Utils.getJavaUpdate();
-                    final int javaBuild = Utils.getJavaBuild();
-                    // See https://technet.microsoft.com/en-us/windows/release-info.aspx
-                    if (currentBuild >= 15_063 && ((javaVersion == 8 && javaUpdate < 141)
-                            || (javaVersion == 9 && javaUpdate == 0 && javaBuild < 173))) {
-                        // Workaround from https://bugs.openjdk.java.net/browse/JDK-8179014
-                        UIManager.put("FileChooser.useSystemExtensionHiding", Boolean.FALSE);
-                    }
-                }
-            } catch (NumberFormatException | ReflectiveOperationException | JosmRuntimeException e) {
-                Logging.error(e);
-            } catch (ExceptionInInitializerError e) {
-                Logging.log(Logging.LEVEL_ERROR, null, e);
-            }
-        } else if (PlatformManager.isPlatformOsx() && javaVersion < 17) {
-            // Workaround for JDK-8251377: JTabPanel active tab is unreadable in Big Sur, see #20075, see #20821
-            // os.version will return 10.16, or 11.0 depending on environment variable
-            // https://twitter.com/BriceDutheil/status/1330926649269956612
-            final String macOSVersion = getSystemProperty("os.version");
-            if ((laf.contains("Mac") || laf.contains("Aqua"))
-                    && (macOSVersion.startsWith("10.16") || macOSVersion.startsWith("11"))) {
-                UIManager.put("TabbedPane.foreground", Color.BLACK);
-            }
-        }
-        // Workaround for JDK-8262085
-        if ("Metal".equals(laf) && javaVersion >= 11 && javaVersion < 17) {
-            UIManager.put("ToolTipUI", JosmMetalToolTipUI.class.getCanonicalName());
-        }
-
         // See #20850. The upstream bug (JDK-6396936) is unlikely to ever be fixed due to potential compatibility
         // issues. This affects Windows LaF only (includes Windows Classic, a sub-LaF of Windows LaF).
@@ -1271,5 +1215,4 @@
         // if not yet enabled and if neither running on Gnome or KDE desktop
         if (PlatformManager.isPlatformUnixoid()
-                && Utils.getJavaVersion() >= 9
                 && UIManager.getLookAndFeelDefaults().get(RenderingHints.KEY_TEXT_ANTIALIASING) == null
                 && System.getProperty("awt.useSystemAAFontSettings") == null
Index: /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 19108)
+++ /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 19109)
@@ -1718,18 +1718,6 @@
         ImageReadParam param = readParamFunction.apply(reader);
         BufferedImage bi = null;
-        try { // NOPMD
+        try (stream) {
             bi = reader.read(0, param);
-            if (bi.getTransparency() != Transparency.TRANSLUCENT && (readMetadata || enforceTransparency) && Utils.getJavaVersion() < 11) {
-                Color color = getTransparentColor(bi.getColorModel(), reader);
-                if (color != null) {
-                    Hashtable<String, Object> properties = new Hashtable<>(1);
-                    properties.put(PROP_TRANSPARENCY_COLOR, color);
-                    bi = new BufferedImage(bi.getColorModel(), bi.getRaster(), bi.isAlphaPremultiplied(), properties);
-                    if (enforceTransparency) {
-                        Logging.trace("Enforcing image transparency of {0} for {1}", stream, color);
-                        bi = makeImageTransparent(bi, color);
-                    }
-                }
-            }
         } catch (LinkageError e) {
             // On Windows, ComponentColorModel.getRGBComponent can fail with "UnsatisfiedLinkError: no awt in java.library.path", see #13973
@@ -1738,5 +1726,4 @@
         } finally {
             reader.dispose();
-            stream.close();
         }
         return bi;
Index: /trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 19108)
+++ /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 19109)
@@ -1003,8 +1003,7 @@
      *  a subclass of <code>klass</code>. The casted value otherwise.
      */
-    @SuppressWarnings("unchecked")
     public static <T> T cast(Object o, Class<T> klass) {
         if (klass.isInstance(o)) {
-            return (T) o;
+            return klass.cast(o);
         }
         return null;
@@ -1784,13 +1783,8 @@
                             Config.getUrls().getJOSMWebsite() + "/remote/oracle-java-update-baseline.version")))
                     .connect().fetchContent().split("\n", -1);
-            if (getJavaVersion() <= 11 && isRunningWebStart()) { // OpenWebStart currently only has Java 11
+            // OpenWebStart currently only has Java 21
+            if (getJavaVersion() <= 21) {
                 for (String version : versions) {
-                    if (version.startsWith("11")) {
-                        return version;
-                    }
-                }
-            } else if (getJavaVersion() <= 17) {
-                for (String version : versions) {
-                    if (version.startsWith("17")) { // Use current Java LTS
+                    if (version.startsWith("21")) { // Use current Java LTS
                         return version;
                     }
@@ -1852,5 +1846,5 @@
      * Get a function that converts an object to a singleton stream of a certain
      * class (or null if the object cannot be cast to that class).
-     *
+     * <p>
      * Can be useful in relation with streams, but be aware of the performance
      * implications of creating a stream for each element.
@@ -1877,8 +1871,7 @@
      * @since 12604
      */
-    @SuppressWarnings("unchecked")
     public static <T> void instanceOfThen(Object o, Class<T> klass, Consumer<? super T> consumer) {
         if (klass.isInstance(o)) {
-            consumer.accept((T) o);
+            consumer.accept(klass.cast(o));
         }
     }
@@ -1893,8 +1886,7 @@
      * Optional otherwise
      */
-    @SuppressWarnings("unchecked")
     public static <T> Optional<T> instanceOfAndCast(Object o, Class<T> klass) {
         if (klass.isInstance(o))
-            return Optional.of((T) o);
+            return Optional.of(klass.cast(o));
         return Optional.empty();
     }
Index: /trunk/test/unit/org/openstreetmap/josm/TestUtils.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 19108)
+++ /trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 19109)
@@ -496,5 +496,5 @@
         // See https://github.com/raphw/byte-buddy/blob/master/byte-buddy-dep/src/main/java/net/bytebuddy/ClassFileVersion.java
         // for currently supported Java versions.
-        if (Utils.getJavaVersion() >= 19) {
+        if (Utils.getJavaVersion() >= 22) {
             // Byte Buddy often supports new class file versions for current EA releases if its experimental flag is set to true
             System.setProperty("net.bytebuddy.experimental", "true");
Index: /trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java	(revision 19108)
+++ /trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java	(revision 19109)
@@ -247,16 +247,4 @@
         }
 
-        // On Java < 11 and headless mode, filter plugins requiring JavaFX as Monocle is not available
-        int javaVersion = Utils.getJavaVersion();
-        if (GraphicsEnvironment.isHeadless() && javaVersion < 11) {
-            for (Iterator<PluginInformation> it = plugins.iterator(); it.hasNext();) {
-                PluginInformation pi = it.next();
-                if (pi.getRequiredPlugins().contains("javafx")) {
-                    System.out.println("Ignoring " + pi.name + " (requiring JavaFX and we're using Java < 11 in headless mode)");
-                    it.remove();
-                }
-            }
-        }
-
         // Skip unofficial plugins in headless mode, too much work for us for little added-value
         if (GraphicsEnvironment.isHeadless()) {
Index: /trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java	(revision 19108)
+++ /trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java	(revision 19109)
@@ -3,6 +3,4 @@
 
 import java.awt.Color;
-import java.awt.GraphicsEnvironment;
-import java.awt.Toolkit;
 import java.awt.Window;
 import java.awt.event.WindowEvent;
@@ -17,5 +15,4 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
-import java.lang.reflect.Method;
 import java.nio.charset.StandardCharsets;
 import java.security.GeneralSecurityException;
@@ -26,5 +23,4 @@
 import java.util.concurrent.TimeUnit;
 import java.util.logging.Handler;
-import java.util.logging.Level;
 
 import org.awaitility.Awaitility;
@@ -78,6 +74,4 @@
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.MemoryManagerTest;
-import org.openstreetmap.josm.tools.PlatformManager;
-import org.openstreetmap.josm.tools.Utils;
 import org.openstreetmap.josm.tools.bugreport.ReportedException;
 import org.openstreetmap.josm.tools.date.DateUtils;
@@ -646,5 +640,4 @@
                 }
 
-                workaroundJdkBug8159956();
                 new MainApplication();
                 JOSMFixture.initContentPane();
@@ -653,18 +646,4 @@
                 JOSMFixture.initMainMenu();
             }
-        }
-    }
-
-    private void workaroundJdkBug8159956() {
-        // Note: This has been backported to Java 8u381 (2023-07-18)
-        try {
-            if (PlatformManager.isPlatformWindows() && Utils.getJavaVersion() == 8 && GraphicsEnvironment.isHeadless()) {
-                // https://bugs.openjdk.java.net/browse/JDK-8159956
-                Method initIDs = Toolkit.class.getDeclaredMethod("initIDs");
-                initIDs.setAccessible(true);
-                initIDs.invoke(Toolkit.getDefaultToolkit());
-            }
-        } catch (Exception e) {
-            Logging.log(Level.WARNING, "Failed to Toolkit.initIDs", e);
         }
     }
