Changeset 12130 in josm
- Timestamp:
- 2017-05-13T00:56:58+02:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r12095 r12130 1405 1405 /** 1406 1406 * Updates system properties with the current values in the preferences. 1407 *1408 1407 */ 1409 1408 public void updateSystemProperties() { … … 1417 1416 // Force AWT toolkit to update its internal preferences (fix #6345). 1418 1417 // Does not work anymore with Java 9, to remove with Java 9 migration 1419 if ( !GraphicsEnvironment.isHeadless()) {1418 if (Utils.getJavaVersion() < 9 && !GraphicsEnvironment.isHeadless()) { 1420 1419 try { 1421 1420 Field field = Toolkit.class.getDeclaredField("resources"); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r12015 r12130 1586 1586 return angleDeg * TO_RADIANS; 1587 1587 } 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 } 1588 1609 } -
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r12045 r12130 154 154 155 155 /** 156 * Returns the Java version as an int value.157 * @return the Java version as an int value (8, 9, etc.)158 */159 public static int getJavaVersion() {160 String version = System.getProperty("java.version");161 if (version.startsWith("1.")) {162 version = version.substring(2);163 }164 // Allow these formats:165 // 1.8.0_72-ea166 // 9-ea167 // 9168 // 9.0.1169 int dotPos = version.indexOf('.');170 int dashPos = version.indexOf('-');171 return Integer.parseInt(version.substring(0,172 dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : 1));173 }174 175 /**176 156 * Returns a private field value. 177 157 * @param obj object -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r12022 r12130 25 25 import org.junit.Test; 26 26 import org.openstreetmap.josm.JOSMFixture; 27 import org.openstreetmap.josm.TestUtils;28 27 import org.openstreetmap.josm.data.Bounds; 29 28 import org.openstreetmap.josm.data.coor.EastNorth; 30 29 import org.openstreetmap.josm.data.coor.LatLon; 31 30 import org.openstreetmap.josm.tools.Pair; 31 import org.openstreetmap.josm.tools.Utils; 32 32 33 33 /** … … 180 180 } 181 181 182 final boolean java9 = TestUtils.getJavaVersion() >= 9;182 final boolean java9 = Utils.getJavaVersion() >= 9; 183 183 for (TestData data : allData) { 184 184 Projection proj = Projections.getProjectionByCode(data.code); -
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r11921 r12130 196 196 197 197 /** 198 * Test {@link Utils#getJavaVersion} 199 */ 200 @Test 201 public void testGetJavaVersion() { 202 String javaVersion = System.getProperty("java.version"); 203 try { 204 System.setProperty("java.version", "1.8.0_72-ea"); 205 assertEquals(8, Utils.getJavaVersion()); 206 207 System.setProperty("java.version", "9-ea"); 208 assertEquals(9, Utils.getJavaVersion()); 209 210 System.setProperty("java.version", "9"); 211 assertEquals(9, Utils.getJavaVersion()); 212 213 System.setProperty("java.version", "9.0.1"); 214 assertEquals(9, Utils.getJavaVersion()); 215 } finally { 216 System.setProperty("java.version", javaVersion); 217 } 218 } 219 220 /** 198 221 * Tests if readBytesFromStream handles null streams (might happen when there is no data on error stream) 199 222 * @throws IOException in case of I/O error
Note:
See TracChangeset
for help on using the changeset viewer.