Changeset 13520 in josm


Ignore:
Timestamp:
2018-03-12T22:32:42+01:00 (21 months ago)
Author:
Don-vip
Message:

see #15560 - fix detection of Java version >= 10

Location:
trunk
Files:
2 edited

Legend:

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

    r13473 r13520  
    15751575    /**
    15761576     * Returns the Java version as an int value.
    1577      * @return the Java version as an int value (8, 9, etc.)
     1577     * @return the Java version as an int value (8, 9, 10, etc.)
    15781578     * @since 12130
    15791579     */
     
    15911591        int dashPos = version.indexOf('-');
    15921592        return Integer.parseInt(version.substring(0,
    1593                 dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : 1));
     1593                dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : version.length()));
    15941594    }
    15951595
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r12703 r13520  
    213213            System.setProperty("java.version", "9.0.1");
    214214            assertEquals(9, Utils.getJavaVersion());
     215
     216            System.setProperty("java.version", "10");
     217            assertEquals(10, Utils.getJavaVersion());
     218
     219            System.setProperty("java.version", "10-ea");
     220            assertEquals(10, Utils.getJavaVersion());
     221
     222            System.setProperty("java.version", "10.0.1");
     223            assertEquals(10, Utils.getJavaVersion());
    215224        } finally {
    216225            System.setProperty("java.version", javaVersion);
Note: See TracChangeset for help on using the changeset viewer.