Top Description Fields Constructors Methods
org.aspectj.weaver.loadtime

public Class ConcreteAspectCodeGen

extends Object
Class Inheritance
Static Imports
org.aspectj.apache.bcel.generic.Type.NO_ARGS

Generates bytecode for concrete-aspect.

The concrete aspect is generated annotation style aspect (so traditional Java constructs annotated with our AspectJ annotations). As it is built during aop.xml definitions registration we perform the type munging for perclause, ie. aspectOf() artifact directly, instead of waiting for it to go thru the weaver (that we are in the middle of configuring).

Authors
Alexandre Vasseur, Andy Clement

Field Summary

Modifier and TypeField and Description
private byte[]
bytes

Bytecode for the generated class

private final Definition.ConcreteAspect
concreteAspect

Concrete aspect definition we build for

private static final String[]
private boolean
isValid

Set to true when all is checks are verified

private ResolvedType
parent

The parent aspect, not concretized

private PerClause
perclause

Aspect perClause, used for direct munging of aspectOf artifacts

private final World
world

World for which we build for

Constructor Summary

AccessConstructor and Description
pack-priv
ConcreteAspectCodeGen(Definition.ConcreteAspect
the aspect definition
concreteAspect
,
World
the related world (for type resolution, etc)
world
)

Create a new generator for a concrete aspect

Method Summary

Modifier and TypeMethod and Description
private AnnotationAJ
buildAdviceAnnotation(LazyClassGen cg, Definition.PointcutAndAdvice paa)

For the given PointcutAndAdvice build the correct advice annotation.

private AnnotationGen
buildAnnotationFromString(ConstantPool cp, World w, String annotationString)

Build an AnnotationGen object based on a string, for example "@Foo(35,message='string')".

private AnnotationGen
private AnnotationAJ
buildDeclareAnnotation_actualAnnotation(LazyClassGen cg, Definition.DeclareAnnotation da)

Construct the annotation that the declare wants to add to the target.

private void
generateAdviceMethod(Definition.PointcutAndAdvice paa, int adviceCounter, LazyClassGen cg)

The PointcutAndAdvice object encapsulates an advice kind, a pointcut and names a Java method in a particular class.

private void
generateDeclareAnnotation(Definition.DeclareAnnotation da, int decCounter, LazyClassGen cg)

The DeclareAnnotation object encapsulates an method/field/type descriptor and an annotation.

public byte[]

Returns:

the bytecode for the concrete aspect
getBytes
()

public String
private Collection<ResolvedMember>
private void
private boolean
private void
reportError(String message)

Error reporting

private String

Returns:

string repr.
stringify
()

Rebuild the XML snip that defines this concrete aspect, for log error purpose

public boolean

Returns:

true if ok, false otherwise
validate
()

Checks that concrete aspect is valid.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bytesback to summary
private byte[] bytes

Bytecode for the generated class

concreteAspectback to summary
private final Definition.ConcreteAspect concreteAspect

Concrete aspect definition we build for

EMPTY_STRINGSback to summary
private static final String[] EMPTY_STRINGS
isValidback to summary
private boolean isValid

Set to true when all is checks are verified

parentback to summary
private ResolvedType parent

The parent aspect, not concretized

perclauseback to summary
private PerClause perclause

Aspect perClause, used for direct munging of aspectOf artifacts

worldback to summary
private final World world

World for which we build for

Constructor Detail

ConcreteAspectCodeGenback to summary
pack-priv ConcreteAspectCodeGen(Definition.ConcreteAspect concreteAspect, World world)

Create a new generator for a concrete aspect

Parameters
concreteAspect:Definition.ConcreteAspect

the aspect definition

world:World

the related world (for type resolution, etc)

Method Detail

buildAdviceAnnotationback to summary
private AnnotationAJ buildAdviceAnnotation(LazyClassGen cg, Definition.PointcutAndAdvice paa)

For the given PointcutAndAdvice build the correct advice annotation.

buildAnnotationFromStringback to summary
private AnnotationGen buildAnnotationFromString(ConstantPool cp, World w, String annotationString)

Build an AnnotationGen object based on a string, for example "@Foo(35,message='string')". Notice single quotes are fine for strings as they don't need special handling in the XML.

buildBaseAnnotationTypeback to summary
private AnnotationGen buildBaseAnnotationType(ConstantPool cp, World world, String typename)
buildDeclareAnnotation_actualAnnotationback to summary
private AnnotationAJ buildDeclareAnnotation_actualAnnotation(LazyClassGen cg, Definition.DeclareAnnotation da)

Construct the annotation that the declare wants to add to the target.

generateAdviceMethodback to summary
private void generateAdviceMethod(Definition.PointcutAndAdvice paa, int adviceCounter, LazyClassGen cg)

The PointcutAndAdvice object encapsulates an advice kind, a pointcut and names a Java method in a particular class. Generate an annotation style advice that has that pointcut whose implementation delegates to the Java method.

generateDeclareAnnotationback to summary
private void generateDeclareAnnotation(Definition.DeclareAnnotation da, int decCounter, LazyClassGen cg)

The DeclareAnnotation object encapsulates an method/field/type descriptor and an annotation. This uses a DeclareAnnotation object captured from the XML (something like '<declare-annotation field="* field1(..)" annotation="@Annot(a='a',fred=false,'abc')"/>') and builds the same construct that would have existed if the code style variant was used. This involves creating a member upon which to hang the real annotation and then creating a classfile level attribute indicating a declare annotation is present (that includes the signature pattern and a pointer to the real member holding the annotation).

getBytesback to summary
public byte[] getBytes()
Returns:byte[]

the bytecode for the concrete aspect

getClassNameback to summary
public String getClassName()
getOutstandingAbstractMethodsback to summary
private Collection<ResolvedMember> getOutstandingAbstractMethods(ResolvedType type)
getOutstandingAbstractMethodsHelperback to summary
private void getOutstandingAbstractMethodsHelper(ResolvedType type, Map<String, ResolvedMember> collector)
hasPointcutAnnotationback to summary
private boolean hasPointcutAnnotation(ResolvedMember member)
reportErrorback to summary
private void reportError(String message)

Error reporting

stringifyback to summary
private String stringify()

Rebuild the XML snip that defines this concrete aspect, for log error purpose

Returns:String

string repr.

validateback to summary
public boolean validate()

Checks that concrete aspect is valid.

Returns:boolean

true if ok, false otherwise