本文整理匯總了Java中org.apache.bcel.classfile.JavaClass.getMethods方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaClass.getMethods方法的具體用法?Java JavaClass.getMethods怎麽用?Java JavaClass.getMethods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.bcel.classfile.JavaClass
的用法示例。
在下文中一共展示了JavaClass.getMethods方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitClassContext
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
JavaClass javaClass = classContext.getJavaClass();
//The class extends WebChromeClient
boolean isWebChromeClient = InterfaceUtils.isSubtype(javaClass, "android.webkit.WebChromeClient");
//Not the target of this detector
if (!isWebChromeClient) {
return;
}
Method[] methodList = javaClass.getMethods();
for (Method m : methodList) {
if (DEBUG) {
System.out.println(">>> Method: " + m.getName());
}
//The presence of onGeolocationPermissionsShowPrompt is not enforce for the moment
if (!m.getName().equals("onGeolocationPermissionsShowPrompt")) {
continue;
}
//Since the logic implemented need to be analyze by a human, all implementation will be flagged.
bugReporter.reportBug(new BugInstance(this, ANDROID_GEOLOCATION_TYPE, Priorities.NORMAL_PRIORITY) //
.addClassAndMethod(javaClass, m));
}
}
示例2: visitClassContext
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
JavaClass javaClass = classContext.getJavaClass();
for (Method m : javaClass.getMethods()) {
for (AnnotationEntry ae : m.getAnnotationEntries()) {
//Every method mark with @javax.jws.WebMethod is mark as an Endpoint
if (ae.getAnnotationType().equals("Ljavax/jws/WebMethod;")) {
bugReporter.reportBug(new BugInstance(this, JAXWS_ENDPOINT_TYPE, Priorities.LOW_PRIORITY) //
.addClassAndMethod(javaClass, m));
}
}
}
}
示例3: visit
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visit(JavaClass javaClass) {
staticInitializerSeen = false;
Method[] methods = javaClass.getMethods();
for (Method method : methods) {
if (method.getName().equals(STATIC_INITIALIZER_NAME)) {
// check field initialization before visiting methods
doVisitMethod(method);
staticInitializerSeen = true;
break;
}
}
isFirstArrayStore = false;
wasToConstArrayConversion = false;
}
示例4: visitClassContext
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void visitClassContext(ClassContext classContext) {
JavaClass jclass = classContext.getJavaClass();
Method[] methodList = jclass.getMethods();
for (int i = 0; i < methodList.length; ++i) {
Method method = methodList[i];
if (method.getCode() == null)
continue;
analyzeMethod(classContext, method);
}
}
示例5: visitClassContext
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
JavaClass javaClass = classContext.getJavaClass();
method : for (Method m : javaClass.getMethods()) {
for (AnnotationEntry ae : m.getAnnotationEntries()) {
if (REQUEST_MAPPING_ANNOTATION_TYPES.contains(ae.getAnnotationType())) {
bugReporter.reportBug(new BugInstance(this, SPRING_ENDPOINT_TYPE, Priorities.LOW_PRIORITY) //
.addClassAndMethod(javaClass, m));
continue method;
}
}
}
}
示例6: findMethod
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
Method findMethod(JavaClass clazz, String name, String sig) {
Method[] m = clazz.getMethods();
for (int i = 0; i < m.length; i++)
if (m[i].getName().equals(name)
&& m[i].getSignature().equals(sig))
return m[i];
return null;
}
示例7: visitClassContext
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
JavaClass javaClass = classContext.getJavaClass();
for (Method m : javaClass.getMethods()) {
for (AnnotationEntry ae : m.getAnnotationEntries()) {
//Every method mark with @javax.ws.rs.Path is mark as an Endpoint
if (ae.getAnnotationType().equals("Ljavax/ws/rs/Path;")) {
bugReporter.reportBug(new BugInstance(this, JAXRS_ENDPOINT_TYPE, Priorities.LOW_PRIORITY) //
.addClassAndMethod(javaClass, m));
}
}
}
}
示例8: findMethod
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
* Find a method in given class.
*
* @param javaClass the class
* @param methodName the name of the method
* @param methodSig the signature of the method
* @return the Method, or null if no such method exists in the class
*/
public static Method findMethod(JavaClass javaClass, String methodName, String methodSig) {
Method[] methodList = javaClass.getMethods();
for (int i = 0; i < methodList.length; ++i) {
Method method = methodList[i];
if (method.getName().equals(methodName) && method.getSignature().equals(methodSig))
return method;
}
return null;
}
示例9: main
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
* Test driver.
*/
public static void main(String[] argv) throws Exception {
if (argv.length != 1) {
System.err.println("Usage: " + BetterCFGBuilder2.class.getName() + " <class file>");
System.exit(1);
}
String methodName = System.getProperty("cfgbuilder.method");
JavaClass jclass = new ClassParser(argv[0]).parse();
ClassGen classGen = new ClassGen(jclass);
Method[] methodList = jclass.getMethods();
for (int i = 0; i < methodList.length; ++i) {
Method method = methodList[i];
if (method.isAbstract() || method.isNative())
continue;
if (methodName != null && !method.getName().equals(methodName))
continue;
MethodGen methodGen = new MethodGen(method, jclass.getClassName(), classGen.getConstantPool());
CFGBuilder cfgBuilder = new BetterCFGBuilder2(methodGen);
cfgBuilder.build();
CFG cfg = cfgBuilder.getCFG();
CFGPrinter cfgPrinter = new CFGPrinter(cfg);
System.out.println("---------------------------------------------------------------------");
System.out.println("Method: " + SignatureConverter.convertMethodSignature(methodGen));
System.out.println("---------------------------------------------------------------------");
cfgPrinter.print(System.out);
}
}
示例10: visitClassContext
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
JavaClass javaClass = classContext.getJavaClass();
Method[] methodList = javaClass.getMethods();
for (Method m : methodList) {
try {
analyzeMethod(m, classContext);
} catch (CFGBuilderException | DataflowAnalysisException e) {
AnalysisContext.logError("Cannot analyze method", e);
}
}
}
示例11: JavaClassDefinition
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
* Creates a JavaClassDefinition from a JavaClass. The fields and
* methods of the JavaClassDefinition are those whose scopes are
* in restricted sets of Scopes.
* @param aJavaClass the JavaClass for the definition.
* @param aFieldScopes the restricted set of field scopes.
* @param aMethodScopes the restriced set of method scopes.
*/
public JavaClassDefinition(
JavaClass aJavaClass,
Set aFieldScopes,
Set aMethodScopes)
{
mJavaClass = aJavaClass;
// create method definitions, restricted by scope
final Method[] methods = aJavaClass.getMethods();
final Set methodSet = new HashSet();
mMethodDefs = new MethodDefinition[methods.length];
for (int i = 0; i < methods.length; i++) {
if (Utils.inScope(methods[i], aMethodScopes)) {
methodSet.add(new MethodDefinition(methods[i]));
}
}
mMethodDefs =
(MethodDefinition[]) methodSet.toArray(
new MethodDefinition[methodSet.size()]);
// create field definitions, restricted by scope
final Field[] fields = aJavaClass.getFields();
mFieldDefs = new HashMap(fields.length);
for (int i = 0; i < fields.length; i++) {
if (Utils.inScope(fields[i], aFieldScopes)) {
mFieldDefs.put(
fields[i].getName(),
new FieldDefinition(fields[i]));
}
}
}
示例12: visitClassContext
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
JavaClass clazz = classContext.getJavaClass();
if (hasRequestMapping(clazz)) {
Method[] methods = clazz.getMethods();
for (Method m: methods) {
try {
analyzeMethod(m, classContext);
} catch (CFGBuilderException e){
}
}
}
}
示例13: hasRequestMapping
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
private boolean hasRequestMapping(JavaClass clazz) {
Method[] methods = clazz.getMethods();
for (Method m: methods) {
AnnotationEntry[] annotations = m.getAnnotationEntries();
for (AnnotationEntry ae: annotations) {
if (REQUEST_MAPPING_ANNOTATION_TYPES.contains(ae.getAnnotationType())) {
return true;
}
}
}
return false;
}
示例14: visitClassContext
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
JavaClass javaClass = classContext.getJavaClass();
boolean isActionForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.action.ActionForm");
boolean isValidatorForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.validator.ValidatorForm");
boolean isDynaValidatorForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.validator.DynaValidatorForm");
if (isActionForm && !(isValidatorForm || isDynaValidatorForm)) {
bugReporter.reportBug(new BugInstance(this, STRUTS_FORM_VALIDATION_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(javaClass) //
.addString("ActionForm"));
return;
}
if (!isValidatorForm && !isDynaValidatorForm) return; //Not form implementation
final String expectedSig = "(Lorg/apache/struts/action/ActionMapping;Ljavax/servlet/http/HttpServletRequest;)Lorg/apache/struts/action/ActionErrors;";
boolean validateMethodFound = false;
for (Method m : javaClass.getMethods()) {
if ("validate".equals(m.getName()) && expectedSig.equals(m.getSignature())) {
validateMethodFound = true;
}
}
//ValidatorForm without a validate method is just like a regular ActionForm
if (!validateMethodFound) {
bugReporter.reportBug(new BugInstance(this, STRUTS_FORM_VALIDATION_TYPE, Priorities.LOW_PRIORITY) //
.addClass(javaClass) //
.addString("ValidatorForm"));
}
}
示例15: visitClassContext
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
JavaClass javaClass = classContext.getJavaClass();
Method[] methodList = javaClass.getMethods();
for (Method m : methodList) {
try {
analyzeMethod(m,classContext);
} catch (CFGBuilderException e) {
}
}
}