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


Ignore:
Timestamp:
2017-05-13T00:56:58+02:00 (7 years ago)
Author:
Don-vip
Message:

see #11924 - do not try old workaround with java 9 (pollutes console with stacktrace)

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r12095 r12130  
    14051405    /**
    14061406     * Updates system properties with the current values in the preferences.
    1407      *
    14081407     */
    14091408    public void updateSystemProperties() {
     
    14171416        // Force AWT toolkit to update its internal preferences (fix #6345).
    14181417        // Does not work anymore with Java 9, to remove with Java 9 migration
    1419         if (!GraphicsEnvironment.isHeadless()) {
     1418        if (Utils.getJavaVersion() < 9 && !GraphicsEnvironment.isHeadless()) {
    14201419            try {
    14211420                Field field = Toolkit.class.getDeclaredField("resources");
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r12015 r12130  
    15861586        return angleDeg * TO_RADIANS;
    15871587    }
     1588
     1589    /**
     1590     * Returns the Java version as an int value.
     1591     * @return the Java version as an int value (8, 9, etc.)
     1592     * @since 12130
     1593     */
     1594    public static int getJavaVersion() {
     1595        String version = System.getProperty("java.version");
     1596        if (version.startsWith("1.")) {
     1597            version = version.substring(2);
     1598        }
     1599        // Allow these formats:
     1600        // 1.8.0_72-ea
     1601        // 9-ea
     1602        // 9
     1603        // 9.0.1
     1604        int dotPos = version.indexOf('.');
     1605        int dashPos = version.indexOf('-');
     1606        return Integer.parseInt(version.substring(0,
     1607                dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : 1));
     1608    }
    15881609}
Note: See TracChangeset for help on using the changeset viewer.