Package org.aspectj.weaver.bcel
Class Utility
java.lang.Object
org.aspectj.weaver.bcel.Utility
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intFor testing purposes: bit clunky but does work -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendConversion(InstructionList il, InstructionFactory fact, ResolvedType fromType, ResolvedType toType) static AttributebcelAttribute(AjAttribute a, ConstantPool pool) static Stringstatic InstructionFix 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 !static InstructioncreateConstant(InstructionFactory fact, int value) static InstructionListcreateConversion(InstructionFactory factory, Type fromType, Type toType) static InstructionListcreateConversion(InstructionFactory fact, Type fromType, Type toType, boolean allowAutoboxing) static InstructioncreateGet(InstructionFactory fact, Member signature) static Instructionstatic InstructioncreateInvoke(InstructionFactory fact, short kind, Member member) Create an invoke instructionstatic InstructioncreateInvoke(InstructionFactory fact, BcelWorld world, Member signature) static InstructioncreateInvoke(InstructionFactory fact, LazyMethodGen m) static InstructioncreateSet(InstructionFactory fact, Member signature) static InstructioncreateSuperInvoke(InstructionFactory fact, BcelWorld world, Member signature) static voiddeleteInstruction(InstructionHandle ih, InstructionHandle retargetTo, LazyMethodGen enclosingMethod) delete an instruction handle and retarget all targeters of the deleted instruction to the provided target.static voiddeleteInstruction(InstructionHandle ih, LazyMethodGen enclosingMethod) delete an instruction handle and retarget all targeters of the deleted instruction to the next instruction.static intreturns -1 if no source line attributegetSuppressedWarnings(AnnotationAJ[] anns, Lint lint) static booleanstatic booleanisSuppressing(Member member, String lintkey) Checks for suppression specified on the member or on the declaring type of that memberstatic String[]makeArgNames(int n) static JavaClassmakeJavaClass(String filename, byte[] bytes) static intmakePublic(int i) static BcelVar[]pushAndReturnArrayOfVars(ResolvedType[] proceedParamTypes, InstructionList il, InstructionFactory fact, LazyMethodGen enclosingMethod) static List<AjAttribute>readAjAttributes(String classname, Attribute[] as, ISourceContext context, World w, AjAttribute.WeaverVersionInfo version, ConstantPoolReader dataDecompressor) static voidreplaceInstruction(InstructionHandle ih, InstructionList replacementInstructions, LazyMethodGen enclosingMethod) replace an instruction handle with another instruction, in this case, a branch instruction.static voidsetSourceLine(InstructionHandle ih, int lineNumber)
-
Field Details
-
testingParseCounter
public static int testingParseCounterFor testing purposes: bit clunky but does work
-
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
readAjAttributes
public static List<AjAttribute> readAjAttributes(String classname, Attribute[] as, ISourceContext context, World w, AjAttribute.WeaverVersionInfo version, ConstantPoolReader dataDecompressor) -
beautifyLocation
-
createSuperInvoke
public static Instruction createSuperInvoke(InstructionFactory fact, BcelWorld world, Member signature) -
createInvoke
-
createGet
-
createSet
-
createInstanceof
-
createInvoke
-
createInvoke
Create an invoke instruction- Parameters:
fact-kind- INVOKEINTERFACE, INVOKEVIRTUAL..member-- Returns:
-
makeArgNames
-
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
-
makeJavaClass
-
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.replacementInstructions- the branch instruction to replace ih withenclosingMethod- where to find ih's instruction list.
-
deleteInstruction
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 deleteretargetTo- the instruction handle to retarget targeters of ih to.enclosingMethod- where to find ih's instruction list.
-
copyInstruction
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
returns -1 if no source line attribute -
setSourceLine
-
makePublic
public static int makePublic(int i) -
pushAndReturnArrayOfVars
public static BcelVar[] pushAndReturnArrayOfVars(ResolvedType[] proceedParamTypes, InstructionList il, InstructionFactory fact, LazyMethodGen enclosingMethod) -
isConstantPushInstruction
-
isSuppressing
Checks for suppression specified on the member or on the declaring type of that member -
getSuppressedWarnings
-
bcelAttribute
-