### Question:
VersionUtil { public static long parseJavaVersion (String versRegex, String versStr) { Matcher m = Pattern.compile(versRegex).matcher(versStr); if (!m.matches()) return 0L; long vers = 0L; for (int ii = 1; ii <= m.groupCount(); ii++) { String valstr = m.group(ii); int value = (valstr == null) ? 0 : parseInt(valstr); vers *= 100; vers += value; } return vers; }  static long readVersion(File vfile); static void writeVersion(File vfile, long version); static long parseJavaVersion(String versRegex, String versStr); static long readReleaseVersion(File relfile, String versRegex);  }### Answer:
@Test public void shouldParseJavaVersion () { long version = VersionUtil.parseJavaVersion( "(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(_\\d+)?)?)?", "1.8.0_152"); assertEquals(1_080_152, version); }
@Test public void shouldParseJavaVersion8 () { long version = VersionUtil.parseJavaVersion( "(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(_\\d+)?)?)?", "1.8"); assertEquals(1_080_000, version); }
@Test public void shouldParseJavaVersion9 () { long version = VersionUtil.parseJavaVersion( "(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(_\\d+)?)?)?", "9"); assertEquals(9_000_000, version); }
@Test public void shouldParseJavaVersion10 () { long version = VersionUtil.parseJavaVersion( "(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(_\\d+)?)?)?", "10"); assertEquals(10_000_000, version); }
@Test public void shouldParseJavaRuntimeVersion () { long version = VersionUtil.parseJavaVersion( "(\\d+)\\.(\\d+)\\.(\\d+)(_\\d+)?(-b\\d+)?", "1.8.0_131-b11"); assertEquals(108_013_111, version); }