jvmunsupported-class-version

Is there a way to show the range of major.minor class versions supported by a jvm?


Can the java command print the range of class versions supported by it? Or is there a list of this information for each jvm version somewhere online?


Solution

  • The requirements on supported class file versions are described in JVM specification §4.1:

    +---------+-----------------------------+--------------------------+
    | Java SE | Corresponding major version | Supported major versions |
    +---------+-----------------------------+--------------------------+
    | 1.0.2   | 45                          | 45                       |
    | 1.1     | 45                          | 45                       |
    | 1.2     | 46                          | 45 .. 46                 |
    | 1.3     | 47                          | 45 .. 47                 |
    | 1.4     | 48                          | 45 .. 48                 |
    | 5.0     | 49                          | 45 .. 49                 |
    | 6       | 50                          | 45 .. 50                 |
    | 7       | 51                          | 45 .. 51                 |
    | 8       | 52                          | 45 .. 52                 |
    | 9       | 53                          | 45 .. 53                 |
    | 10      | 54                          | 45 .. 54                 |
    | 11      | 55                          | 45 .. 55                 |
    | 12      | 56                          | 45 .. 56                 |
    | 13      | 57                          | 45 .. 57                 |
    +---------+-----------------------------+--------------------------+
    

    For a class file whose major_version is 56 or above, the minor_version must be 0 or 65535.

    For a class file whose major_version is between 45 and 55 inclusive, the minor_version may be any value.

    A historical perspective is warranted on JDK support for class file format versions. JDK 1.0.2 supported versions 45.0 through 45.3 inclusive. JDK 1.1 supported versions 45.0 through 45.65535 inclusive. When JDK 1.2 introduced support for major version 46, the only minor version supported under that major version was 0. Later JDKs continued the practice of introducing support for a new major version (47, 48, etc) but supporting only a minor version of 0 under the new major version. Finally, the introduction of preview features in Java SE 12 (see below) motivated a standard role for the minor version of the class file format, so JDK 12 supported minor versions of 0 and 65535 under major version 56. Subsequent JDKs introduce support for N.0 and N.65535 where N is the corresponding major version of the implemented Java SE Platform. For example, JDK 13 supports 57.0 and 57.65535.