Java Utililty Methods Aspectj Usage

List of utility methods to do Aspectj Usage

Description

The list of methods to do Aspectj Usage are organized into topic(s).

Method

StringaccessToString(int access_flags, boolean for_class)
Convert bit field of flags into string such as 'static final'.
StringBuffer buf = new StringBuffer();
int p = 0;
for (int i = 0; p < Constants.MAX_ACC_FLAG; i++) { 
    p = pow2(i);
    if ((access_flags & p) != 0) {
        if (for_class && ((p == Constants.ACC_SUPER) || (p == Constants.ACC_INTERFACE))) {
            continue;
        buf.append(Constants.ACCESS_NAMES[i]).append(" ");
return buf.toString().trim();
ListarrayAsList(Object[] ra)
array As List
return org.aspectj.util.LangUtil.arrayAsList(ra);
StringclassOrInterface(int access_flags)
class Or Interface
return ((access_flags & Constants.ACC_INTERFACE) != 0) ? "interface" : "class";
IterablecollectArguments(JoinPoint jp)
collect Arguments
List<Object> result = new ArrayList<>();
for (Object arg : jp.getArgs()) {
    if (arg instanceof Collection) {
        result.addAll((Collection) arg);
    } else {
        result.add(arg);
return result;
String[]combine(String[] one, String[] two)
combine two string arrays, removing null and duplicates
ArrayList twoList = new ArrayList();
twoList.addAll(org.aspectj.util.LangUtil.arrayAsList(two));
ArrayList result = new ArrayList();
if (null != one) {
    for (int i = 0; i < one.length; i++) {
        if (null != one[i]) {
            twoList.remove(one[i]);
            result.add(one[i]);
...
StringconvertToFile(String path)
convert To File
String fixedFile = path;
if (TARGET_PRODUCT_NAME.equals("ZXing")) {
    String splitter = "/src/";
    fixedFile = path.substring(path.indexOf(splitter) + splitter.length());
    fixedFile = fixedFile.replace('/', '.');
} else if (TARGET_PRODUCT_NAME.equals("SWT")) {
    String splitter = "/org/eclipse/";
    fixedFile = path.substring(path.indexOf(splitter) + 1);
...
InstructioncopyInstruction(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 !
if (i instanceof InstructionSelect) {
    InstructionSelect freshSelect = (InstructionSelect) i;
    InstructionHandle[] targets = new InstructionHandle[freshSelect.getTargets().length];
    for (int ii = 0; ii < targets.length; ii++) {
        targets[ii] = freshSelect.getTargets()[ii];
    return new SwitchBuilder(freshSelect.getMatchs(), targets, freshSelect.getTarget()).getInstruction();
} else {
...
InstructioncreateConstant(InstructionFactory fact, int value)
create Constant
Instruction inst;
switch (value) {
case -1:
    inst = InstructionConstants.ICONST_M1;
    break;
case 0:
    inst = InstructionConstants.ICONST_0;
    break;
...
InstructioncreateInstanceof(InstructionFactory fact, ReferenceType t)
create Instanceof
int cpoolEntry = (t instanceof ArrayType) ? fact.getConstantPool().addArrayClass((ArrayType) t)
        : fact.getConstantPool().addClass((ObjectType) t);
return new InstructionCP(Constants.INSTANCEOF, cpoolEntry);
StringgenPointcutDetails(Pointcut pcd)
Generates the pointcut details for the given pointcut, for example an anonymous pointcut will return '' and a named pointcut called p() will return 'p()..'
StringBuffer details = new StringBuffer();
if (pcd instanceof ReferencePointcut) {
    ReferencePointcut rp = (ReferencePointcut) pcd;
    details.append(rp.name).append(DOUBLE_DOTS);
} else if (pcd instanceof AndPointcut) {
    AndPointcut ap = (AndPointcut) pcd;
    if (ap.getLeft() instanceof ReferencePointcut) {
        details.append(ap.getLeft().toString()).append(DOUBLE_DOTS);
...