Package: org.codehaus.groovy.vmplugin.v8

## [Java] Class Java8

- org.codehaus.groovy.vmplugin.v8.Java8

- All Implemented Interfaces and Traits:
    VMPlugin

      @Deprecated(since = "6.0.0", forRemoval = true)
      public class Java8
      extends Object
      implements VMPlugin

  Java 8 based functions.

  deprecated:
    Use Java17 instead. Groovy 6.0 requires JDK 17+.
  Since:
    2.5.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected ClassNode` | `applyTypeAnnotations(AnnotatedType annotatedType, ClassNode classNode)` Applies type-use annotations (JSR 308) of the given annotated type to the given class node, recursing into type arguments, wildcard bounds and array component types.
    `` | `public boolean` | `checkAccessible(Class<?> callerClass, Class<?> declaringClass, int memberModifiers, boolean allowIllegalAccess)` * check whether the member can be accessed or not * Parameters: `callerClass` - callerClass the callerClass to invoke `setAccessible` * `declaringClass` - the type of member owner * `memberModifiers` - modifiers of member * `allowIllegalAccess` - whether to allow illegal access * Returns: the result of checking
    `` | `public boolean` | `checkCanSetAccessible(AccessibleObject accessibleObject, Class<?> callerClass)` The following scenarios can not set accessible, i.e. the return value is false 1) SecurityException occurred 2) the accessible object is a Constructor object for the Class class
    `` | `public void` | `configureAnnotation(AnnotationNode node)` * Copies runtime annotation metadata into the supplied annotation node. * * Parameters: `node` - the annotation node to configure
    `` | `public void` | `configureClassNode(CompileUnit compileUnit, ClassNode classNode)` * Configures the supplied class node from its runtime type information. * * Parameters: `unit` - the compile unit that owns the class node * `node` - the class node to configure
    `` | `public static GenericsType` | `configureTypeVariableDefinition(ClassNode base, ClassNode[] bounds)` Configures a type-variable definition node from its bounds.
    `` | `public static ClassNode` | `configureTypeVariableReference(String name)` Creates a placeholder class node that references a type variable by name.
    `` | `protected void` | `fillParameterNames(String[] names, Member member)` Populates parameter names from the supplied reflective executable member.
    `` | `public Object` | `getInvokeSpecialHandle(Method method, Object receiver)` * Returns a handle with bound receiver to invokeSpecial the given method. * This method will require at least Java 7, but since the source has to compile * on older Java versions as well it is not marked to return a MethodHandle and * uses Object instead * Returns: null in case of jdk<7, otherwise a handle that takes the method call * arguments for the invokespecial call
    `` | `public Class<?>[]` | `getPluginDefaultGroovyMethods()` * Returns plugin-specific default Groovy methods. * * Returns: the default Groovy method classes contributed by this plugin
    `` | `public Class<?>[]` | `getPluginStaticGroovyMethods()` * Returns plugin-specific static Groovy methods. * * Returns: the static Groovy method classes contributed by this plugin
    `` | `protected Expression` | `getValue(Field field)` Returns the initial expression for given field.
    `` | `public int` | `getVersion()` * Gives the version the plugin is made for * Returns: 7 for jdk7, 8 for jdk8, 9 for jdk9 or higher
    `` | `public void` | `invalidateCallSites()` * Invalidates cached call sites maintained by the plugin.
    `` | `public Object` | `invokeHandle(Object handle, Object[] arguments)` * Invokes a handle produced by #getInvokeSpecialdHandle * Parameters: `handle` - the handle * `args` - arguments for the method call, can be empty but not null * Returns: the result of the method call
    `` | `protected ClassNode` | `makeClassNode(CompileUnit cu, Type t, Class<?> c)` Creates or reuses a class node for the supplied runtime and generic type information.
    `` | `protected void` | `makeRecordComponents(CompileUnit cu, ClassNode classNode, Class<?> clazz)` Adds record components to the class node when supported by the runtime.
    `` | `protected Lookup` | `newLookup(Class<?> targetClass)` Creates a lookup capable of accessing members declared by the target class.
    `` | `public static Lookup` | `of(Class<?> targetClass)` Returns a private lookup for the supplied target class using the active VM plugin.
    `` | `public void` | `setAdditionalClassInformation(ClassNode cn)` * Adds VM-specific metadata to the given class node. * * Parameters: `node` - the class node to enrich
    `` | `protected AnnotationNode` | `toAnnotationNode(Annotation annotation)` Converts a runtime annotation instance into a Groovy AST annotation node.
    `` | `public MetaMethod` | `transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod)` * transform meta method. * * Parameters: `metaClass` - metaclass * `metaMethod` - the original meta method * Returns: the transformed meta method
    `` | `public MetaMethod` | `transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?> caller)` * transform meta method * * Parameters: `metaClass` - metaclass * `metaMethod` - the original meta method * `caller` - caller class, whose method sets accessible for methods * Returns: the transformed meta method
    `` | `public boolean` | `trySetAccessible(AccessibleObject ao)` * Set the `accessible` flag for this reflected object to `true` * if possible. * * throws: SecurityException if the request is denied by the security manager (legacy comment) Parameters: `ao` - the accessible object * Returns: `true` if the `accessible` flag is set to `true`; * `false` if access cannot be enabled. *

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### protected ClassNode applyTypeAnnotations(AnnotatedType annotatedType, ClassNode classNode)

      Applies type-use annotations (JSR 308) of the given annotated type to the given class node, recursing into type arguments, wildcard bounds and array component types. The returned node may differ from the input node: type annotations may only be attached to per-use redirect nodes, so shared (cached) nodes are replaced by an annotated plain node reference.

      Parameters:
        `annotatedType` - the reflective annotated type at some position (e.g. a method return type)
        `classNode` - the class node created for that position
      Returns:
        the annotated class node: either the input node or a per-use replacement for it
      Since:
        6.0.0

    - #### public boolean checkAccessible(Class<?> callerClass, Class<?> declaringClass, int memberModifiers, boolean allowIllegalAccess)

      * check whether the member can be accessed or not *

      Parameters:
        `callerClass` - callerClass the callerClass to invoke `setAccessible` *
        `declaringClass` - the type of member owner *
        `memberModifiers` - modifiers of member *
        `allowIllegalAccess` - whether to allow illegal access *
      Returns:
        the result of checking

    - #### public boolean checkCanSetAccessible(AccessibleObject accessibleObject, Class<?> callerClass)

      The following scenarios can not set accessible, i.e. the return value is false 1) SecurityException occurred 2) the accessible object is a Constructor object for the Class class

      Parameters:
        `accessibleObject` - the accessible object to check
        `callerClass` - the callerClass to invoke `setAccessible`
      Returns:
        the check result

    - #### public void configureAnnotation(AnnotationNode node)

      * Copies runtime annotation metadata into the supplied annotation node. * *

      Parameters:
        `node` - the annotation node to configure

    - #### public void configureClassNode(CompileUnit compileUnit, ClassNode classNode)

      * Configures the supplied class node from its runtime type information. * *

      Parameters:
        `unit` - the compile unit that owns the class node *
        `node` - the class node to configure

    - #### public static GenericsType configureTypeVariableDefinition(ClassNode base, ClassNode[] bounds)

      Configures a type-variable definition node from its bounds.

      Parameters:
        `base` - the placeholder class node
        `bounds` - the upper bounds of the type variable
      Returns:
        the configured generics type

    - #### public static ClassNode configureTypeVariableReference(String name)

      Creates a placeholder class node that references a type variable by name.

      Parameters:
        `name` - the type-variable name
      Returns:
        the placeholder class node

    - #### protected void fillParameterNames(String[] names, Member member)

      Populates parameter names from the supplied reflective executable member.

      Parameters:
        `names` - the destination array for parameter names
        `member` - the reflective member providing parameter metadata

    - #### public Object getInvokeSpecialHandle(Method method, Object receiver)

      * Returns a handle with bound receiver to invokeSpecial the given method. * This method will require at least Java 7, but since the source has to compile * on older Java versions as well it is not marked to return a MethodHandle and * uses Object instead *

      Returns:
        null in case of jdk<7, otherwise a handle that takes the method call * arguments for the invokespecial call

    - #### public Class<?>[] getPluginDefaultGroovyMethods()

      * Returns plugin-specific default Groovy methods. * *

      Returns:
        the default Groovy method classes contributed by this plugin

    - #### public Class<?>[] getPluginStaticGroovyMethods()

      * Returns plugin-specific static Groovy methods. * *

      Returns:
        the static Groovy method classes contributed by this plugin

    - #### protected Expression getValue(Field field)

      Returns the initial expression for given field.

      Returns:
        value expression or null
      Since:
        5.0.0

    - #### public int getVersion()

      * Gives the version the plugin is made for *

      Returns:
        7 for jdk7, 8 for jdk8, 9 for jdk9 or higher

    - #### public void invalidateCallSites()

      * Invalidates cached call sites maintained by the plugin.

    - #### public Object invokeHandle(Object handle, Object[] arguments)

      * Invokes a handle produced by #getInvokeSpecialdHandle *

      Parameters:
        `handle` - the handle *
        `args` - arguments for the method call, can be empty but not null *
      Returns:
        the result of the method call

    - #### protected ClassNode makeClassNode(CompileUnit cu, Type t, Class<?> c)

      Creates or reuses a class node for the supplied runtime and generic type information.

      Parameters:
        `cu` - the owning compile unit
        `t` - the reflective type
        `c` - the erased runtime class
      Returns:
        the resolved class node

    - #### protected void makeRecordComponents(CompileUnit cu, ClassNode classNode, Class<?> clazz)

      Adds record components to the class node when supported by the runtime.

      Parameters:
        `cu` - the owning compile unit
        `classNode` - the class node to update
        `clazz` - the runtime class

    - #### protected Lookup newLookup(Class<?> targetClass)

      Creates a lookup capable of accessing members declared by the target class.

      Parameters:
        `targetClass` - the lookup target
      Returns:
        a lookup for the target class

    - #### @Deprecated(since = "5.0.0")
      public static Lookup of(Class<?> targetClass)

      Returns a private lookup for the supplied target class using the active VM plugin.

      Parameters:
        `targetClass` - the class to create a lookup for
      Returns:
        a lookup with private access to `targetClass`

    - #### public void setAdditionalClassInformation(ClassNode cn)

      * Adds VM-specific metadata to the given class node. * *

      Parameters:
        `node` - the class node to enrich

    - #### protected AnnotationNode toAnnotationNode(Annotation annotation)

      Converts a runtime annotation instance into a Groovy AST annotation node.

      Parameters:
        `annotation` - the runtime annotation
      Returns:
        the corresponding annotation node

    - #### public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod)

      * transform meta method. * *

      Parameters:
        `metaClass` - metaclass *
        `metaMethod` - the original meta method *
      Returns:
        the transformed meta method

    - #### public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?> caller)

      * transform meta method * *

      Parameters:
        `metaClass` - metaclass *
        `metaMethod` - the original meta method *
        `caller` - caller class, whose method sets accessible for methods *
      Returns:
        the transformed meta method

    - #### public boolean trySetAccessible(AccessibleObject ao)

      * Set the `accessible` flag for this reflected object to `true` * if possible. * *

      throws:
        SecurityException if the request is denied by the security manager (legacy comment)
      Parameters:
        `ao` - the accessible object *
      Returns:
        `true` if the `accessible` flag is set to `true`; * `false` if access cannot be enabled. *