Class NativeImageUtil


  • public class NativeImageUtil
    extends java.lang.Object
    Utilities for graal native image support; mostly to improve error message handling in case of missing information for native image.
    Since:
    2.14
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isInNativeImage()
      Checks whether we're running in SubstrateVM native image only by the presence of "org.graalvm.nativeimage.imagecode" system property, regardless of its value (buildtime or runtime).
      static boolean isInNativeImageAndIsAtRuntime()
      Check whether we're running in SubstrateVM native image and also in "runtime" mode.
      static boolean isUnsupportedFeatureError​(java.lang.Throwable e)
      Check whether the given error is a substratevm UnsupportedFeatureError
      static boolean needsReflectionConfiguration​(java.lang.Class<?> cl)
      Check whether the given class is likely missing reflection configuration (running in native image, and no members visible in reflection).
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isInNativeImageAndIsAtRuntime

        public static boolean isInNativeImageAndIsAtRuntime()
        Check whether we're running in SubstrateVM native image and also in "runtime" mode. The "runtime" check cannot be a constant, because the static initializer may run early during build time

        As optimization, RUNNING_IN_SVM is used to short-circuit on normal JVMs.

        Since:
        2.16
      • isInNativeImage

        public static boolean isInNativeImage()
        Checks whether we're running in SubstrateVM native image only by the presence of "org.graalvm.nativeimage.imagecode" system property, regardless of its value (buildtime or runtime). We are irrespective of the build or runtime phase, because native-image can initialize static initializers at build time.

        Since:
        2.16
      • isUnsupportedFeatureError

        public static boolean isUnsupportedFeatureError​(java.lang.Throwable e)
        Check whether the given error is a substratevm UnsupportedFeatureError
      • needsReflectionConfiguration

        public static boolean needsReflectionConfiguration​(java.lang.Class<?> cl)
        Check whether the given class is likely missing reflection configuration (running in native image, and no members visible in reflection).