Annotation Type NativeHint


  • @Repeatable(NativeHints.class)
    @Retention(RUNTIME)
    public @interface NativeHint
    NativeHint annotations should be placed either on Spring configuration/registrar/import-selectors or on some implementation of NativeConfiguration that the system will discover via a service factory load.

    This allows hints to be provided for pre-compiled sources that don't yet have hints provided. A NativeHint determines what needs to be accessible at runtime in a native image (via reflection or via resource access). NativeHint typically have a trigger that activates them and that would be if a particular piece of configuration/registrar or import-selector is determined to be active in a Spring application. The trigger is either inferred (if the hint is on a piece of Spring configuration/registrar/import-selector) or it can be specified by setting the `trigger` member of the annotation (for hints provided separately to the Spring configuration).

    Author:
    Andy Clement, Sebastien Deleuze
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean abortIfTypesMissing
      Determine if analysis should stop if the inferred and/or specific types for this hint cannot be found.
      AotProxyHint[] aotProxies
      A set of class proxy information which describe a class based proxy that should be created at build time if the trigger is active.
      String[] extractTypesFromAttributes
      Names of the annotation attributes on the target type which contain type names (as class references or strings) other than 'value'.
      boolean follow
      Determine if types inferred or specified directly in TypeHints should be followed to find further hints.
      Class<?>[] imports
      A set of types that have TypeHint / JdkProxyHint / etc.
      InitializationHint[] initialization
      A set of initialization information which specify which classes/packages should be initialized explicitly at runtime/build-time (runtime being GraalVM native image default).
      JdkProxyHint[] jdkProxies
      A set of proxy information which indicate which sets of types need a proxy if the trigger is active.
      String[] options
      GraalVM native options to configure automatically when the hint is active
      ResourceHint[] resources
      A set of resource information which specify which resources need including if the trigger is active.
      SerializationHint[] serializables
      A set of serialization hints indicating which types will be (de)serialized if the trigger is active.
      Class<?> trigger
      The class specified here could be a configuration/registrar/import-selectors which will trigger this hint only when active, or any other class, in that case the hint will be active only if the class is present in the classpath.
      TypeHint[] types
      A set of type information which indicate which types should be made accessible (as via reflection and/or *.class resources) if the trigger is active.
    • Element Detail

      • trigger

        Class<?> trigger
        The class specified here could be a configuration/registrar/import-selectors which will trigger this hint only when active, or any other class, in that case the hint will be active only if the class is present in the classpath. If no value is specified it is considered to be a hint about the type upon which the hint annotation is specified, unless the hosting type is an implementation of NativeConfiguration, in which case the hint with no trigger is considered to encapsulate hints that should always be active. The trigger is ignored for initialization configuration.
        Returns:
        the class that acts as a trigger
        Default:
        java.lang.Object.class
      • types

        TypeHint[] types
        A set of type information which indicate which types should be made accessible (as via reflection and/or *.class resources) if the trigger is active.
        Returns:
        the type information
        Default:
        {}
      • jdkProxies

        JdkProxyHint[] jdkProxies
        A set of proxy information which indicate which sets of types need a proxy if the trigger is active.
        Returns:
        the proxy information
        Default:
        {}
      • aotProxies

        AotProxyHint[] aotProxies
        A set of class proxy information which describe a class based proxy that should be created at build time if the trigger is active.
        Returns:
        the class proxy information
        Default:
        {}
      • serializables

        SerializationHint[] serializables
        A set of serialization hints indicating which types will be (de)serialized if the trigger is active.
        Returns:
        the serialization hint
        Default:
        {}
      • resources

        ResourceHint[] resources
        A set of resource information which specify which resources need including if the trigger is active.
        Returns:
        the resource information
        Default:
        {}
      • initialization

        InitializationHint[] initialization
        A set of initialization information which specify which classes/packages should be initialized explicitly at runtime/build-time (runtime being GraalVM native image default).
        Returns:
        the initialization information
        Default:
        {}
      • imports

        Class<?>[] imports
        A set of types that have TypeHint / JdkProxyHint / etc. annotations on them that should be pulled in as type hints for this one. Using this mechanism a set of TypeHints can be shared by two hints without duplication (e.g. webflux and webmvc).
        Returns:
        the types to import
        Default:
        {}
      • options

        String[] options
        GraalVM native options to configure automatically when the hint is active
        Returns:
        the native options to configure
        Default:
        {}
      • extractTypesFromAttributes

        String[] extractTypesFromAttributes
        Names of the annotation attributes on the target type which contain type names (as class references or strings) other than 'value'. For example in @ConditionalOnBean both value and type can include a type name. This information is used when determining what must be exposed for reflective access.
        Returns:
        the attribute names from which types names should be extracted (e.g. name or type )
        Default:
        {}
      • follow

        boolean follow
        Determine if types inferred or specified directly in TypeHints should be followed to find further hints. Some types must obviously be followed such as @Configuration classes but in cases where it is not obvious follow can be set to true to force it, other types that are automatically followed include selectors and registrars (full list in Type.shouldFollow()).
        Returns:
        true if types related to a hint should be followed to discover further hints
        Default:
        false
      • abortIfTypesMissing

        boolean abortIfTypesMissing
        Determine if analysis should stop if the inferred and/or specific types for this hint cannot be found. For example if an @ConditionalOnClass is used, the conditional class will be inferred. Using this abort option will avoid analysing deeper into the class if that inferred class is missing. Without this the system will assume the existence is optional and proceed with deeper analysis.
        Returns:
        true if analysis should stop when an inferred and/or specific type for this hint cannot be found.
        Default:
        false