Top Description Inners Fields Constructors Methods
org.codehaus.groovy.classgen

public Class Verifier

extends Object
implements GroovyClassVisitor, Opcodes
Class Inheritance
All Implemented Interfaces
org.objectweb.asm.Opcodes, org.codehaus.groovy.ast.GroovyClassVisitor
Known Direct Subclasses
org.codehaus.groovy.transform.trait.TraitASTTransformation.DefaultArgsMethodsAdder
Imports
groovy.lang.GroovyClassLoader, .GroovyRuntimeException, .MetaClass, groovy.transform.Generated, .Internal, org.apache.groovy.ast.tools.ClassNodeUtils, org.apache.groovy.util.BeanUtils, org.codehaus.groovy.GroovyBugError, org.codehaus.groovy.ast.ASTNode, .AnnotationNode, .ClassHelper, .ClassNode, .CodeVisitorSupport, .ConstructorNode, .DynamicVariable, .FieldNode, .GenericsType, .GroovyClassVisitor, .GroovyCodeVisitor, .InnerClassNode, .MethodNode, .Parameter, .PropertyNode, .Variable, .VariableScope, org.codehaus.groovy.ast.expr.ArgumentListExpression, .BinaryExpression, .CastExpression, .ClosureExpression, .ConstantExpression, .ConstructorCallExpression, .Expression, .FieldExpression, .MethodCallExpression, .VariableExpression, org.codehaus.groovy.ast.stmt.BlockStatement, .ExpressionStatement, .ReturnStatement, .Statement, org.codehaus.groovy.classgen.asm.BytecodeHelper, .MopWriter, .OptimizingStatementWriter.ClassNodeSkip, .WriterController, org.codehaus.groovy.reflection.ClassInfo, org.codehaus.groovy.syntax.RuntimeParserException, .Token, .Types, org.codehaus.groovy.transform.trait.Traits, org.objectweb.asm.Label, .MethodVisitor, .Opcodes, java.beans.Transient, java.lang.reflect.Field, java.util.ArrayList, .Arrays, .Collections, .HashMap, .HashSet, .Iterator, .List, .ListIterator, .Map, .Set

Verifies the AST node and adds any default AST code before bytecode generation occurs.

Checks include:

Added code includes:

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
private static class

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
private ClassNode
public static final String
private static final ClassNode
public static final String
private static final ClassNode
private MethodNode
private static final Parameter[]
public static final String
public static final String
private static final ClassNode

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
addConstructor(final Parameter[] newParams, final ConstructorNode ctor, final Statement code, final ClassNode type)

protected void
addCovariantMethods(final ClassNode classNode)

private void
addCovariantMethods(final ClassNode classNode, final List<MethodNode> declaredMethods, final Map<String, MethodNode> abstractMethods, final Map<String, MethodNode> methodsToAdd, final Map<String, ClassNode> oldGenericsSpec)

protected void
protected void
addDefaultParameterConstructors(final ClassNode type)

Creates a new constructor for each combination of default parameter expressions.

protected void
addDefaultParameterMethods(final ClassNode type)

Creates a new method for each combination of default parameter expressions.

protected void
addDefaultParameters(final List<? extends MethodNode> methods, final Verifier.DefaultArgsAction action)

Creates a new helper method for each combination of default parameter expressions.

protected void
private static void
addFastPathHelperFieldsAndHelperMethod(final ClassNode node, final String classInternalName)

protected void
addFieldInitialization(final List<E> list, final List<E> staticList, final FieldNode fieldNode, final boolean isEnumClassNode, final List<E> initStmtsAfterEnumValuesInit, final Set<E> explicitStaticPropsInEnum)

protected void
addGroovyObjectInterfaceAndMethods(final ClassNode node, final String classInternalName)

protected void
protected void
addInitialization(final ClassNode node, final ConstructorNode constructorNode)

