}
}
- // for testing - if we have this attribute, return it - will return null if
- // it doesnt know anything
- public AjAttribute[] getAttributes(String name) {
- List results = new ArrayList();
- List l = Utility.readAjAttributes(getDeclaringType().getClassName(), method.getAttributes(),
- getSourceContext(bcelObjectType.getWorld()), bcelObjectType.getWorld(), bcelObjectType.getWeaverVersionAttribute());
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- AjAttribute element = (AjAttribute) iter.next();
- if (element.getNameString().equals(name))
- results.add(element);
- }
- if (results.size() > 0) {
- return (AjAttribute[]) results.toArray(new AjAttribute[] {});
- }
- return null;
- }
+ //
+ // // for testing - if we have this attribute, return it - will return null
+ // if
+ // // it doesnt know anything
+ // public AjAttribute[] getAttributes(String name) {
+ // List results = new ArrayList();
+ // List l = Utility.readAjAttributes(getDeclaringType().getClassName(),
+ // method.getAttributes(),
+ // getSourceContext(bcelObjectType.getWorld()), bcelObjectType.getWorld(),
+ // bcelObjectType.getWeaverVersionAttribute());
+ // for (Iterator iter = l.iterator(); iter.hasNext();) {
+ // AjAttribute element = (AjAttribute) iter.next();
+ // if (element.getNameString().equals(name))
+ // results.add(element);
+ // }
+ // if (results.size() > 0) {
+ // return (AjAttribute[]) results.toArray(new AjAttribute[] {});
+ // }
+ // return null;
+ // }
public String getAnnotationDefaultValue() {
Attribute[] attrs = method.getAttributes();
}
/**
- * A method can be parameterized if it has one or more generic parameters. A generic parameter (type variable parameter) is
- * identified by the prefix "T"
+ * A method can be parameterized if it has one or more generic parameters. A
+ * generic parameter (type variable parameter) is identified by the prefix
+ * "T"
*/
public boolean canBeParameterized() {
unpackGenericSignature();
}
/**
- * Return the parameterized/generic return type or the normal return type if the method is not generic.
+ * Return the parameterized/generic return type or the normal return type if
+ * the method is not generic.
*/
public UnresolvedType getGenericReturnType() {
unpackGenericSignature();
}
/**
- * Returns whether or not the given object is equivalent to the current one. Returns true if
- * getMethod().getCode().getCodeString() are equal. Allows for different line number tables.
+ * Returns whether or not the given object is equivalent to the current one.
+ * Returns true if getMethod().getCode().getCodeString() are equal. Allows
+ * for different line number tables.
*/
// bug 154054: is similar to equals(Object) however
// doesn't require implementing equals in Method and Code
package org.aspectj.weaver.bcel;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import org.aspectj.apache.bcel.classfile.ClassParser;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.JavaClass;
-import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.Unknown;
import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValueGen;
import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
}
/*
- * Ensure we report a nice source location - particular in the case where the source info is missing (binary weave).
+ * Ensure we report a nice source location - particular in the case where
+ * the source info is missing (binary weave).
*/
public static String beautifyLocation(ISourceLocation isl) {
StringBuffer nice = new StringBuffer();
.getReturnType()), kind);
}
- /**
- * Creae a field GET instruction
- *
- * @param fact
- * @param signature
- * @param declaringType
- * @return
- */
- public static Instruction createGetOn(InstructionFactory fact, Member signature, UnresolvedType declaringType) {
- short kind;
- if (signature.isStatic()) {
- kind = Constants.GETSTATIC;
- } else {
- kind = Constants.GETFIELD;
- }
-
- return fact.createFieldAccess(declaringType.getName(), signature.getName(), BcelWorld.makeBcelType(signature
- .getReturnType()), kind);
- }
-
public static Instruction createSet(InstructionFactory fact, Member signature) {
short kind;
if (signature.isStatic()) {
.getReturnType()), kind);
}
- public static Instruction createInvoke(InstructionFactory fact, JavaClass declaringClass, Method newMethod) {
- short kind;
- if (newMethod.isInterface()) {
- kind = Constants.INVOKEINTERFACE;
- } else if (newMethod.isStatic()) {
- kind = Constants.INVOKESTATIC;
- } else if (newMethod.isPrivate() || newMethod.getName().equals("<init>")) {
- kind = Constants.INVOKESPECIAL;
- } else {
- kind = Constants.INVOKEVIRTUAL;
- }
-
- String sig = newMethod.getSignature();
- return fact.createInvoke(declaringClass.getClassName(), newMethod.getName(), sig, kind);
- }
-
- public static byte[] stringToUTF(String s) {
- try {
- ByteArrayOutputStream out0 = new ByteArrayOutputStream();
- DataOutputStream out1 = new DataOutputStream(out0);
- out1.writeUTF(s);
- return out0.toByteArray();
- } catch (IOException e) {
- throw new RuntimeException("sanity check");
- }
- }
-
public static Instruction createInstanceof(InstructionFactory fact, ReferenceType t) {
int cpoolEntry = (t instanceof ArrayType) ? fact.getConstantPool().addArrayClass((ArrayType) t) : fact.getConstantPool()
.addClass((ObjectType) t);
}
}
- public static String arrayToString(int[] a) {
- int len = a.length;
- if (len == 0)
- return "[]";
- StringBuffer buf = new StringBuffer("[");
- buf.append(a[0]);
- for (int i = 1; i < len; i++) {
- buf.append(", ");
- buf.append(a[i]);
- }
- buf.append("]");
- return buf.toString();
- }
-
/**
- * replace an instruction handle with another instruction, in this case, a branch instruction.
+ * replace an instruction handle with another instruction, in this case, a
+ * branch instruction.
*
* @param ih the instruction handle to replace.
* @param branchInstruction the branch instruction to replace ih with
}
/**
- * 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.
+ * 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.
*
* @param ih the instruction handle to delete.
* @param enclosingMethod where to find ih's instruction list.
}
/**
- * delete an instruction handle and retarget all targeters of the deleted instruction to the provided target.
+ * delete an instruction handle and retarget all targeters of the deleted
+ * instruction to the provided target.
*
* @param ih the instruction handle to delete
* @param retargetTo the instruction handle to retarget targeters of ih to.
/**
* 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).
+ * 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).
*
* <pre>
* declare error:
}
/**
- * Checks for suppression specified on the member or on the declaring type of that member
+ * Checks for suppression specified on the member or on the declaring type
+ * of that member
*/
public static boolean isSuppressing(Member member, String lintkey) {
boolean isSuppressing = Utils.isSuppressing(member.getAnnotations(), lintkey);