org.aspectj.weaver.bcel
Class LazyMethodGen

java.lang.Object
  extended by org.aspectj.weaver.bcel.LazyMethodGen
All Implemented Interfaces:
Traceable

public final class LazyMethodGen
extends java.lang.Object
implements Traceable

A LazyMethodGen should be treated as a MethodGen. It's our way of abstracting over the low-level Method objects. It converts through MethodGen to create and to serialize, but that's it.

At any rate, there are two ways to create LazyMethodGens. One is from a method, which does work through MethodGen to do the correct thing. The other is the creation of a completely empty LazyMethodGen, and it is used when we're constructing code from scratch.

We stay away from targeters for rangey things like Shadows and Exceptions.


Field Summary
 ResolvedType definingType
           
 
Constructor Summary
LazyMethodGen(org.aspectj.weaver.bcel.BcelMethod m, LazyClassGen enclosingClass)
           
LazyMethodGen(int modifiers, Type returnType, java.lang.String name, Type[] paramTypes, java.lang.String[] declaredExceptions, LazyClassGen enclosingClass)
           
LazyMethodGen(Method m, LazyClassGen enclosingClass)
           
 
Method Summary
 void addAnnotation(AnnotationAJ ax)
           
 void addAttribute(Attribute attribute)
           
 void addExceptionHandler(InstructionHandle start, InstructionHandle end, InstructionHandle handlerStart, ObjectType catchType, boolean highPriority)
           
 void addParameterAnnotation(int parameterNumber, AnnotationAJ anno)
           
 int allocateLocal(int slots)
           
 int allocateLocal(Type type)
           
 void assertGoodBody()
          A good body is a body with the following properties: For each branch instruction S in body, target T of S is in body.
static void assertGoodBody(InstructionList il, java.lang.String from)
           
 void ensureAllLineNumberSetup()
          On entry to this method we have a method whose instruction stream contains a few instructions that have line numbers assigned to them (LineNumberTags).
 void forcePublic()
           
 int getAccessFlags()
           
 int getAccessFlagsWithoutSynchronized()
           
 Type[] getArgumentTypes()
           
 java.util.List<Attribute> getAttributes()
           
 InstructionList getBody()
           
 InstructionList getBodyForPrint()
           
 boolean getCanInline()
           
 java.lang.String getClassName()
           
 ConstantPool getConstantPool()
           
 int getDeclarationLineNumber()
           
 int getDeclarationOffset()
           
 java.lang.String[] getDeclaredExceptions()
           
 AjAttribute.EffectiveSignatureAttribute getEffectiveSignature()
           
 LazyClassGen getEnclosingClass()
           
 java.lang.String getGenericReturnTypeSignature()
           
 int getMaxLocals()
           
 org.aspectj.weaver.bcel.BcelMethod getMemberView()
           
 Method getMethod()
           
 java.lang.String getName()
           
 java.lang.String getParameterSignature()
           
 Type getReturnType()
           
 java.lang.String getSignature()
           
 ISourceLocation getSourceLocation()
           
 boolean hasAnnotation(UnresolvedType annotationType)
           
 boolean hasBody()
           
 boolean hasDeclaredLineNumberInfo()
           
 boolean isAbstract()
           
 boolean isBridgeMethod()
           
static boolean isConstructor(LazyMethodGen aMethod)
           
 boolean isDefault()
           
 boolean isPrivate()
           
 boolean isProtected()
           
 boolean isPublic()
           
 boolean isStatic()
           
 boolean isSynchronized()
           
 void makeSynthetic()
           
 void markAsChanged()
           
 void optimizedPackBody(MethodGen gen)
           
 MethodGen pack()
           
 void packBody(MethodGen gen)
          fill the newly created method gen with our body, inspired by InstructionList.copy()
 void print(AjAttribute.WeaverVersionInfo weaverVersion)
           
 void print(java.io.PrintStream out, AjAttribute.WeaverVersionInfo weaverVersion)
           
 void removeAnnotation(ResolvedType annotationType)
           
 void setAccessFlags(int newFlags)
           
 void setCanInline(boolean canInline)
           
 void setEffectiveSignature(ResolvedMember member, Shadow.Kind kind, boolean shouldWeave)
           
 void setMaxLocals(int maxLocals)
           
 java.lang.String toLongString(AjAttribute.WeaverVersionInfo weaverVersion)
           
 java.lang.String toShortString()
           
 java.lang.String toString()
           
 java.lang.String toTraceString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

definingType

public ResolvedType definingType
Constructor Detail

LazyMethodGen

public LazyMethodGen(int modifiers,
                     Type returnType,
                     java.lang.String name,
                     Type[] paramTypes,
                     java.lang.String[] declaredExceptions,
                     LazyClassGen enclosingClass)

