org.aspectj.weaver.bcel
Class Utility

java.lang.Object
  extended by org.aspectj.weaver.bcel.Utility

public class Utility
extends java.lang.Object


Field Summary
static int testingParseCounter
          For testing purposes: bit clunky but does work
 
Constructor Summary
Utility()
           
 
Method Summary
static void appendConversion(InstructionList il, InstructionFactory fact, ResolvedType fromType, ResolvedType toType)
           
static Attribute bcelAttribute(AjAttribute a, ConstantPool pool)
           
static java.lang.String beautifyLocation(ISourceLocation isl)
           
static Instruction copyInstruction(Instruction i)
          Fix for Bugzilla #39479, #40109 patch contributed by Andy Clement Need to manually copy Select instructions - if we rely on the the 'fresh' object created by copy(), the InstructionHandle array 'targets' inside the Select object will not have been deep copied, so modifying targets in fresh will modify the original Select - not what we want ! (It is a bug in BCEL to do with cloning Select objects).
static Instruction createConstant(InstructionFactory fact, int value)
           
static InstructionList createConversion(InstructionFactory factory, Type fromType, Type toType)
           
static InstructionList createConversion(InstructionFactory fact, Type fromType, Type toType, boolean allowAutoboxing)
           
static Instruction createGet(InstructionFactory fact, Member signature)
           
static Instruction createInstanceof(InstructionFactory fact, ReferenceType t)
           
static Instruction createInvoke(InstructionFactory fact, BcelWorld world, Member signature)
           
static Instruction createInvoke(InstructionFactory fact, LazyMethodGen m)
           
static Instruction createInvoke(InstructionFactory fact, short kind, Member member)
          Create an invoke instruction
static Instruction createSet(InstructionFactory fact, Member signature)
           
static Instruction createSuperInvoke(InstructionFactory fact, BcelWorld world, Member signature)
           
static void deleteInstruction(InstructionHandle ih, InstructionHandle retargetTo, LazyMethodGen enclosingMethod)
          delete an instruction handle and retarget all targeters of the deleted instruction to the provided target.
static void deleteInstruction(InstructionHandle ih, LazyMethodGen enclosingMethod)
          delete an instruction handle and retarget all targeters of the deleted instruction to the next instruction.
static int getSourceLine(InstructionHandle ih)
          returns -1 if no source line attribute
static java.util.List<Lint.Kind> getSuppressedWarnings(AnnotationAJ[] anns, Lint lint)
           
static boolean isConstantPushInstruction(Instruction i)
           
static boolean isSuppressing(Member member, java.lang.String lintkey)
          Checks for suppression specified on the member or on the declaring type of that member
static java.lang.String[] makeArgNames(int n)
           
static JavaClass makeJavaClass(java.lang.String filename, byte[] bytes)
           
static int makePublic(int i)
           
static BcelVar[] pushAndReturnArrayOfVars(ResolvedType[] proceedParamTypes, InstructionList il, InstructionFactory fact, LazyMethodGen enclosingMethod)
           
static java.util.List<AjAttribute> readAjAttributes(java.lang.String classname, Attribute[] as, ISourceContext context, World w, AjAttribute.WeaverVersionInfo version, ConstantPoolReader dataDecompressor)
           
static void replaceInstruction(InstructionHandle ih, InstructionList replacementInstructions, LazyMethodGen enclosingMethod)
          replace an instruction handle with another instruction, in this case, a branch instruction.
static void setSourceLine(InstructionHandle ih, int lineNumber)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

testingParseCounter

public static int testingParseCounter
For testing purposes: bit clunky but does work

Constructor Detail

Utility

public Utility()
Method Detail

readAjAttributes

public static java.util.List<AjAttribute> readAjAttributes(java.lang.String classname,
                                                           Attribute[] as,
                                                           ISourceContext context,
                                                           World w,
                                                           AjAttribute.WeaverVersionInfo version,
                                                           ConstantPoolReader dataDecompressor)

beautifyLocation

public static java.lang.String beautifyLocation(ISourceLocation isl)

createSuperInvoke

public static Instruction createSuperInvoke(InstructionFactory fact,
                                            BcelWorld world,
                                            Member signature)

createInvoke

