use of org.apache.bcel.classfile.Code in project fb-contrib by mebigfatguy.
the class NonRecycleableTaglibs method getAttributes.
/**
* collect all possible attributes given the name of methods available.
*
* @param cls
* the class to look for setter methods to infer properties
* @return the map of possible attributes/types
*/
private static Map<QMethod, String> getAttributes(JavaClass cls) {
Map<QMethod, String> atts = new HashMap<>();
Method[] methods = cls.getMethods();
for (Method m : methods) {
String name = m.getName();
if (name.startsWith("set") && m.isPublic() && !m.isStatic()) {
String sig = m.getSignature();
List<String> args = SignatureUtils.getParameterSignatures(sig);
if ((args.size() == 1) && Values.SIG_VOID.equals(SignatureUtils.getReturnSignature(sig))) {
String parmSig = args.get(0);
if (validAttrTypes.contains(parmSig)) {
Code code = m.getCode();
if ((code != null) && (code.getCode().length < MAX_ATTRIBUTE_CODE_LENGTH)) {
atts.put(new QMethod(name, sig), parmSig);
}
}
}
}
}
return atts;
}
use of org.apache.bcel.classfile.Code in project fb-contrib by mebigfatguy.
the class AbstractOverriddenMethod method visitMethod.
/**
* overrides the visitor to find abstract methods that override concrete ones
*
* @param obj
* the context object of the currently parsed method
*/
@Override
public void visitMethod(Method obj) {
if (!obj.isAbstract())
return;
String methodName = obj.getName();
String methodSig = obj.getSignature();
outer: for (JavaClass cls : superClasses) {
Method[] methods = cls.getMethods();
for (Method m : methods) {
if (m.isPrivate() || m.isAbstract())
continue;
if (methodName.equals(m.getName()) && methodSig.equals(m.getSignature())) {
BugInstance bug = new BugInstance(this, BugType.AOM_ABSTRACT_OVERRIDDEN_METHOD.name(), NORMAL_PRIORITY).addClass(this).addMethod(this);
Code code = obj.getCode();
if (code != null)
bug.addSourceLineRange(clsContext, this, 0, code.getLength() - 1);
bugReporter.reportBug(bug);
break outer;
}
}
}
}
Aggregations