当前位置: 首页>>代码示例>>Java>>正文


Java InstructionList.size方法代码示例

本文整理汇总了Java中org.apache.bcel.generic.InstructionList.size方法的典型用法代码示例。如果您正苦于以下问题:Java InstructionList.size方法的具体用法?Java InstructionList.size怎么用?Java InstructionList.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.bcel.generic.InstructionList的用法示例。


在下文中一共展示了InstructionList.size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check_reflection

import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
private int check_reflection(MethodGen mgen, ConstantPoolGen cpgen) {
	int cnt = 0;

	InstructionList ilist = mgen.getInstructionList();
	if (ilist == null || ilist.size() == 0)
		return cnt;

	for (Instruction instr : ilist.getInstructions()) {
		// go through all instructions and look for invokes
		if (instr instanceof InvokeInstruction) {
			InvokeInstruction invoke = (InvokeInstruction) instr;
			ReferenceType rtype = invoke.getReferenceType(cpgen);

			if (rtype instanceof ObjectType) {
				String cname = ((ObjectType) rtype).getClassName();
				String mname = invoke.getName(cpgen);

				// we look for exact match
				if (cname.equals("java.lang.reflect.Method") && mname.equals("invoke")) {
					// Util.log(rtype.toString());
					cnt++;
				}
			} else {
				// reference type can be ArrayType or UninitializedObjectType
			}
		}
	}

	return cnt;
}
 
开发者ID:USC-NSL,项目名称:SIF,代码行数:31,代码来源:ClassFileScanner.java

示例2: instrument_reflection

import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
private static Method instrument_reflection(InstructionFactory inf, MethodGen mgen, ConstantPoolGen cpgen) {
	Method ret = mgen.getMethod();

	InstructionList ilist = mgen.getInstructionList();
	if (ilist == null || ilist.size() == 0)
		return ret;

	InstructionHandle[] ihdls = ilist.getInstructionHandles();

	for (InstructionHandle ihdl : ihdls) {
		Instruction instr = ihdl.getInstruction();

		// go through all instructions and look for invokes
		if (instr instanceof InvokeInstruction) {
			InvokeInstruction invoke = (InvokeInstruction) instr;
			ReferenceType rtype = invoke.getReferenceType(cpgen);

			if (rtype instanceof ObjectType) {
				String cname = ((ObjectType) rtype).getClassName();
				String mname = invoke.getName(cpgen);

				// we look for exact match
				if (cname.equals("java.lang.reflect.Method") && mname.equals("invoke")) {
					// Util.log(rtype.toString());
					Type[] arg_types = { new ObjectType(java.lang.reflect.Method.class.getCanonicalName()), Type.OBJECT, new ArrayType(Type.OBJECT, 1) };
					ihdl.setInstruction(inf.createInvoke(SIFAStub.class.getCanonicalName(), "invoke", Type.OBJECT, arg_types, Constants.INVOKESTATIC));
				}
			} else {
				// reference type can be ArrayType or UninitializedObjectType
			}
		}
	}

	ilist.setPositions();

	mgen.setInstructionList(ilist);
	mgen.removeLineNumbers();
	mgen.setMaxStack();
	mgen.setMaxLocals();

	ret = mgen.getMethod();

	return ret;
}
 
开发者ID:USC-NSL,项目名称:SIF,代码行数:45,代码来源:ReflectionHandler.java


注:本文中的org.apache.bcel.generic.InstructionList.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。