Top Fields Constructors Methods
org.aspectj.weaver.bcel

public Class Utility

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, java.lang.reflect.Modifier, java.util.ArrayList, .Collections, .Hashtable, .List, org.aspectj.apache.bcel.Constants, org.aspectj.apache.bcel.classfile.Attribute, .ClassParser, .ConstantPool, .JavaClass, .Unknown, org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue, .ElementValue, .NameValuePair, .SimpleElementValue, org.aspectj.apache.bcel.generic.ArrayType, .BasicType, .Instruction, .InstructionByte, .InstructionCP, .InstructionConstants, .InstructionFactory, .InstructionHandle, .InstructionList, .InstructionSelect, .InstructionShort, .InstructionTargeter, .LineNumberTag, .ObjectType, .ReferenceType, .SwitchBuilder, .TargetLostException, .Type, org.aspectj.bridge.ISourceLocation, org.aspectj.weaver.AjAttribute, .AjAttribute.WeaverVersionInfo, .AnnotationAJ, .BCException, .ConstantPoolReader, .ISourceContext, .Lint, .Member, .ResolvedType, .UnresolvedType, .Utils, .World

Field Summary

Modifier and TypeField and Description
private static String[]
private static final char
public static int
testingParseCounter

For testing purposes: bit clunky but does work

private static Hashtable<String, String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
public static Attribute
public static String
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 !

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

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

public static Instruction
public static Instruction
public static Instruction
public static Instruction
public static Instruction
createInvoke(InstructionFactory fact, short
INVOKEINTERFACE, INVOKEVIRTUAL..
kind
,
Member member)

Create an invoke instruction

public static Instruction
public static Instruction
public static void
deleteInstruction(InstructionHandle
the instruction handle to delete.
ih
,
LazyMethodGen
where to find ih's instruction list.
enclosingMethod
)

delete an instruction handle and retarget all targeters of the deleted instruction to the next instruction.

public static void
deleteInstruction(InstructionHandle
the instruction handle to delete
ih
,
InstructionHandle
the instruction handle to retarget targeters of ih to.
retargetTo
,
LazyMethodGen
where to find ih's instruction list.
enclosingMethod
)

delete an instruction handle and retarget all targeters of the deleted instruction to the provided target.

public static int
getSourceLine(InstructionHandle ih)

returns -1 if no source line attribute

public static List<Lint.Kind>
public static boolean
public static boolean
isSuppressing(Member member, String lintkey)

Checks for suppression specified on the member or on the declaring type of that member

public static String[]
makeArgNames(int n)

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

public static int
makePublic(int i)

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

public static void
replaceInstruction(InstructionHandle
the instruction handle to replace.
ih
,
InstructionList
the branch instruction to replace ih with
replacementInstructions
,
LazyMethodGen
where to find ih's instruction list.
enclosingMethod
)

replace an instruction handle with another instruction, in this case, a branch instruction.

public static void
setSourceLine(InstructionHandle ih, int lineNumber)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argNamesback to summary
private static String[] argNames
PACKAGE_INITIAL_CHARback to summary
private static final char PACKAGE_INITIAL_CHAR
testingParseCounterback to summary
public static int testingParseCounter

For testing purposes: bit clunky but does work

validBoxingback to summary
private static Hashtable<String, String> validBoxing

Constructor Detail

Utilityback to summary
public Utility()

Method Detail

appendConversionback to summary
public static void appendConversion(InstructionList il, InstructionFactory fact, ResolvedType fromType, ResolvedType toType)
bcelAttributeback to summary
public static Attribute bcelAttribute(AjAttribute a, ConstantPool pool)
beautifyLocationback to summary
public static String beautifyLocation(ISourceLocation isl)
copyInstructionback to summary
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()";
createConstantback to summary
public static Instruction createConstant(InstructionFactory fact, int value)
createConversionback to summary
public static InstructionList createConversion(InstructionFactory factory, Type fromType, Type toType)
createConversionback to summary
public static InstructionList createConversion(InstructionFactory fact, Type fromType, Type toType, boolean allowAutoboxing)
createGetback to summary
public static Instruction createGet(InstructionFactory fact, Member signature)
createInstanceofback to summary
public static Instruction createInstanceof(InstructionFactory fact, ReferenceType t)
createInvokeback to summary
public static Instruction createInvoke(InstructionFactory fact, BcelWorld world, Member signature)
createInvokeback to summary
public static Instruction createInvoke(InstructionFactory fact, LazyMethodGen m)
createInvokeback to summary
public static Instruction createInvoke(InstructionFactory fact, short kind, Member member)

Create an invoke instruction

Parameters
kind:short

INVOKEINTERFACE, INVOKEVIRTUAL..

createSetback to summary
public static Instruction createSet(InstructionFactory fact, Member signature)
createSuperInvokeback to summary
public static Instruction createSuperInvoke(InstructionFactory fact, BcelWorld world, Member signature)
deleteInstructionback to summary
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:InstructionHandle

the instruction handle to delete.

enclosingMethod:LazyMethodGen

where to find ih's instruction list.

deleteInstructionback to summary
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:InstructionHandle

the instruction handle to delete

retargetTo:InstructionHandle

the instruction handle to retarget targeters of ih to.

enclosingMethod:LazyMethodGen

where to find ih's instruction list.

getSourceLineback to summary
public static int getSourceLine(InstructionHandle ih)

returns -1 if no source line attribute

getSuppressedWarningsback to summary
public static List<Lint.Kind> getSuppressedWarnings(AnnotationAJ[] anns, Lint lint)
isConstantPushInstructionback to summary
public static boolean isConstantPushInstruction(Instruction i)
isSuppressingback to summary
public static boolean isSuppressing(Member member, String lintkey)

Checks for suppression specified on the member or on the declaring type of that member

makeArgNamesback to summary
public static String[] makeArgNames(int n)
makeJavaClassback to summary
public static JavaClass makeJavaClass(String filename, byte[] bytes)
makePublicback to summary
public static int makePublic(int i)
pushAndReturnArrayOfVarsback to summary
public static BcelVar[] pushAndReturnArrayOfVars(ResolvedType[] proceedParamTypes, InstructionList il, InstructionFactory fact, LazyMethodGen enclosingMethod)
readAjAttributesback to summary
public static List<AjAttribute> readAjAttributes(String classname, Attribute[] as, ISourceContext context, World w, AjAttribute.WeaverVersionInfo version, ConstantPoolReader dataDecompressor)
replaceInstructionback to summary
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:InstructionHandle

the instruction handle to replace.

replacementInstructions:InstructionList

the branch instruction to replace ih with

enclosingMethod:LazyMethodGen

where to find ih's instruction list.

setSourceLineback to summary
public static void setSourceLine(InstructionHandle ih, int lineNumber)