Top Description Inners Fields Constructors Methods
org.springframework.core

public abstract Class NativeDetector

extends Object
Class Inheritance
Imports
org.springframework.lang.Nullable

A common delegate for detecting a GraalVM native image environment.
Author
Sebastien Deleuze
Since
5.3.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
NativeDetector.Context

Native image context as defined in GraalVM's ImageInfo.

Field Summary

Modifier and TypeField and Description
private static final String
private static final boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean
inNativeImage()

Returns true if running in a native image context (for example buildtime, runtime, or agent) expressed by setting the org.graalvm.nativeimage.imagecode system property to any value.

public static boolean
inNativeImage(NativeDetector.Context...
the native image context(s)
contexts
)

Returns true if running in any of the specified native image context(s).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

imageCodeback to summary
private static final String imageCode
Annotations
@Nullable
inNativeImageback to summary
private static final boolean inNativeImage

Constructor Detail

NativeDetectorback to summary
public NativeDetector()

Method Detail

inNativeImageback to summary
public static boolean inNativeImage()

Returns true if running in a native image context (for example buildtime, runtime, or agent) expressed by setting the org.graalvm.nativeimage.imagecode system property to any value.

inNativeImageback to summary
public static boolean inNativeImage(NativeDetector.Context... contexts)

Returns true if running in any of the specified native image context(s).

Parameters
contexts:NativeDetector.Context[]

the native image context(s)

Since
6.0.10
org.springframework.core back to summary

public final Enum NativeDetector.Context

extends Enum<NativeDetector.Context>
Class Inheritance

Native image context as defined in GraalVM's ImageInfo.
Since
6.0.10

Field Summary

Modifier and TypeField and Description
public static final NativeDetector.Context
BUILD

The code is executing in the context of image building.

private final String
public static final NativeDetector.Context
RUN

The code is executing at image runtime.

Constructor Summary

AccessConstructor and Description
private
Context(final String key)

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.
public static NativeDetector.Context
public static NativeDetector.Context[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

BUILDback to summary
public static final NativeDetector.Context BUILD

The code is executing in the context of image building.

keyback to summary
private final String key
RUNback to summary
public static final NativeDetector.Context RUN

The code is executing at image runtime.

Constructor Detail

Contextback to summary
private Context(final String key)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static NativeDetector.Context valueOf(String name)
valuesback to summary
public static NativeDetector.Context[] values()