Top Description Inners Fields Constructors Methods
org.codehaus.groovy.vmplugin.v8

public Class Java8

extends Object
implements VMPlugin
Class Inheritance
All Implemented Interfaces
org.codehaus.groovy.vmplugin.VMPlugin
Known Direct Subclasses
org.codehaus.groovy.vmplugin.v9.Java9
Imports
groovy.lang.GroovyRuntimeException, .MetaClass, .MetaMethod, org.codehaus.groovy.GroovyBugError, org.codehaus.groovy.ast.AnnotatedNode, .AnnotationNode, .ClassHelper, .ClassNode, .CompileUnit, .ConstructorNode, .FieldNode, .GenericsType, .MethodNode, .PackageNode, .Parameter, org.codehaus.groovy.ast.expr.AnnotationConstantExpression, .ClassExpression, .ConstantExpression, .Expression, .ListExpression, .PropertyExpression, org.codehaus.groovy.ast.stmt.ReturnStatement, org.codehaus.groovy.reflection.ReflectionUtils, org.codehaus.groovy.vmplugin.VMPlugin, .VMPluginFactory, java.lang.annotation.Annotation, .ElementType, .Retention, .RetentionPolicy, .Target, java.lang.invoke.MethodHandle, .MethodHandles, java.lang.reflect.AccessibleObject, .Array, .Constructor, .Field, .GenericArrayType, .GenericSignatureFormatError, .InvocationTargetException, .MalformedParameterizedTypeException, .Member, .Method, .ParameterizedType, .ReflectPermission, .Type, .TypeVariable, .WildcardType, java.security.AccessController, .Permission, .PrivilegedAction, java.util.List

