Class Jvm

java.lang.Object
spock.util.environment.Jvm

public class Jvm extends Object
Provides information on the current JVM, such as its Java version.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Jvm
    Returns the current JVM.
    The Java specification version, as returned by the java.specification.version system property.
    The Java version, as returned by the java.version system property.
    boolean
    Tells whether the Java version is 10.
    boolean
    Tells whether the Java version is compatible with Java 10.
    boolean
    Tells whether the Java version is 11.
    boolean
    Tells whether the Java version is compatible with Java 11.
    boolean
    Tells whether the Java version is 12.
    boolean
    Tells whether the Java version is compatible with Java 12.
    boolean
    Tells whether the Java version is 13.
    boolean
    Tells whether the Java version is compatible with Java 13.
    boolean
    Tells whether the Java version is 14.
    boolean
    Tells whether the Java version is compatible with Java 14.
    boolean
    Tells whether the Java version is 15.
    boolean
    Tells whether the Java version is compatible with Java 15.
    boolean
    Tells whether the Java version is 16.
    boolean
    Tells whether the Java version is compatible with Java 16.
    boolean
    Tells whether the Java version is 17.
    boolean
    Tells whether the Java version is compatible with Java 17.
    boolean
    Tells whether the Java version is 18.
    boolean
    Tells whether the Java version is compatible with Java 18.
    boolean
    Tells whether the Java version is 19.
    boolean
    Tells whether the Java version is compatible with Java 19.
    boolean
    Tells whether the Java version is 20.
    boolean
    Tells whether the Java version is compatible with Java 20.
    boolean
    Tells whether the Java version is 21.
    boolean
    Tells whether the Java version is compatible with Java 21.
    boolean
    Tells whether the Java version is 22.
    boolean
    Tells whether the Java version is compatible with Java 22.
    boolean
    Tells whether the Java version is 23.
    boolean
    Tells whether the Java version is compatible with Java 23.
    boolean
    Tells whether the Java version is 24.
    boolean
    Tells whether the Java version is compatible with Java 24.
    boolean
    Tells whether the Java version is 25.
    boolean
    Tells whether the Java version is compatible with Java 25.
    boolean
    Tells whether the Java version is 26.
    boolean
    Tells whether the Java version is compatible with Java 26.
    boolean
    Tells whether the Java version is 27.
    boolean
    Tells whether the Java version is compatible with Java 27.
    boolean
    Tells whether the Java version is 28.
    boolean
    Tells whether the Java version is compatible with Java 28.
    boolean
    Tells whether the Java version is 29.
    boolean
    Tells whether the Java version is compatible with Java 29.
    boolean
    Tells whether the Java version is 8.
    boolean
    Tells whether the Java version is compatible with Java 8.
    boolean
    Tells whether the Java version is 9.
    boolean
    Tells whether the Java version is compatible with Java 9.
    boolean
    isJavaVersion(int majorJavaVersion)
    Tells whether the Java version is equal to the given major Java version.
    boolean
    isJavaVersionCompatible(int majorJavaVersion)
    Tells whether the Java version is compatible with the given major Java version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getJavaVersion

      public String getJavaVersion()
      The Java version, as returned by the java.version system property. Examples for valid values (for Oracle/OpenJDK) are "1.6.0_22" and "1.7.0_07".
      Returns:
      the Java version, as returned by the java.version system property
    • getJavaSpecificationVersion

      public String getJavaSpecificationVersion()
      The Java specification version, as returned by the java.specification.version system property. Examples for valid values are "1.6" and "1.7".
      Returns:
      the Java specification version, as returned by the java.specification.version system property
    • isJava8

      public boolean isJava8()
      Tells whether the Java version is 8.
      Returns:
      whether the Java version is 8
    • isJava9

      public boolean isJava9()
      Tells whether the Java version is 9.
      Returns:
      whether the Java version is 9
    • isJava10

      public boolean isJava10()
      Tells whether the Java version is 10.
      Returns:
      whether the Java version is 10
      Since:
      1.2
    • isJava11

      public boolean isJava11()
      Tells whether the Java version is 11.
      Returns:
      whether the Java version is 11
      Since:
      1.2
    • isJava12

      public boolean isJava12()
      Tells whether the Java version is 12.
      Returns:
      whether the Java version is 12
      Since:
      2.0
    • isJava13

      public boolean isJava13()
      Tells whether the Java version is 13.
      Returns:
      whether the Java version is 13
      Since:
      2.0
    • isJava14

      public boolean isJava14()
      Tells whether the Java version is 14.
      Returns:
      whether the Java version is 14
      Since:
      2.0
    • isJava15

      public boolean isJava15()
      Tells whether the Java version is 15.
      Returns:
      whether the Java version is 15
      Since:
      2.0
    • isJava16

      public boolean isJava16()
      Tells whether the Java version is 16.
      Returns:
      whether the Java version is 16
      Since:
      2.0
    • isJava17

      public boolean isJava17()
      Tells whether the Java version is 17.
      Returns:
      whether the Java version is 17
      Since:
      2.0
    • isJava18

      public boolean isJava18()
      Tells whether the Java version is 18.
      Returns:
      whether the Java version is 18
      Since:
      2.0
    • isJava19

      public boolean isJava19()
      Tells whether the Java version is 19.
      Returns:
      whether the Java version is 19
      Since:
      2.0
    • isJava20

      public boolean isJava20()
      Tells whether the Java version is 20.
      Returns:
      whether the Java version is 20
      Since:
      2.0
    • isJava21

      public boolean isJava21()
      Tells whether the Java version is 21.
      Returns:
      whether the Java version is 21
      Since:
      2.0
    • isJava22

      public boolean isJava22()
      Tells whether the Java version is 22.
      Returns:
      whether the Java version is 22
      Since:
      2.0
    • isJava23

      public boolean isJava23()
      Tells whether the Java version is 23.
      Returns:
      whether the Java version is 23
      Since:
      2.0
    • isJava24

      public boolean isJava24()
      Tells whether the Java version is 24.
      Returns:
      whether the Java version is 24
      Since:
      2.4
    • isJava25

      public boolean isJava25()
      Tells whether the Java version is 25.
      Returns:
      whether the Java version is 25
      Since:
      2.4
    • isJava26

      public boolean isJava26()
      Tells whether the Java version is 26.
      Returns:
      whether the Java version is 26
      Since:
      2.4
    • isJava27

      public boolean isJava27()
      Tells whether the Java version is 27.
      Returns:
      whether the Java version is 27
      Since:
      2.4
    • isJava28

      public boolean isJava28()
      Tells whether the Java version is 28.
      Returns:
      whether the Java version is 28
      Since:
      2.4
    • isJava29

      public boolean isJava29()
      Tells whether the Java version is 29.
      Returns:
      whether the Java version is 29
      Since:
      2.4
    • isJavaVersion

      public boolean isJavaVersion(int majorJavaVersion)
      Tells whether the Java version is equal to the given major Java version.
      Parameters:
      majorJavaVersion - major java version (e.g. 8, 12, 17) to check the Java version is equal to
      Returns:
      whether the Java version is equal to the given major Java version
      Since:
      2.0
    • isJava8Compatible

      public boolean isJava8Compatible()
      Tells whether the Java version is compatible with Java 8.
      Returns:
      whether the Java version is compatible with Java 8
    • isJava9Compatible

      public boolean isJava9Compatible()
      Tells whether the Java version is compatible with Java 9.
      Returns:
      whether the Java version is compatible with Java 9
    • isJava10Compatible

      public boolean isJava10Compatible()
      Tells whether the Java version is compatible with Java 10.
      Returns:
      whether the Java version is compatible with Java 10
      Since:
      1.2
    • isJava11Compatible

      public boolean isJava11Compatible()
      Tells whether the Java version is compatible with Java 11.
      Returns:
      whether the Java version is compatible with Java 11
      Since:
      1.2
    • isJava12Compatible

      public boolean isJava12Compatible()
      Tells whether the Java version is compatible with Java 12.
      Returns:
      whether the Java version is compatible with Java 12
      Since:
      2.0
    • isJava13Compatible

      public boolean isJava13Compatible()
      Tells whether the Java version is compatible with Java 13.
      Returns:
      whether the Java version is compatible with Java 13
      Since:
      2.0
    • isJava14Compatible

      public boolean isJava14Compatible()
      Tells whether the Java version is compatible with Java 14.
      Returns:
      whether the Java version is compatible with Java 14
      Since:
      2.0
    • isJava15Compatible

      public boolean isJava15Compatible()
      Tells whether the Java version is compatible with Java 15.
      Returns:
      whether the Java version is compatible with Java 15
      Since:
      2.0
    • isJava16Compatible

      public boolean isJava16Compatible()
      Tells whether the Java version is compatible with Java 16.
      Returns:
      whether the Java version is compatible with Java 16
      Since:
      2.0
    • isJava17Compatible

      public boolean isJava17Compatible()
      Tells whether the Java version is compatible with Java 17.
      Returns:
      whether the Java version is compatible with Java 17
      Since:
      2.0
    • isJava18Compatible

      public boolean isJava18Compatible()
      Tells whether the Java version is compatible with Java 18.
      Returns:
      whether the Java version is compatible with Java 18
      Since:
      2.0
    • isJava19Compatible

      public boolean isJava19Compatible()
      Tells whether the Java version is compatible with Java 19.
      Returns:
      whether the Java version is compatible with Java 19
      Since:
      2.0
    • isJava20Compatible

      public boolean isJava20Compatible()
      Tells whether the Java version is compatible with Java 20.
      Returns:
      whether the Java version is compatible with Java 20
      Since:
      2.0
    • isJava21Compatible

      public boolean isJava21Compatible()
      Tells whether the Java version is compatible with Java 21.
      Returns:
      whether the Java version is compatible with Java 21
      Since:
      2.0
    • isJava22Compatible

      public boolean isJava22Compatible()
      Tells whether the Java version is compatible with Java 22.
      Returns:
      whether the Java version is compatible with Java 22
      Since:
      2.0
    • isJava23Compatible

      public boolean isJava23Compatible()
      Tells whether the Java version is compatible with Java 23.
      Returns:
      whether the Java version is compatible with Java 23
      Since:
      2.0
    • isJava24Compatible

      public boolean isJava24Compatible()
      Tells whether the Java version is compatible with Java 24.
      Returns:
      whether the Java version is compatible with Java 24
      Since:
      2.4
    • isJava25Compatible

      public boolean isJava25Compatible()
      Tells whether the Java version is compatible with Java 25.
      Returns:
      whether the Java version is compatible with Java 25
      Since:
      2.4
    • isJava26Compatible

      public boolean isJava26Compatible()
      Tells whether the Java version is compatible with Java 26.
      Returns:
      whether the Java version is compatible with Java 26
      Since:
      2.4
    • isJava27Compatible

      public boolean isJava27Compatible()
      Tells whether the Java version is compatible with Java 27.
      Returns:
      whether the Java version is compatible with Java 27
      Since:
      2.4
    • isJava28Compatible

      public boolean isJava28Compatible()
      Tells whether the Java version is compatible with Java 28.
      Returns:
      whether the Java version is compatible with Java 28
      Since:
      2.4
    • isJava29Compatible

      public boolean isJava29Compatible()
      Tells whether the Java version is compatible with Java 29.
      Returns:
      whether the Java version is compatible with Java 29
      Since:
      2.4
    • isJavaVersionCompatible

      public boolean isJavaVersionCompatible(int majorJavaVersion)
      Tells whether the Java version is compatible with the given major Java version.
      Parameters:
      majorJavaVersion - major java version (e.g. 8, 12, 17) to check the Java version compatibility with
      Returns:
      whether the Java version is compatible with the given major Java version
      Since:
      2.0
    • getCurrent

      public static Jvm getCurrent()
      Returns the current JVM.
      Returns:
      the current JVM