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

Create version constants to model preview language and vm features

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P3 P3
    • 26
    • core-libs
    • None
    • behavioral
    • minimal
    • Users are already warned of new constant addition in these classes.
    • Java API
    • SE

      Summary

      Create new constants, CURRENT_PREVIEW, in javax.lang.model.SourceVersion and java.lang.reflect.ClassFileFormatVersion to represent preview features for version-specific queries.

      Problem

      Many version-specific queries wish to reveal the different behaviors when preview features are enabled. However, these queries should not differ by whether preview features are enabled on the current runtime environment (both preview querying non-preview and non-preview querying preview), and should by default report information that has backward compatibility, which is not fulfilled by preview features.

      Solution

      Add a CURRENT_PREVIEW constant to both classes, with the following properties:

      1. It behaves as if it is an arbitrary future version to the release the program is compiled against, like any other additional constant a program will encounter when running on a JRE of later Java SE releases.
      2. It is not subject to backward compatibility in future versions. This is revealed by a new API, boolean isSupported().
      3. It is a reflective preview API, so that programs (such as tools) running not in preview can use it; but programs must ensure they are running on the correct Java SE release when they use it.

      There are additional changes to support this evolution.

      1. A new API is added to determine if a version is subject to backward compatibility. Only the CURRENT_PREVIEW is not subject to backward compatibility. This API is not preview.

        boolean isSupported()
      2. ClassFileFormatVersion sees some relevant specification cleanup that better describes its situations. For example, a later release can loosen restrictions that make a seemingly compatible CFFV class no longer runnable on a previous Java SE release.

      Specification

      See attachment.

            liach Chen Liang
            liach Chen Liang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: