本文整理汇总了Java中org.apache.bcel.classfile.Method.getSignature方法的典型用法代码示例。如果您正苦于以下问题:Java Method.getSignature方法的具体用法?Java Method.getSignature怎么用?Java Method.getSignature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.Method
的用法示例。
在下文中一共展示了Method.getSignature方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyze
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
protected String[] analyze(Method method) {
SignatureParser parser = new SignatureParser(method.getSignature());
ArrayList<String> resultList = new ArrayList<String>();
for (Iterator<String> i = parser.parameterSignatureIterator(); i.hasNext();) {
resultList.add(i.next());
}
return resultList.toArray(new String[resultList.size()]);
}
示例2: isSelfCall
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
/**
* Is the given instruction a self-call?
*/
private Method isSelfCall(InvokeInstruction inv) {
ConstantPoolGen cpg = classContext.getConstantPoolGen();
JavaClass jclass = classContext.getJavaClass();
String calledClassName = inv.getClassName(cpg);
// FIXME: is it possible we would see a superclass name here?
// Not a big deal for now, as we are mostly just interested in calls
// to private methods, for which we will definitely see the right
// called class name.
if (!calledClassName.equals(jclass.getClassName()))
return null;
String calledMethodName = inv.getMethodName(cpg);
String calledMethodSignature = inv.getSignature(cpg);
boolean isStaticCall = (inv instanceof INVOKESTATIC);
// Scan methods for one that matches.
Method[] methods = jclass.getMethods();
for (int i = 0; i < methods.length; ++i) {
Method method = methods[i];
String methodName = method.getName();
String signature = method.getSignature();
boolean isStatic = method.isStatic();
if (methodName.equals(calledMethodName) &&
signature.equals(calledMethodSignature) &&
isStatic == isStaticCall) {
// This method looks like a match.
return wantCallsFor(method) ? method : null;
}
}
// Hmm...no matching method found.
// This is almost certainly because the named method
// was inherited from a superclass.
if (DEBUG) System.out.println("No method found for " + calledClassName + "." + calledMethodName + " : " + calledMethodSignature);
return null;
}
示例3: visit
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public void visit(Method obj) {
int accessFlags = obj.getAccessFlags();
if ((accessFlags & ACC_STATIC) != 0) return;
String name = obj.getName();
String sig = obj.getSignature();
if ((accessFlags & ACC_ABSTRACT) != 0) {
if (name.equals("equals")
&& sig.equals("(L" + getClassName() + ";)Z")) {
bugReporter.reportBug(new BugInstance(this, "EQ_ABSTRACT_SELF", LOW_PRIORITY).addClass(getDottedClassName()));
return;
} else if (name.equals("compareTo")
&& sig.equals("(L" + getClassName() + ";)I")) {
bugReporter.reportBug(new BugInstance(this, "CO_ABSTRACT_SELF", LOW_PRIORITY).addClass(getDottedClassName()));
return;
}
}
boolean sigIsObject = sig.equals("(Ljava/lang/Object;)Z");
if (name.equals("hashCode")
&& sig.equals("()I")) {
hasHashCode = true;
if (obj.isAbstract()) hashCodeIsAbstract = true;
// System.out.println("Found hashCode for " + betterClassName);
} else if (name.equals("equals")) {
if (sigIsObject) {
hasEqualsObject = true;
if (obj.isAbstract())
equalsObjectIsAbstract = true;
else {
Code code = obj.getCode();
byte[] codeBytes = code.getCode();
if ((codeBytes.length == 5 &&
(codeBytes[1] & 0xff) == INSTANCEOF)
|| (codeBytes.length == 15 &&
(codeBytes[1] & 0xff) == INSTANCEOF &&
(codeBytes[11] & 0xff) == INVOKESPECIAL)) {
equalsMethodIsInstanceOfEquals = true;
}
}
} else if (sig.equals("(L" + getClassName() + ";)Z"))
hasEqualsSelf = true;
} else if (name.equals("compareTo")) {
if (sig.equals("(Ljava/lang/Object;)I"))
hasCompareToObject = true;
else if (sig.equals("(L" + getClassName() + ";)I"))
hasCompareToSelf = true;
}
}