--- old/src/java.base/share/classes/java/lang/Runtime.java 2018-01-16 12:04:30.000000000 -0800 +++ new/src/java.base/share/classes/java/lang/Runtime.java 2018-01-16 12:04:30.000000000 -0800 @@ -1099,16 +1099,23 @@ m.group(VersionPattern.OPT_GROUP)); // empty '+' - if ((m.group(VersionPattern.PLUS_GROUP) != null) - && !build.isPresent()) { - if (optional.isPresent()) { - if (pre.isPresent()) - throw new IllegalArgumentException("'+' found with" - + " pre-release and optional components:'" + s - + "'"); + if (!build.isPresent()) { + if (m.group(VersionPattern.PLUS_GROUP) != null) { + if (optional.isPresent()) { + if (pre.isPresent()) + throw new IllegalArgumentException("'+' found with" + + " pre-release and optional components:'" + s + + "'"); + } else { + throw new IllegalArgumentException("'+' found with neither" + + " build or optional components: '" + s + "'"); + } } else { - throw new IllegalArgumentException("'+' found with neither" - + " build or optional components: '" + s + "'"); + if (optional.isPresent() && !pre.isPresent()) { + throw new IllegalArgumentException("optional component" + + " must be preceeded by a pre-release component" + + " or '+': '" + s + "'"); + } } } return new Version(List.of(version), pre, build, optional); --- old/test/jdk/java/lang/Runtime/Version/Basic.java 2018-01-16 12:04:31.000000000 -0800 +++ new/test/jdk/java/lang/Runtime/Version/Basic.java 2018-01-16 12:04:31.000000000 -0800 @@ -115,6 +115,7 @@ tryCatch("9-pre+-opt", IAE); tryCatch("1.4142+-", IAE); tryCatch("2.9979+-%", IAE); + tryCatch("10--ea", IAE); //// Test for Runtime.version() testVersion();