Class JavaFeatureVersion

java.lang.Object
org.codehaus.groovy.vmplugin.JavaFeatureVersion

public final class JavaFeatureVersion extends Object
The Java feature version of the running VM, e.g. 17 (GROOVY-12382).

Runtime.version() is a Java 9 API that some runtimes built on the JDK class library do not provide (Android's ART, for one). Where it is missing, the java.specification.version property is parsed instead, and when that is unusable the lowest release Groovy supports is assumed.

Deliberately tiny and free of lambdas: it is consulted from static initialisers that can run while the system class loader is being instantiated (-Djava.system.class.loader=groovy.lang.GroovyClassLoader), where an invokedynamic bootstrap is not yet permitted, and it must not trigger the creation of the VM plugin.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The lowest Java release Groovy runs on.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Returns the feature version of the running VM.
    static int
    parse(String specificationVersion, int minimum)
    Parses a java.specification.version value ("1.8", "17", "0.9" on Android) into a feature version.

    Methods inherited from class java.lang.Object

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

    • MINIMUM

      public static final int MINIMUM
      The lowest Java release Groovy runs on.
      See Also:
  • Method Details

    • current

      public static int current()
      Returns the feature version of the running VM.
      Returns:
      the feature version, never below MINIMUM
    • parse

      public static int parse(String specificationVersion, int minimum)
      Parses a java.specification.version value ("1.8", "17", "0.9" on Android) into a feature version.
      Parameters:
      specificationVersion - the property value, possibly null
      minimum - the value returned when the property is missing, unparseable or below it
      Returns:
      the feature version