Package spock.util.environment
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JvmgetCurrent()Returns the current JVM.StringgetJavaSpecificationVersion()The Java specification version, as returned by thejava.specification.versionsystem property.StringgetJavaVersion()The Java version, as returned by thejava.versionsystem property.booleanisJava10()Tells whether the Java version is 10.booleanisJava10Compatible()Tells whether the Java version is compatible with Java 10.booleanisJava11()Tells whether the Java version is 11.booleanisJava11Compatible()Tells whether the Java version is compatible with Java 11.booleanisJava12()Tells whether the Java version is 12.booleanisJava12Compatible()Tells whether the Java version is compatible with Java 12.booleanisJava13()Tells whether the Java version is 13.booleanisJava13Compatible()Tells whether the Java version is compatible with Java 13.booleanisJava14()Tells whether the Java version is 14.booleanisJava14Compatible()Tells whether the Java version is compatible with Java 14.booleanisJava15()Tells whether the Java version is 15.booleanisJava15Compatible()Tells whether the Java version is compatible with Java 15.booleanisJava16()Tells whether the Java version is 16.booleanisJava16Compatible()Tells whether the Java version is compatible with Java 16.booleanisJava17()Tells whether the Java version is 17.booleanisJava17Compatible()Tells whether the Java version is compatible with Java 17.booleanisJava18()Tells whether the Java version is 18.booleanisJava18Compatible()Tells whether the Java version is compatible with Java 18.booleanisJava19()Tells whether the Java version is 19.booleanisJava19Compatible()Tells whether the Java version is compatible with Java 19.booleanisJava20()Tells whether the Java version is 20.booleanisJava20Compatible()Tells whether the Java version is compatible with Java 20.booleanisJava21()Tells whether the Java version is 21.booleanisJava21Compatible()Tells whether the Java version is compatible with Java 21.booleanisJava22()Tells whether the Java version is 22.booleanisJava22Compatible()Tells whether the Java version is compatible with Java 22.booleanisJava23()Tells whether the Java version is 23.booleanisJava23Compatible()Tells whether the Java version is compatible with Java 23.booleanisJava8()Tells whether the Java version is 8.booleanisJava8Compatible()Tells whether the Java version is compatible with Java 8.booleanisJava9()Tells whether the Java version is 9.booleanisJava9Compatible()Tells whether the Java version is compatible with Java 9.booleanisJavaVersion(int majorJavaVersion)Tells whether the Java version is equal to the given major Java version.booleanisJavaVersionCompatible(int majorJavaVersion)Tells whether the Java version is compatible with the given major Java version.
-
-
-
Method Detail
-
getJavaVersion
public String getJavaVersion()
The Java version, as returned by thejava.versionsystem 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.versionsystem property
-
getJavaSpecificationVersion
public String getJavaSpecificationVersion()
The Java specification version, as returned by thejava.specification.versionsystem property. Examples for valid values are"1.6"and"1.7".- Returns:
- the Java specification version, as returned by the
java.specification.versionsystem 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
-
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
-
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
-
-