public static Instruction createInvoke(InstructionFactory fact,
                                       BcelWorld world,
                                       Member signature)

createGet

public static Instruction createGet(InstructionFactory fact,
                                    Member signature)

createSet

public static Instruction createSet(InstructionFactory fact,
                                    Member signature)

createInstanceof

public static Instruction createInstanceof(InstructionFactory fact,
                                           ReferenceType t)

createInvoke

public static Instruction createInvoke(InstructionFactory fact,
                                       LazyMethodGen m)

createInvoke

public static Instruction createInvoke(InstructionFactory fact,
                                       short kind,
                                       Member member)
Create an invoke instruction

Parameters:
fact -
kind - INVOKEINTERFACE, INVOKEVIRTUAL..
member -
Returns:

makeArgNames

public static java.lang.String[] makeArgNames(int n)

appendConversion

public static void appendConversion(InstructionList il,
                                    InstructionFactory fact,
                                    ResolvedType fromType,
                                    ResolvedType toType)

createConversion

public static InstructionList createConversion(InstructionFactory factory,
                                               Type fromType,
                                               Type toType)

createConversion

public static InstructionList createConversion(InstructionFactory fact,
                                               Type fromType,
                                               Type toType,
                                               boolean allowAutoboxing)

createConstant

public static Instruction createConstant(InstructionFactory fact,
                                         int value)

makeJavaClass

public static JavaClass makeJavaClass(java.lang.String filename,
                                      byte[] bytes)

replaceInstruction

public static void replaceInstruction(InstructionHandle ih,
                                      InstructionList replacementInstructions,
                                      LazyMethodGen enclosingMethod)
replace an instruction handle with another instruction, in this case, a branch instruction.

Parameters:
ih - the instruction handle to replace.
branchInstruction - the branch instruction to replace ih with
enclosingMethod - where to find ih's instruction list.

deleteInstruction

public static void deleteInstruction(InstructionHandle ih,
                                     LazyMethodGen enclosingMethod)
delete an instruction handle and retarget all targeters of the deleted instruction to the next instruction. Obviously, this should not be used to delete a control transfer instruction unless you know what you're doing.

Parameters:
ih - the instruction handle to delete.
enclosingMethod - where to find ih's instruction list.

deleteInstruction

public static void deleteInstruction(InstructionHandle ih,
                                     InstructionHandle retargetTo,
                                     LazyMethodGen enclosingMethod)
delete an instruction handle and retarget all targeters of the deleted instruction to the provided target.

Parameters:
ih - the instruction handle to delete
retargetTo - the instruction handle to retarget targeters of ih to.
enclosingMethod - where to find ih's instruction list.

copyInstruction

public static Instruction copyInstruction(Instruction i)
Fix for Bugzilla #39479, #40109 patch contributed by Andy Clement Need to manually copy Select instructions - if we rely on the the 'fresh' object created by copy(), the InstructionHandle array 'targets' inside the Select object will not have been deep copied, so modifying targets in fresh will modify the original Select - not what we want ! (It is a bug in BCEL to do with cloning Select objects).
 declare error:
     call(* Instruction.copy()) && within(org.aspectj.weaver)
       && !withincode(* Utility.copyInstruction(Instruction)):
     "use Utility.copyInstruction to work-around bug in Select.copy()";
 


getSourceLine

public static int getSourceLine(InstructionHandle ih)
returns -1 if no source line attribute


setSourceLine

public static void setSourceLine(InstructionHandle ih,
                                 int lineNumber)

makePublic

public static int makePublic(int i)

pushAndReturnArrayOfVars

public static BcelVar[] pushAndReturnArrayOfVars(ResolvedType[] proceedParamTypes,
                                                 InstructionList il,
                                                 InstructionFactory fact,
                                                 LazyMethodGen enclosingMethod)

isConstantPushInstruction

public static boolean isConstantPushInstruction(Instruction i)

isSuppressing

public static boolean isSuppressing(Member member,
                                    java.lang.String lintkey)
Checks for suppression specified on the member or on the declaring type of that member


getSuppressedWarnings

public static java.util.List<Lint.Kind> getSuppressedWarnings(AnnotationAJ[] anns,
                                                              Lint lint)

bcelAttribute

public static Attribute bcelAttribute(AjAttribute a,
                                      ConstantPool pool)