本文整理汇总了Java中org.apache.bcel.classfile.Method.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Method.getName方法的具体用法?Java Method.getName怎么用?Java Method.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.Method
的用法示例。
在下文中一共展示了Method.getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public void visit(Method obj) {
if (!validClass)
return;
validMethod = false;
methodName = obj.getName();
if (methodName.equals("setUp") || methodName.equals("tearDown")) {
if (methodName.equals("setUp"))
setUpAnnotation = MethodAnnotation.fromVisitedMethod(this);
else if (methodName.equals("tearDown"))
tearDownAnnotation = MethodAnnotation.fromVisitedMethod(this);
validMethod = true;
state = SEEN_NOTHING;
super.visit(obj);
} else if (methodName.equals("suite") && !obj.isStatic())
bugReporter.reportBug(new BugInstance(this, "IJU_SUITE_NOT_STATIC", NORMAL_PRIORITY)
.addClass(this)
.addMethod(MethodAnnotation.fromVisitedMethod(this)));
}
示例2: visit
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public void visit(Method obj) {
if (isAdapter) {
String methodName = obj.getName();
String signature = methodMap.get(methodName);
if (!methodName.equals("<init>") && signature != null) {
if (!signature.equals(obj.getSignature())) {
if (!badOverrideMap.keySet().contains(methodName)) {
badOverrideMap.put(methodName, new BugInstance(this, "BOA_BADLY_OVERRIDDEN_ADAPTER", NORMAL_PRIORITY)
.addClassAndMethod(this)
.addSourceLine(this));
}
}
else {
badOverrideMap.put(methodName, null);
}
}
}
}
示例3: visit
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public void visit(Method obj) {
int flags = obj.getAccessFlags();
if ((flags & doNotConsider) != 0) return;
String name = obj.getName();
boolean isSynchronized = (flags & ACC_SYNCHRONIZED) != 0;
/*
String sig = obj.getSignature();
char firstArg = sig.charAt(1);
char returnValue = sig.charAt(1 + sig.indexOf(')'));
boolean firstArgIsRef = (firstArg == 'L') || (firstArg == '[');
boolean returnValueIsRef = (returnValue == 'L') || (returnValue == '[');
System.out.println(className + "." + name
+ " " + firstArgIsRef
+ " " + returnValueIsRef
+ " " + isSynchronized
+ " " + isNative
);
*/
if (name.startsWith("get")
&& !isSynchronized
// && returnValueIsRef
) {
getMethods.put(name.substring(3), MethodAnnotation.fromVisitedMethod(this));
} else if (name.startsWith("set")
&& isSynchronized
// && firstArgIsRef
) {
setMethods.put(name.substring(3), MethodAnnotation.fromVisitedMethod(this));
}
}
示例4: ignore
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
/** @see AbstractReferenceCheck */
public boolean ignore(String aClassName, Method aMethod) {
final String methodName = aMethod.getName();
return (/*super.ignore(aClassName, aMethod)
|| */methodName.equals("<init>")
|| methodName.equals("<clinit>")
|| methodName.equals("class$")
|| aMethod.toString().indexOf("[Synthetic]") > -1);
}
示例5: ignore
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
/** @see AbstractReferenceCheck */
public boolean ignore(String aClassName, Method aMethod)
{
final String methodName = aMethod.getName();
return (super.ignore(aClassName, aMethod)
|| methodName.equals("<init>")
|| methodName.equals("<clinit>"));
}
示例6: 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;
}
示例7: 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;
}
}