Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8221264

Refactor and update SourceVersion.latestSupported

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 13
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b14

      Description

      The JDK 11 javadoc for SourceVersion#latest and SourceVersion#latestSupported currently reads as:

      > Returns the latest source version that can be modeled.

      https://docs.oracle.com/en/java/javase/11/docs/api/java.compiler/javax/lang/model/SourceVersion.html#latest()

      > Returns the latest source version fully supported by the current execution environment. RELEASE_5 or later must be returned.

      https://docs.oracle.com/en/java/javase/11/docs/api/java.compiler/javax/lang/model/SourceVersion.html#latestSupported()

      It would be helpful to provide some more information about when latestSupported should be used, and perhaps a usage example.

      In particular it's not clear to me when latestSupported is the right choice.
      * If the current runtime version is the same as the java.compiler version latestSupported and latest have the same behaviour.
      * If the runtime version is newer than the version of java.compiler, the implementation will see an unrecognized value of `java.specification.version` and fall back to returning RELEASE_5, which is misleading: http://hg.openjdk.java.net/jdk/jdk/file/0288c6919a20/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java#l235
      * The runtime version shouldn't ever be older than the version of java.compiler, except for during the JDK's own build process when version N of java.compiler is run on the version N-1 bootstrap JDK. Is that situation the intended use-case for latestSupported?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                cushon Liam Miller-Cushon
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: