RFR: JDK-8275308: Add valueOf(Runtime.Version) factory to SourceVersion [v3]

Joe Darcy darcy at openjdk.java.net
Mon Oct 25 22:01:50 UTC 2021


On Sat, 23 Oct 2021 04:06:08 GMT, Michael Bien <duke at openjdk.java.net> wrote:

>> src/java.compiler/share/classes/javax/lang/model/SourceVersion.java line 525:
>> 
>>> 523:         if (feature > Runtime.version().feature()) {
>>> 524:             throw new IllegalArgumentException("No matching SourceVersion for " + rv);
>>> 525:         } else {
>> 
>> Using `Runtime.version()` as a stand-in for the max `SourceVersion` seems non-obvious. Would it be better to use `SourceVersion.latest().runtimeVersion()` instead?
>> 
>> What about when running this API on JDK N-1?
>
> if could be potentially dropped since valueOf("RELEASE_" + feature) is throwing IAE already.

Updated as suggested.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5973


More information about the compiler-dev mailing list