Top Description Fields Constructors Methods
org.graalvm.nativeimage

public final Class ImageInfo

extends Object
Class Inheritance

Utility class to retrieve information about the context in which code gets executed. The provided string constants are part of the API and guaranteed to remain unchanged in future versions. This allows to use System#getProperty(String) directly with the string literals defined here thus eliminating the need to depend on this class.
Since
19.0

Field Summary

Modifier and TypeField and Description
public static final String
PROPERTY_IMAGE_CODE_KEY

Holds the string that is the name of the system property providing information about the context in which code is currently executing.

public static final String
PROPERTY_IMAGE_CODE_VALUE_BUILDTIME

Holds the string that will be returned by the system property for ImageInfo#PROPERTY_IMAGE_CODE_KEY if code is executing in the context of image building (e.g. in a static initializer of class that will be contained in the image).

public static final String
PROPERTY_IMAGE_CODE_VALUE_RUNTIME

Holds the string that will be returned by the system property for ImageInfo#PROPERTY_IMAGE_CODE_KEY if code is executing at image runtime.

public static final String
PROPERTY_IMAGE_KIND_KEY

Name of the system property that holds if this image is built as a shared library or an executable.

public static final String
PROPERTY_IMAGE_KIND_VALUE_EXECUTABLE

Holds the string that will be returned by the system property for ImageInfo#PROPERTY_IMAGE_KIND_KEY if image is an executable.

public static final String
PROPERTY_IMAGE_KIND_VALUE_SHARED_LIBRARY

Holds the string that will be returned by the system property for ImageInfo#PROPERTY_IMAGE_KIND_KEY if image is a shared library.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
public static boolean
inImageBuildtimeCode()

Returns true if (at the time of the call) code is executing in the context of image building (e.g. in a static initializer of class that will be contained in the image).

public static boolean
inImageCode()

Returns true if (at the time of the call) code is executing in the context of image building or during image runtime, else false.

public static boolean
inImageRuntimeCode()

Returns true if (at the time of the call) code is executing at image runtime.

public static boolean
isExecutable()

Returns true if the image is built as an executable.

public static boolean
isSharedLibrary()

Returns true if the image is build as a shared library.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

PROPERTY_IMAGE_CODE_KEYback to summary
public static final String PROPERTY_IMAGE_CODE_KEY

Holds the string that is the name of the system property providing information about the context in which code is currently executing. If the property returns the string given by PROPERTY_IMAGE_CODE_VALUE_BUILDTIME the code is executing in the context of image building (e.g. in a static initializer of a class that will be contained in the image). If the property returns the string given by PROPERTY_IMAGE_CODE_VALUE_RUNTIME the code is executing at image runtime. Otherwise the property is not set.

Since
19.0
PROPERTY_IMAGE_CODE_VALUE_BUILDTIMEback to summary
public static final String PROPERTY_IMAGE_CODE_VALUE_BUILDTIME

Holds the string that will be returned by the system property for ImageInfo#PROPERTY_IMAGE_CODE_KEY if code is executing in the context of image building (e.g. in a static initializer of class that will be contained in the image).

Since
19.0
PROPERTY_IMAGE_CODE_VALUE_RUNTIMEback to summary
public static final String PROPERTY_IMAGE_CODE_VALUE_RUNTIME

Holds the string that will be returned by the system property for ImageInfo#PROPERTY_IMAGE_CODE_KEY if code is executing at image runtime.

Since
19.0
PROPERTY_IMAGE_KIND_KEYback to summary
public static final String PROPERTY_IMAGE_KIND_KEY

Name of the system property that holds if this image is built as a shared library or an executable. If the property is PROPERTY_IMAGE_KIND_VALUE_EXECUTABLE the image is built as an executable. If the property is PROPERTY_IMAGE_KIND_VALUE_SHARED_LIBRARY the image is built as a shared library.

Since
19.0
PROPERTY_IMAGE_KIND_VALUE_EXECUTABLEback to summary
public static final String PROPERTY_IMAGE_KIND_VALUE_EXECUTABLE

Holds the string that will be returned by the system property for ImageInfo#PROPERTY_IMAGE_KIND_KEY if image is an executable.

Since
19.0
PROPERTY_IMAGE_KIND_VALUE_SHARED_LIBRARYback to summary
public static final String PROPERTY_IMAGE_KIND_VALUE_SHARED_LIBRARY

Holds the string that will be returned by the system property for ImageInfo#PROPERTY_IMAGE_KIND_KEY if image is a shared library.

Since
19.0

Constructor Detail

ImageInfoback to summary
private ImageInfo()

Method Detail

ensureKindAvailableback to summary
private static void ensureKindAvailable()
inImageBuildtimeCodeback to summary
public static boolean inImageBuildtimeCode()

Returns true if (at the time of the call) code is executing in the context of image building (e.g. in a static initializer of class that will be contained in the image).

Since
19.0
inImageCodeback to summary
public static boolean inImageCode()

Returns true if (at the time of the call) code is executing in the context of image building or during image runtime, else false. This method will be const-folded so that it can be used to hide parts of an application that only work when running on the JVM. For example: if (!ImageInfo.inImageCode()) { ... JVM specific code here ... }

Since
19.0
inImageRuntimeCodeback to summary
public static boolean inImageRuntimeCode()

Returns true if (at the time of the call) code is executing at image runtime. This method will be const-folded. It can be used to hide parts of an application that only work when running as native image.

Since
19.0
isExecutableback to summary
public static boolean isExecutable()

Returns true if the image is built as an executable.

Since
19.0
isSharedLibraryback to summary
public static boolean isSharedLibrary()

Returns true if the image is build as a shared library.

Since
19.0