LazyMethodGen

public LazyMethodGen(Method m,
                     LazyClassGen enclosingClass)

LazyMethodGen

public LazyMethodGen(org.aspectj.weaver.bcel.BcelMethod m,
                     LazyClassGen enclosingClass)
Method Detail

hasDeclaredLineNumberInfo

public boolean hasDeclaredLineNumberInfo()

getDeclarationLineNumber

public int getDeclarationLineNumber()

getDeclarationOffset

public int getDeclarationOffset()

addAnnotation

public void addAnnotation(AnnotationAJ ax)

removeAnnotation

public void removeAnnotation(ResolvedType annotationType)

addParameterAnnotation

public void addParameterAnnotation(int parameterNumber,
                                   AnnotationAJ anno)

hasAnnotation

public boolean hasAnnotation(UnresolvedType annotationType)

ensureAllLineNumberSetup

public void ensureAllLineNumberSetup()
On entry to this method we have a method whose instruction stream contains a few instructions that have line numbers assigned to them (LineNumberTags). The aim is to ensure every instruction has the right line number. This is necessary because some of them may be extracted out into other methods - and it'd be useful for them to maintain the source line number for debugging.


allocateLocal

public int allocateLocal(Type type)

allocateLocal

public int allocateLocal(int slots)

getMethod

public Method getMethod()

markAsChanged

public void markAsChanged()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toShortString

public java.lang.String toShortString()

toLongString

public java.lang.String toLongString(AjAttribute.WeaverVersionInfo weaverVersion)

print

public void print(AjAttribute.WeaverVersionInfo weaverVersion)

print

public void print(java.io.PrintStream out,
                  AjAttribute.WeaverVersionInfo weaverVersion)

isStatic

public boolean isStatic()

isAbstract

public boolean isAbstract()

isBridgeMethod

public boolean isBridgeMethod()

addExceptionHandler

public void addExceptionHandler(InstructionHandle start,
                                InstructionHandle end,
                                InstructionHandle handlerStart,
                                ObjectType catchType,
                                boolean highPriority)

getAccessFlags

public int getAccessFlags()

getAccessFlagsWithoutSynchronized

public int getAccessFlagsWithoutSynchronized()

isSynchronized

public boolean isSynchronized()

setAccessFlags

public void setAccessFlags(int newFlags)

getArgumentTypes

public Type[] getArgumentTypes()

getEnclosingClass

public LazyClassGen getEnclosingClass()

getMaxLocals

public int getMaxLocals()

getName

public java.lang.String getName()

getGenericReturnTypeSignature

public java.lang.String getGenericReturnTypeSignature()

getReturnType

public Type getReturnType()

setMaxLocals

public void setMaxLocals(int maxLocals)

getBody

public InstructionList getBody()

getBodyForPrint

public InstructionList getBodyForPrint()

hasBody

public boolean hasBody()

getAttributes

public java.util.List<Attribute> getAttributes()

getDeclaredExceptions

public java.lang.String[] getDeclaredExceptions()

getClassName

public java.lang.String getClassName()

pack

public MethodGen pack()

makeSynthetic

public void makeSynthetic()

packBody

public void packBody(MethodGen gen)
fill the newly created method gen with our body, inspired by InstructionList.copy()


optimizedPackBody

public void optimizedPackBody(MethodGen gen)

isPrivate

public boolean isPrivate()

isProtected

public boolean isProtected()

isDefault

public boolean isDefault()

isPublic

public boolean isPublic()

assertGoodBody

public void assertGoodBody()
A good body is a body with the following properties: Where the shorthand "R is in body" means "R.start is in body, R.end is in body, and any InstructionHandle stored in a field of R (such as an exception handle) is in body".


assertGoodBody

public static void assertGoodBody(InstructionList il,
                                  java.lang.String from)

getSourceLocation

public ISourceLocation getSourceLocation()

getEffectiveSignature

public AjAttribute.EffectiveSignatureAttribute getEffectiveSignature()

setEffectiveSignature

public void setEffectiveSignature(ResolvedMember member,
                                  Shadow.Kind kind,
                                  boolean shouldWeave)

getSignature

public java.lang.String getSignature()

getParameterSignature

public java.lang.String getParameterSignature()

getMemberView

public org.aspectj.weaver.bcel.BcelMethod getMemberView()

forcePublic

public void forcePublic()

getCanInline

public boolean getCanInline()

setCanInline

public void setCanInline(boolean canInline)

addAttribute

public void addAttribute(Attribute attribute)

toTraceString

public java.lang.String toTraceString()
Specified by:
toTraceString in interface Traceable

getConstantPool

public ConstantPool getConstantPool()

isConstructor

public static boolean isConstructor(LazyMethodGen aMethod)