Java 8 based functions.
Since
2.5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final Permission
private static final Annotation[]
private static final Method[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
checkAccessible(final Class<?>
callerClass the callerClass to invoke setAccessible
callerClass
,
final Class<?>
the type of member owner
declaringClass
,
final int
modifiers of member
memberModifiers
,
final boolean
whether to allow illegal access
allowIllegalAccess
)

Implements org.codehaus.groovy.vmplugin.VMPlugin.checkAccessible.

check whether the member can be accessed or not
public boolean

Returns:

the check result
checkCanSetAccessible
(final AccessibleObject
the accessible object to check
accessibleObject
,
final Class<?>
the callerClass to invoke setAccessible
callerClass
)

Implements org.codehaus.groovy.vmplugin.VMPlugin.checkCanSetAccessible.

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
private void
configureAnnotation(final AnnotationNode node, final Annotation annotation)

public void
private static ClassNode
configureClass(final Class<?> c)

public void
private ClassNode
configureGenericArray(final GenericArrayType genericArrayType)

private ClassNode
private ClassNode
configureType(final Type type)

private GenericsType[]
private GenericsType[]
private ClassNode[]
configureTypes(final Type[] types)

public static GenericsType
public static ClassNode
private ClassNode
configureWildcardType(final WildcardType wildcardType)

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

private Annotation[][]

Returns:

array of arrays containing the annotations on the parameters of the given Constructor
getConstructorParameterAnnotations
(final Constructor<?>
the Constructor for which to return parameter annotations
constructor
)

Synthetic parameters such as those added for inner class constructors may not be included in the parameter annotations array.

protected int
public Object
getInvokeSpecialHandle(final Method method, final Object receiver)

Implements org.codehaus.groovy.vmplugin.VMPlugin.getInvokeSpecialHandle.

Returns a handle with bound receiver to invokeSpecial the given method.
private Object
getInvokeSpecialHandleFallback(final Method method, final Object receiver)

private static Constructor<MethodHandles.Lookup>
public Class<?>[]
public Class<?>[]
public int
getVersion()

Implements org.codehaus.groovy.vmplugin.VMPlugin.getVersion.

Gives the version the plugin is made for
public void
public Object
invokeHandle(final Object
the handle
handle
,
final Object[]
arguments for the method call, can be empty but not null
args
)

Implements org.codehaus.groovy.vmplugin.VMPlugin.invokeHandle.

Invokes a handle produced by #getInvokeSpecialdHandle
private ClassNode
makeClassNode(final CompileUnit cu, Type t, final Class<?> c)

private ClassNode[]
makeClassNodes(final CompileUnit cu, final Type[] types, final Class<?>[] cls)

private void
makeInterfaceTypes(final CompileUnit cu, final ClassNode classNode, final Class<?> clazz)

protected Parameter
makeParameter(final CompileUnit cu, final Type type, final Class<?> cl, final Annotation[] annotations, final String name)

Deprecated
private Parameter[]
makeParameters(final CompileUnit cu, final Type[] types, final Class<?>[] cls, final Annotation[][] parameterAnnotations, final Member member)

public static MethodHandles.Lookup
of(final Class<?> targetClass)

protected Parameter[]
processParameters(final CompileUnit compileUnit, final Method m)

Deprecated
public void
private void
setAnnotationMetaData(final Annotation[] annotations, final AnnotatedNode target)

private static void
private AnnotationNode
toAnnotationNode(final Annotation annotation)

private Expression
public MetaMethod
transformMetaMethod(final MetaClass
meta class
metaClass
,
final MetaMethod
the original meta method
metaMethod
,
final Class<?>
caller class, whose method sets accessible for methods
caller
)

Implements org.codehaus.groovy.vmplugin.VMPlugin.transformMetaMethod.

transform meta method
public MetaMethod
transformMetaMethod(final MetaClass
meta class
metaClass
,
final MetaMethod
the original meta method
metaMethod
)

Implements org.codehaus.groovy.vmplugin.VMPlugin.transformMetaMethod.

transform meta method.
public boolean
trySetAccessible(final AccessibleObject
the accessible object
ao
)

Implements org.codehaus.groovy.vmplugin.VMPlugin.trySetAccessible.

Set the accessible flag for this reflected object to true if possible.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ACCESS_PERMISSIONback to summary
private static final Permission ACCESS_PERMISSION
EMPTY_ANNOTATION_ARRAYback to summary
private static final Annotation[] EMPTY_ANNOTATION_ARRAY
EMPTY_METHOD_ARRAYback to summary
private static final Method[] EMPTY_METHOD_ARRAY

Constructor Detail

Java8back to summary
public Java8()

Method Detail

checkAccessibleback to summary
public boolean checkAccessible(final Class<?> callerClass, final Class<?> declaringClass, final int memberModifiers, final boolean allowIllegalAccess)

Implements org.codehaus.groovy.vmplugin.VMPlugin.checkAccessible.

Doc from org.codehaus.groovy.vmplugin.VMPlugin.checkAccessible.

check whether the member can be accessed or not

Parameters
callerClass:Class<?>

callerClass the callerClass to invoke setAccessible

declaringClass:Class<?>

the type of member owner

memberModifiers:int

modifiers of member

allowIllegalAccess:boolean

whether to allow illegal access

Returns:boolean

the result of checking

Annotations
@Override
checkCanSetAccessibleback to summary
public boolean checkCanSetAccessible(final AccessibleObject accessibleObject, final Class<?> callerClass)

Implements org.codehaus.groovy.vmplugin.VMPlugin.checkCanSetAccessible.

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:AccessibleObject

the accessible object to check

callerClass:Class<?>

the callerClass to invoke setAccessible

Returns:boolean

the check result

Annotations
@Override
configureAnnotationback to summary
public void configureAnnotation(final AnnotationNode node)

Implements org.codehaus.groovy.vmplugin.VMPlugin.configureAnnotation.

Annotations
@Override
configureAnnotationback to summary
private void configureAnnotation(final AnnotationNode node, final Annotation annotation)
configureAnnotationNodeFromDefinitionback to summary
public void configureAnnotationNodeFromDefinition(final AnnotationNode definition, final AnnotationNode root)

Implements org.codehaus.groovy.vmplugin.VMPlugin.configureAnnotationNodeFromDefinition.

Annotations
@Override
configureClassback to summary
private static ClassNode configureClass(final Class<?> c)
configureClassNodeback to summary
public void configureClassNode(final CompileUnit compileUnit, final ClassNode classNode)

Implements org.codehaus.groovy.vmplugin.VMPlugin.configureClassNode.

Annotations
@Override
configureGenericArrayback to summary
private ClassNode configureGenericArray(final GenericArrayType genericArrayType)
configureParameterizedTypeback to summary
private ClassNode configureParameterizedType(final ParameterizedType parameterizedType)
configureTypeback to summary
private ClassNode configureType(final Type type)
configureTypeArgumentsback to summary
private GenericsType[] configureTypeArguments(final Type[] ta)
configureTypeParametersback to summary
private GenericsType[] configureTypeParameters(final TypeVariable<?>[] tp)
configureTypesback to summary
private ClassNode[] configureTypes(final Type[] types)
configureTypeVariableDefinitionback to summary
public static GenericsType configureTypeVariableDefinition(final ClassNode base, final ClassNode[] bounds)
configureTypeVariableReferenceback to summary
public static ClassNode configureTypeVariableReference(final String name)
configureWildcardTypeback to summary
private ClassNode configureWildcardType(final WildcardType wildcardType)
fillParameterNamesback to summary
protected void fillParameterNames(final String[] names, final Member member)
getConstructorParameterAnnotationsback to summary
private Annotation[][] getConstructorParameterAnnotations(final Constructor<?> constructor)

Synthetic parameters such as those added for inner class constructors may not be included in the parameter annotations array. This is the case when at least one parameter of an inner class constructor has an annotation with a RUNTIME retention (this occurs for JDK8 and below). This method will normalize the annotations array so that it contains the same number of elements as the array returned from Constructor#getParameterTypes(). If adjustment is required, the adjusted array will be prepended with a zero-length element. If no adjustment is required, the original array from Constructor#getParameterAnnotations() will be returned.

Parameters
constructor:Constructor<?>

the Constructor for which to return parameter annotations

Returns:Annotation[][]

array of arrays containing the annotations on the parameters of the given Constructor

getElementCodeback to summary
protected int getElementCode(final ElementType value)
getInvokeSpecialHandleback to summary
public Object getInvokeSpecialHandle(final Method method, final Object receiver)

Implements org.codehaus.groovy.vmplugin.VMPlugin.getInvokeSpecialHandle.

Doc from org.codehaus.groovy.vmplugin.VMPlugin.getInvokeSpecialHandle.

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:Object

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

Annotations
@Override
getInvokeSpecialHandleFallbackback to summary
private Object getInvokeSpecialHandleFallback(final Method method, final Object receiver)
getLookupConstructorback to summary
private static Constructor<MethodHandles.Lookup> getLookupConstructor()
getPluginDefaultGroovyMethodsback to summary
public Class<?>[] getPluginDefaultGroovyMethods()

Implements org.codehaus.groovy.vmplugin.VMPlugin.getPluginDefaultGroovyMethods.

Annotations
@Override
getPluginStaticGroovyMethodsback to summary
public Class<?>[] getPluginStaticGroovyMethods()

Implements org.codehaus.groovy.vmplugin.VMPlugin.getPluginStaticGroovyMethods.

Annotations
@Override
getVersionback to summary
public int getVersion()

Implements org.codehaus.groovy.vmplugin.VMPlugin.getVersion.

Doc from org.codehaus.groovy.vmplugin.VMPlugin.getVersion.

Gives the version the plugin is made for

Returns:int

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

Annotations
@Override
invalidateCallSitesback to summary
public void invalidateCallSites()

Implements org.codehaus.groovy.vmplugin.VMPlugin.invalidateCallSites.

Annotations
@Override
invokeHandleback to summary
public Object invokeHandle(final Object handle, final Object[] args) throws Throwable

Implements org.codehaus.groovy.vmplugin.VMPlugin.invokeHandle.

Doc from org.codehaus.groovy.vmplugin.VMPlugin.invokeHandle.

Invokes a handle produced by #getInvokeSpecialdHandle

Parameters
handle:Object

the handle

args:Object[]

arguments for the method call, can be empty but not null

Returns:Object

the result of the method call

Annotations
@Override
makeClassNodeback to summary
private ClassNode makeClassNode(final CompileUnit cu, Type t, final Class<?> c)
makeClassNodesback to summary
private ClassNode[] makeClassNodes(final CompileUnit cu, final Type[] types, final Class<?>[] cls)
makeInterfaceTypesback to summary
private void makeInterfaceTypes(final CompileUnit cu, final ClassNode classNode, final Class<?> clazz)
makeParameterback to summary
protected Parameter makeParameter(final CompileUnit cu, final Type type, final Class<?> cl, final Annotation[] annotations, final String name)

Deprecated

Annotations
@Deprecated
makeParametersback to summary
private Parameter[] makeParameters(final CompileUnit cu, final Type[] types, final Class<?>[] cls, final Annotation[][] parameterAnnotations, final Member member)
ofback to summary
public static MethodHandles.Lookup of(final Class<?> targetClass)
processParametersback to summary
protected Parameter[] processParameters(final CompileUnit compileUnit, final Method m)

Deprecated

Annotations
@Deprecated
setAdditionalClassInformationback to summary
public void setAdditionalClassInformation(final ClassNode cn)

Implements org.codehaus.groovy.vmplugin.VMPlugin.setAdditionalClassInformation.

Annotations
@Override
setAnnotationMetaDataback to summary
private void setAnnotationMetaData(final Annotation[] annotations, final AnnotatedNode target)
setRetentionPolicyback to summary
private static void setRetentionPolicy(final RetentionPolicy value, final AnnotationNode node)
toAnnotationNodeback to summary
private AnnotationNode toAnnotationNode(final Annotation annotation)
toAnnotationValueExpressionback to summary
private Expression toAnnotationValueExpression(final Object value)
transformMetaMethodback to summary
public MetaMethod transformMetaMethod(final MetaClass metaClass, final MetaMethod metaMethod, final Class<?> caller)

Implements org.codehaus.groovy.vmplugin.VMPlugin.transformMetaMethod.

Doc from org.codehaus.groovy.vmplugin.VMPlugin.transformMetaMethod.

transform meta method

Parameters
metaClass:MetaClass

meta class

metaMethod:MetaMethod

the original meta method

caller:Class<?>

caller class, whose method sets accessible for methods

Returns:MetaMethod

the transformed meta method

Annotations
@Override
transformMetaMethodback to summary
public MetaMethod transformMetaMethod(final MetaClass metaClass, final MetaMethod metaMethod)

Implements org.codehaus.groovy.vmplugin.VMPlugin.transformMetaMethod.

Doc from org.codehaus.groovy.vmplugin.VMPlugin.transformMetaMethod.

transform meta method.

Parameters
metaClass:MetaClass

meta class

metaMethod:MetaMethod

the original meta method

Returns:MetaMethod

the transformed meta method

Annotations
@Override
trySetAccessibleback to summary
public boolean trySetAccessible(final AccessibleObject ao)

Implements org.codehaus.groovy.vmplugin.VMPlugin.trySetAccessible.

Doc from org.codehaus.groovy.vmplugin.VMPlugin.trySetAccessible.

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

Parameters
ao:AccessibleObject

the accessible object

Returns:boolean

true if the accessible flag is set to true; false if access cannot be enabled.

Annotations
@Override
org.codehaus.groovy.vmplugin.v8 back to summary

private Class Java8.LookupHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final Constructor<MethodHandles.Lookup>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOOKUP_Constructorback to summary
private static final Constructor<MethodHandles.Lookup> LOOKUP_Constructor

Constructor Detail

LookupHolderback to summary
private LookupHolder()