Enum Class ApplicationRuntime

java.lang.Object
java.lang.Enum<ApplicationRuntime>
io.inverno.mod.base.ApplicationRuntime
All Implemented Interfaces:
Serializable, Comparable<ApplicationRuntime>, Constable

public enum ApplicationRuntime extends Enum<ApplicationRuntime>

The runtime where the application is running.

An application can be run in the JVM with or without the module system, depending on whether it was started with a class path or a module path. It can also be a native image generated with GraalVM. This can be important at runtime to be able to handle different runtime behaviours, for instance resources are resolved differently whether the application is running with a class path, a module path or a native image: we can't resolve a module resource with Module.getResourceAsStream(java.lang.String) if the application was started with a class path and we can't list resources with ClassLoader.resources(java.lang.String) when running a native image.

Since:
1.7
Author:
Jeremy Kuhn
  • Enum Constant Details

    • JVM_CLASSPATH

      public static final ApplicationRuntime JVM_CLASSPATH
      The JVM has been started with a class path.
    • JVM_MODULE

      public static final ApplicationRuntime JVM_MODULE
      The JVM has been started with a module path.
    • IMAGE_NATIVE

      public static final ApplicationRuntime IMAGE_NATIVE
      A native image has been started.
  • Method Details

    • values

      public static ApplicationRuntime[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ApplicationRuntime valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getApplicationRuntime

      public static ApplicationRuntime getApplicationRuntime()

      Returns the current runtime.

      Returns:
      the application runtime