本文整理汇总了Java中org.apache.bcel.generic.ClassGen.containsMethod方法的典型用法代码示例。如果您正苦于以下问题:Java ClassGen.containsMethod方法的具体用法?Java ClassGen.containsMethod怎么用?Java ClassGen.containsMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.generic.ClassGen
的用法示例。
在下文中一共展示了ClassGen.containsMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle_invokestatic
import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private static Set<String> handle_invokestatic(String invoke_cname, String invoke_mname, String invoke_msig, Map<String, ClassGen> map) {
Set<String> ret = new HashSet<String>();
if (!map.containsKey(invoke_cname)) {
return ret;
}
ClassGen invoke_cgen = map.get(invoke_cname);
Method own_mthd = invoke_cgen.containsMethod(invoke_mname, invoke_msig);
if (own_mthd != null && !own_mthd.isAbstract()) {
ret.add(invoke_cname);
} else {
try {
JavaClass[] sup_jclss = invoke_cgen.getJavaClass().getSuperClasses();
for (JavaClass sup_jcls : sup_jclss) {
String sup_cname = sup_jcls.getClassName();
if (!map.containsKey(sup_cname)) {
continue;
}
ClassGen sup_cgen = map.get(sup_cname);
Method sup_mthd = sup_cgen.containsMethod(invoke_mname, invoke_msig);
if (sup_mthd != null && !sup_mthd.isAbstract() && (sup_mthd.isPublic() || sup_mthd.isProtected())) {
ret.add(sup_cgen.getClassName());
break;
}
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
return ret;
}
示例2: generateMethods
import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private static void generateMethods(RootClass k, ConstantPoolGen cp, InstructionList il, InstructionFactory factory, ClassGen cg, String className, Class implementedInterface)
{
RootMember[] members = k.getMembers();
for (int i = 0; i < members.length; i++)
{
Type type = ((BasicMember) members[i]).getJavaType();
Type returnType = type;
try
{
if (implementedInterface != null) returnType = Type.getType(implementedInterface.getMethod(nameMangler.mangleMember(members[i].getName()),(Class[]) null).getReturnType());
if (!returnType.equals(type) && debugRoot)
{
System.err.println("Warning: Interface type mismatch "+implementedInterface.getName()+"."+nameMangler.mangleMember(members[i].getName())+" "+returnType+" "+type);
}
}
catch (NoSuchMethodException x)
{
}
if (cg.containsMethod(nameMangler.mangleMember(members[i].getName()), "()" + returnType.getSignature()) == null)
{
MethodGen mg = new MethodGen(ACC_PUBLIC, returnType, null, null, nameMangler.mangleMember(members[i].getName()), null, il, cp);
if (members[i].getType() == null) // Dummy object
{
il.append(new PUSH(cp, "<<Unreadable>>"));
}
else
{
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createGetField(className, members[i].getName(), type));
}
if (!returnType.equals(type) && !(returnType == Type.INT && (type == Type.BYTE || type == Type.CHAR || type == Type.SHORT)))
il.append(factory.createCast(type,returnType));
il.append(InstructionFactory.createReturn(returnType));
mg.setMaxStack();
mg.setMaxLocals();
cg.addMethod(mg.getMethod());
il.dispose();
}
}
}
示例3: get_invoke_sig
import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private static String get_invoke_sig(InvokeInstruction invoke, ConstantPoolGen cpgen) {
ReferenceType ctype = invoke.getReferenceType(cpgen);
String cname = ctype.toString();
String mname = invoke.getName(cpgen);
Type[] arg_t = invoke.getArgumentTypes(cpgen);
if ((ctype instanceof ObjectType) && !(cname.startsWith("com.google") || cname.startsWith("java") || cname.startsWith("org.") || cname.startsWith("android."))) { // we only care about user-defined class
JavaClass jcls = Util.loadJavaClass(Config.INPUT_DIR + cname.replace('.', '/') + ".class");
ClassGen cgen = new ClassGen(jcls);
String msig = "(";
for (Type t : arg_t) {
msig += t.getSignature();
}
msig += ")" + invoke.getReturnType(cpgen).getSignature();
// Util.log(cname + "." + mname + ":" + msig);
Method mthd = cgen.containsMethod(mname, msig);
// if (mthd == null) {
// Util.log("null");
// } else {
// Util.log(mthd.toString());
// }
// only needed for matching "native"
// if (mthd != null)
// return mthd.toString();
}
String isig = cname + "." + mname + "(";
if (arg_t.length > 0) {
isig += arg_t[0];
for (int i = 1; i < arg_t.length; i++) {
isig += "," + arg_t[i];
}
}
isig += ")";
// Util.log(isig);
return isig;
}
示例4: handle_invokespecial
import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private static Set<String> handle_invokespecial(String invoke_cname, String invoke_mname, String invoke_msig, Map<String, ClassGen> map) {
Set<String> ret = new HashSet<String>();
if (!map.containsKey(invoke_cname)) { // 0. we will lose control anyway
return ret;
}
ClassGen invoke_cgen = map.get(invoke_cname);
if (invoke_mname.equals("<init>")) { // 1. constructor, no doubt
ret.add(invoke_cname);
} else {
Method own_mthd = invoke_cgen.containsMethod(invoke_mname, invoke_msig);
if (own_mthd != null && !own_mthd.isAbstract()) { // 2. must be invoking this.private_method() or super.method() and super has implemented such method
ret.add(invoke_cname);
} else { // 3. must be invoking super.method() and super does not implement such method
try {
JavaClass[] sup_jclss = invoke_cgen.getJavaClass().getSuperClasses();
for (JavaClass sup_jcls : sup_jclss) {
String sup_cname = sup_jcls.getClassName();
Util.log(sup_cname);
if (!map.containsKey(sup_cname)) {
continue;
}
ClassGen sup_cgen = map.get(sup_cname); // new ClassGen(sup_jcls);
Method sup_mthd = sup_cgen.containsMethod(invoke_mname, invoke_msig);
if (sup_mthd != null && !sup_mthd.isAbstract() && (sup_mthd.isPublic() || sup_mthd.isProtected())) {
ret.add(sup_cgen.getClassName());
break;
}
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
// assert (!ret.isEmpty()) : "ERR: Couldn't find any callee";
return ret;
}