Changeset 17692 in josm for trunk/src/org


Ignore:
Timestamp:
2021-03-30T10:29:14+02:00 (3 years ago)
Author:
Don-vip
Message:

see #17858 - fix deprecation warnings

File:
1 edited

Legend:

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

    r17679 r17692  
    17211721
    17221722    /**
     1723     * Determines if a class can be found for the given name.
     1724     * @param className class nmae to find
     1725     * @return {@code true} if the class can be found, {@code false} otherwise
     1726     * @since 17692
     1727     */
     1728    public static boolean isClassFound(String className) {
     1729        try {
     1730            return Class.forName(className) != null;
     1731        } catch (ClassNotFoundException e) {
     1732            return false;
     1733        }
     1734    }
     1735
     1736    /**
    17231737     * Determines whether JOSM has been started via Web Start (JNLP).
    17241738     * @return true if JOSM has been started via Web Start (JNLP)
     
    17261740     */
    17271741    public static boolean isRunningWebStart() {
    1728         try {
    1729             // See http://stackoverflow.com/a/16200769/2257172
    1730             return Class.forName("javax.jnlp.ServiceManager") != null;
    1731         } catch (ClassNotFoundException e) {
    1732             return false;
    1733         }
     1742        // See http://stackoverflow.com/a/16200769/2257172
     1743        return isClassFound("javax.jnlp.ServiceManager");
    17341744    }
    17351745
     
    17401750     */
    17411751    public static boolean isRunningJavaWebStart() {
    1742         return isRunningWebStart() && Package.getPackage("com.sun.javaws") != null;
     1752        return isRunningWebStart() && isClassFound("com.sun.javaws.Main");
    17431753    }
    17441754
     
    17491759     */
    17501760    public static boolean isRunningOpenWebStart() {
    1751         return isRunningWebStart() && Package.getPackage("net.adoptopenjdk.icedteaweb") != null;
     1761        // To be kept in sync if package name changes to org.eclipse.adoptium or something
     1762        return isRunningWebStart() && isClassFound("net.adoptopenjdk.icedteaweb.client.commandline.CommandLine");
    17521763    }
    17531764
Note: See TracChangeset for help on using the changeset viewer.