protected MethodNode
addMethod(final ClassNode node, final boolean shouldBeSynthetic, final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Helper method to add a new method to a ClassNode.

protected void
addMethod$$bridge(final ClassNode node, final boolean shouldBeSynthetic, final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

protected void
protected void
private void
addStaticMetaClassField(final ClassNode node, final String classInternalName)

protected void
addTimeStamp(final ClassNode node)

Deprecated
private static void
public static String
capitalize(final String name)

Capitalizes the start of the given bean property name.

private static FieldNode
checkFieldDoesNotExist(final ClassNode node, final String fieldName)

private void
private static void
private static void
private static void
private static Parameter[]
cleanParameters(final Parameter[] parameters)

private static ClassNode
cleanType(final ClassNode type)

protected Statement
createGetterBlock(final PropertyNode propertyNode, final FieldNode field)

protected Statement
createSetterBlock(final PropertyNode propertyNode, final FieldNode field)

private static boolean
private static boolean
equalParametersWithGenerics(final MethodNode m1, final MethodNode m2, final Map<String, ClassNode> genericsSpec)

private static boolean
private static List<Statement>
public ClassNode
private MethodNode
getCovariantImplementation(final MethodNode oldMethod, final MethodNode overridingMethod, Map<String, ClassNode> genericsSpec, final boolean ignoreError)

private static Set<String>
protected FinalVariableAnalyzer.VariableNotFinalCallback
private static Statement
getImplicitThis$0Stmt(final List<Statement> statements)

When InnerClassVisitor adds this.this$0 = $p$n, it adds it as a BlockStatement having that ExpressionStatement.

private static FieldNode
public MethodNode
public static long
getTimestamp(final Class<?> clazz)

public static Long
private static boolean
isArrayAssignable(final ClassNode node, final ClassNode testNode)

private static boolean
isAssignable(final ClassNode node, final ClassNode testNode)

private boolean
private static boolean
private static String
protected void
setClassNode(final ClassNode classNode)

private static FieldNode
setMetaClassFieldIfNotExists(final ClassNode node, FieldNode metaClassField)

private static ASTNode
sourceOf(final MethodNode methodNode)

private void
storeMissingCovariantMethods(final List<MethodNode> declaredMethods, final Map<String, MethodNode> methodsToAdd, final Map<String, ClassNode> genericsSpec, final List<MethodNode> methodNodeList)

private void
storeMissingCovariantMethods(final Iterable<MethodNode> methods, final MethodNode method, final Map<String, MethodNode> methodsToAdd, final Map<String, ClassNode> genericsSpec, final boolean ignoreError)

public static ConstantExpression

Returns:

the same instance of constant expression if the type is already primitive, or a primitive constant if possible.
transformToPrimitiveConstantIfPossible
(final ConstantExpression
a constant expression
constantExpression
)

When constant expressions are created, the value is always wrapped to a non primitive type.

public void
public void
public void
public void
visitGenericType(final GenericsType genericsType)

private void
visitGetter(final PropertyNode node, final Statement getterBlock, final int getterModifiers, final String getterName)

public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__TIMESTAMPback to summary
public static final String __TIMESTAMP
__TIMESTAMP__back to summary
public static final String __TIMESTAMP__
classNodeback to summary
private ClassNode classNode
DEFAULT_PARAMETER_GENERATEDback to summary
public static final String DEFAULT_PARAMETER_GENERATED
GENERATED_ANNOTATIONback to summary
private static final ClassNode GENERATED_ANNOTATION
INITIAL_EXPRESSIONback to summary
public static final String INITIAL_EXPRESSION
INTERNAL_ANNOTATIONback to summary
private static final ClassNode INTERNAL_ANNOTATION
methodNodeback to summary
private MethodNode methodNode
SET_METACLASS_PARAMSback to summary
private static final Parameter[] SET_METACLASS_PARAMS
STATIC_METACLASS_BOOLback to summary
public static final String STATIC_METACLASS_BOOL
SWAP_INITback to summary
public static final String SWAP_INIT
TRANSIENT_ANNOTATIONback to summary
private static final ClassNode TRANSIENT_ANNOTATION

Constructor Detail

Verifierback to summary
public Verifier()

Method Detail

addClosureCodeback to summary
protected void addClosureCode(InnerClassNode node)
addConstructorback to summary
protected void addConstructor(final Parameter[] newParams, final ConstructorNode ctor, final Statement code, final ClassNode type)
addCovariantMethodsback to summary
protected void addCovariantMethods(final ClassNode classNode)
addCovariantMethodsback to summary
private void addCovariantMethods(final ClassNode classNode, final List<MethodNode> declaredMethods, final Map<String, MethodNode> abstractMethods, final Map<String, MethodNode> methodsToAdd, final Map<String, ClassNode> oldGenericsSpec)
addDefaultConstructorback to summary
protected void addDefaultConstructor(final ClassNode node)
addDefaultParameterConstructorsback to summary
protected void addDefaultParameterConstructors(final ClassNode type)

Creates a new constructor for each combination of default parameter expressions.

addDefaultParameterMethodsback to summary
protected void addDefaultParameterMethods(final ClassNode type)

Creates a new method for each combination of default parameter expressions.

addDefaultParametersback to summary
protected void addDefaultParameters(final List<? extends MethodNode> methods, final Verifier.DefaultArgsAction action)

Creates a new helper method for each combination of default parameter expressions.

addDefaultParametersback to summary
protected void addDefaultParameters(final Verifier.DefaultArgsAction action, final MethodNode method)
addFastPathHelperFieldsAndHelperMethodback to summary
private static void addFastPathHelperFieldsAndHelperMethod(final ClassNode node, final String classInternalName)
addFieldInitializationback to summary
protected void addFieldInitialization(final List<E> list, final List<E> staticList, final FieldNode fieldNode, final boolean isEnumClassNode, final List<E> initStmtsAfterEnumValuesInit, final Set<E> explicitStaticPropsInEnum)
addGroovyObjectInterfaceAndMethodsback to summary
protected void addGroovyObjectInterfaceAndMethods(final ClassNode node, final String classInternalName)
addInitializationback to summary
protected void addInitialization(final ClassNode node)
addInitializationback to summary
protected void addInitialization(final ClassNode node, final ConstructorNode constructorNode)
addMethodback to summary
protected MethodNode addMethod(final ClassNode node, final boolean shouldBeSynthetic, final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Helper method to add a new method to a ClassNode. Depending on the shouldBeSynthetic flag the call will either be made to ClassNode.addSyntheticMethod() or ClassNode.addMethod(). If a non-synthetic method is to be added the ACC_SYNTHETIC modifier is removed if it has been accidentally supplied.

addMethod$$bridgeback to summary
protected void addMethod$$bridge(final ClassNode node, final boolean shouldBeSynthetic, final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)
addPropertyMethodback to summary
protected void addPropertyMethod(final MethodNode method)
addReturnIfNeededback to summary
protected void addReturnIfNeeded(final MethodNode node)
addStaticMetaClassFieldback to summary
private void addStaticMetaClassField(final ClassNode node, final String classInternalName)
addTimeStampback to summary
protected void addTimeStamp(final ClassNode node)

Deprecated

Annotations
@Deprecated
adjustTypesIfStaticMainMethodback to summary
private static void adjustTypesIfStaticMainMethod(final MethodNode node)
capitalizeback to summary
public static String capitalize(final String name)

Capitalizes the start of the given bean property name.

checkFieldDoesNotExistback to summary
private static FieldNode checkFieldDoesNotExist(final ClassNode node, final String fieldName)
checkFinalVariablesback to summary
private void checkFinalVariables(final ClassNode node)
checkForDuplicateInterfacesback to summary
private static void checkForDuplicateInterfaces(final ClassNode cn)
checkForDuplicateMethodsback to summary
private static void checkForDuplicateMethods(final ClassNode cn)
checkReturnInObjectInitializerback to summary
private static void checkReturnInObjectInitializer(final List<Statement> init)
cleanParametersback to summary
private static Parameter[] cleanParameters(final Parameter[] parameters)
cleanTypeback to summary
private static ClassNode cleanType(final ClassNode type)
createGetterBlockback to summary
protected Statement createGetterBlock(final PropertyNode propertyNode, final FieldNode field)
createSetterBlockback to summary
protected Statement createSetterBlock(final PropertyNode propertyNode, final FieldNode field)
equalParametersNormalback to summary
private static boolean equalParametersNormal(final MethodNode m1, final MethodNode m2)
equalParametersWithGenericsback to summary
private static boolean equalParametersWithGenerics(final MethodNode m1, final MethodNode m2, final Map<String, ClassNode> genericsSpec)
extractImplicitThis$0StmtFromExpressionback to summary
private static boolean extractImplicitThis$0StmtFromExpression(final List<Statement> stmts, final Statement exprStmt)
extractVariableReferenceInitializersback to summary
private static List<Statement> extractVariableReferenceInitializers(final List<Statement> statements)
getClassNodeback to summary
public ClassNode getClassNode()
getCovariantImplementationback to summary
private MethodNode getCovariantImplementation(final MethodNode oldMethod, final MethodNode overridingMethod, Map<String, ClassNode> genericsSpec, final boolean ignoreError)
getExplicitStaticPropertiesback to summary
private static Set<String> getExplicitStaticProperties(final ClassNode cn)
getFinalVariablesCallbackback to summary
protected FinalVariableAnalyzer.VariableNotFinalCallback getFinalVariablesCallback()
getImplicitThis$0Stmtback to summary
private static Statement getImplicitThis$0Stmt(final List<Statement> statements)

When InnerClassVisitor adds this.this$0 = $p$n, it adds it as a BlockStatement having that ExpressionStatement.

getMetaClassFieldback to summary
private static FieldNode getMetaClassField(final ClassNode node)
getMethodNodeback to summary
public MethodNode getMethodNode()
getTimestampback to summary
public static long getTimestamp(final Class<?> clazz)
getTimestampFromFieldNameback to summary
public static Long getTimestampFromFieldName(final String fieldName)
isArrayAssignableback to summary
private static boolean isArrayAssignable(final ClassNode node, final ClassNode testNode)
isAssignableback to summary
private static boolean isAssignable(final ClassNode node, final ClassNode testNode)
methodNeedsReplacementback to summary
private boolean methodNeedsReplacement(final MethodNode m)
moveOptimizedConstantsInitializationback to summary
private static boolean moveOptimizedConstantsInitialization(final ClassNode node)
scriptBodySignatureWithoutReturnTypeback to summary
private static String scriptBodySignatureWithoutReturnType(final ClassNode cn)
setClassNodeback to summary
protected void setClassNode(final ClassNode classNode)
setMetaClassFieldIfNotExistsback to summary
private static FieldNode setMetaClassFieldIfNotExists(final ClassNode node, FieldNode metaClassField)
sourceOfback to summary
private static ASTNode sourceOf(final MethodNode methodNode)
storeMissingCovariantMethodsback to summary
private void storeMissingCovariantMethods(final List<MethodNode> declaredMethods, final Map<String, MethodNode> methodsToAdd, final Map<String, ClassNode> genericsSpec, final List<MethodNode> methodNodeList)
storeMissingCovariantMethodsback to summary
private void storeMissingCovariantMethods(final Iterable<MethodNode> methods, final MethodNode method, final Map<String, MethodNode> methodsToAdd, final Map<String, ClassNode> genericsSpec, final boolean ignoreError)
transformToPrimitiveConstantIfPossibleback to summary
public static ConstantExpression transformToPrimitiveConstantIfPossible(final ConstantExpression constantExpression)

When constant expressions are created, the value is always wrapped to a non primitive type. Some constant expressions are optimized to return primitive types, but not all primitives are handled. This method guarantees to return a similar constant expression but with a primitive type instead of a boxed type.

Additionally, single char strings are converted to 'char' types.

Parameters
constantExpression:ConstantExpression

a constant expression

Returns:ConstantExpression

the same instance of constant expression if the type is already primitive, or a primitive constant if possible.

visitClassback to summary
public void visitClass(final ClassNode node)

Implements org.codehaus.groovy.ast.GroovyClassVisitor.visitClass.

Doc from org.codehaus.groovy.ast.GroovyClassVisitor.visitClass.

Visit a ClassNode.

Annotations
@Override
visitConstructorback to summary
public void visitConstructor(final ConstructorNode node)

Implements org.codehaus.groovy.ast.GroovyClassVisitor.visitConstructor.

Doc from org.codehaus.groovy.ast.GroovyClassVisitor.visitConstructor.

Visit a ConstructorNode.

Annotations
@Override
visitFieldback to summary
public void visitField(final FieldNode node)

Implements org.codehaus.groovy.ast.GroovyClassVisitor.visitField.

Doc from org.codehaus.groovy.ast.GroovyClassVisitor.visitField.

Visit a FieldNode.

Annotations
@Override
visitGenericTypeback to summary
public void visitGenericType(final GenericsType genericsType)
visitGetterback to summary
private void visitGetter(final PropertyNode node, final Statement getterBlock, final int getterModifiers, final String getterName)
visitMethodback to summary
public void visitMethod(final MethodNode node)

Implements org.codehaus.groovy.ast.GroovyClassVisitor.visitMethod.

Doc from org.codehaus.groovy.ast.GroovyClassVisitor.visitMethod.

Visit a MethodNode.

Annotations
@Override
visitPropertyback to summary
public void visitProperty(final PropertyNode node)

Implements org.codehaus.groovy.ast.GroovyClassVisitor.visitProperty.

Doc from org.codehaus.groovy.ast.GroovyClassVisitor.visitProperty.

Visit a PropertyNode.

Annotations
@Override
org.codehaus.groovy.classgen back to summary

public Interface Verifier.DefaultArgsAction

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public void
call(ArgumentListExpression arguments, Parameter[] parameters, MethodNode method)

Method Detail

callback to summary
public void call(ArgumentListExpression arguments, Parameter[] parameters, MethodNode method)
org.codehaus.groovy.classgen back to summary

private Class Verifier.SwapInitStatement

extends BytecodeSequence
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private WriterController

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
visit(final GroovyCodeVisitor visitor)

Overrides org.codehaus.groovy.classgen.BytecodeSequence.visit.

Delegates to the visit method used for this class.
Inherited from org.codehaus.groovy.classgen.BytecodeSequence:
getBytecodeInstructiongetInstructions

Field Detail

controllerback to summary
private WriterController controller

Constructor Detail

SwapInitStatementback to summary
pack-priv SwapInitStatement()

Method Detail

visitback to summary
public void visit(final GroovyCodeVisitor visitor)

Overrides org.codehaus.groovy.classgen.BytecodeSequence.visit.

Doc from org.codehaus.groovy.classgen.BytecodeSequence.visit.

Delegates to the visit method used for this class. If the visitor is a ClassGenerator, then ClassGenerator#visitBytecodeSequence(BytecodeSequence) is called with this instance. If the visitor is no ClassGenerator, then this method will call visit on each ASTNode element sorted by this class. If one element is a BytecodeInstruction, then it will be skipped as it is no ASTNode.

Annotations
@Override
org.codehaus.groovy.classgen back to summary

private Class Verifier.SwapInitStatement.SwapInitInstruction

extends BytecodeInstruction
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Verifier.SwapInitStatement

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void

Field Detail

statementback to summary
private Verifier.SwapInitStatement statement

Constructor Detail

SwapInitInstructionback to summary
private SwapInitInstruction()

Method Detail

visitback to summary
public void visit(final MethodVisitor mv)

Implements abstract org.codehaus.groovy.classgen.BytecodeInstruction.visit.

Annotations
@Override