• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java INSTANCEOF类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



INSTANCEOF类属于org.apache.bcel.generic包,在下文中一共展示了INSTANCEOF类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isPEI

import org.apache.bcel.generic.INSTANCEOF; //导入依赖的package包/类
/**
 * Return whether or not the given instruction can throw exceptions.
 *
 * @param handle
 *            the instruction
 * @return true if the instruction can throw an exception, false otherwise
 */
private boolean isPEI(InstructionHandle handle) {
    Instruction ins = handle.getInstruction();

    if (!(ins instanceof ExceptionThrower))
        return false;

    if (ins instanceof NEW)
        return false;
    // if (ins instanceof ATHROW) return false;
    if (ins instanceof GETSTATIC)
        return false;
    if (ins instanceof PUTSTATIC)
        return false;
    if (ins instanceof ReturnInstruction)
        return false;
    if (ins instanceof INSTANCEOF)
        return false;
    if (ins instanceof MONITOREXIT)
        return false;
    if (ins instanceof LDC)
        return false;
    return true;

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:32,代码来源:BetterCFGBuilder2.java


示例2: insertTypecheckCode

import org.apache.bcel.generic.INSTANCEOF; //导入依赖的package包/类
InstructionHandle insertTypecheckCode(MethodGen m, InstructionList il,
    InstructionHandle pos, int spawnId, int exceptionPos) {
    ArrayList<CodeExceptionGen> catches = mtab.getCatchTypes(m, spawnId);

    InstructionHandle[] jumpTargets = new InstructionHandle[catches.size() + 1];

    BranchHandle[] jumps = new BranchHandle[catches.size()];

    for (int i = 0; i < catches.size(); i++) {
        CodeExceptionGen e = catches.get(i);
        ObjectType type = e.getCatchType();
        InstructionHandle catchTarget = e.getHandlerPC();

        jumpTargets[i] = il.insert(pos, new ALOAD(exceptionPos));
        il.insert(pos, new INSTANCEOF(cpg.addClass(type)));
        il.insert(pos, new BIPUSH((byte) 1));
        jumps[i] = il.insert(pos, new IF_ICMPNE(null));
        il.insert(pos, new ALOAD(exceptionPos));
        il.insert(pos, ins_f.createCheckCast(type));
        il.insert(pos, new GOTO(catchTarget));
    }

    InstructionHandle t = il.insert(pos, new ALOAD(exceptionPos));
    il.insert(pos, new ATHROW());

    jumpTargets[catches.size()] = t;

    for (int i = 0; i < catches.size(); i++) {
        jumps[i].setTarget(jumpTargets[i + 1]);
    }

    return pos;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:34,代码来源:Cashmerec.java


示例3: visitINSTANCEOF

import org.apache.bcel.generic.INSTANCEOF; //导入依赖的package包/类
public void visitINSTANCEOF(INSTANCEOF i) {
	Type t = i.getType(poolGen);
	log.log("         instr(instanceof)=" + t, Project.MSG_DEBUG);
	String type = t.toString();

	design.checkClass(type);
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:8,代码来源:InstructionVisitor.java


示例4: injectCommonExceptionCatchBlock

import org.apache.bcel.generic.INSTANCEOF; //导入依赖的package包/类
/**
 * Inject common exception catch blocks
 */
public void injectCommonExceptionCatchBlock(InstructionList il, MethodGen method, int variableIndex) {
    il.append(new INSTANCEOF(constantsPool.addClass(new ObjectType("java.lang.RuntimeException"))));
    BranchInstruction b1 = InstructionFactory.createBranchInstruction(Constants.IFEQ, null);
    il.append(b1);
    il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
    il.append(factory.createCheckCast(new ObjectType("java.lang.RuntimeException")));
    il.append(InstructionConstants.ATHROW);
    InstructionHandle ih1 = il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
    il.append(new INSTANCEOF(constantsPool.addClass(new ObjectType("java.lang.Error"))));
    BranchInstruction b2 = InstructionFactory.createBranchInstruction(Constants.IFEQ, null);
    il.append(b2);
    il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
    il.append(factory.createCheckCast(new ObjectType("java.lang.Error")));
    il.append(InstructionConstants.ATHROW);
    InstructionHandle ih2 = il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
    il.append(factory.createInvoke("java.lang.Throwable", "printStackTrace", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    il.append(factory.createNew("org.codehaus.jremoting.client.InvocationException"));
    il.append(InstructionConstants.DUP);
    il.append(factory.createNew("java.lang.StringBuffer"));
    il.append(InstructionConstants.DUP);
    il.append(new PUSH(constantsPool, "Should never get here: "));
    il.append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
    il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
    il.append(factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    il.append(factory.createInvoke("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[]{Type.STRING}, Constants.INVOKEVIRTUAL));
    il.append(factory.createInvoke("java.lang.StringBuffer", "toString", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    il.append(factory.createInvoke("org.codehaus.jremoting.client.InvocationException", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
    il.append(InstructionConstants.ATHROW);

    b1.setTarget(ih1);
    b2.setTarget(ih2);

}
 
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:37,代码来源:BcelStubGenerator.java


示例5: visitINSTANCEOF

import org.apache.bcel.generic.INSTANCEOF; //导入依赖的package包/类
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
public void visitINSTANCEOF(INSTANCEOF o){
	indexValid(o, o.getIndex());
	Constant c = cpg.getConstant(o.getIndex());
	if (!	(c instanceof ConstantClass)){
		constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
	}
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:9,代码来源:Pass3aVerifier.java


示例6: prescreen

import org.apache.bcel.generic.INSTANCEOF; //导入依赖的package包/类
public boolean prescreen(ClassContext classContext, Method method) {
    BitSet bytecodeSet = classContext.getBytecodeSet(method);
    return bytecodeSet != null && (bytecodeSet.get(Constants.CHECKCAST) || bytecodeSet.get(Constants.INSTANCEOF));
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:5,代码来源:FindBadCast2.java


示例7: visitINSTANCEOF

import org.apache.bcel.generic.INSTANCEOF; //导入依赖的package包/类
public void visitINSTANCEOF( INSTANCEOF i ) {
    Type type = i.getType(_cp);
    _out.println("il.append(new INSTANCEOF(_cp.addClass(" + BCELifier.printType(type) + ")));");
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:5,代码来源:BCELFactory.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FastInfosetSource类代码示例发布时间:2022-05-23
下一篇:
Java XMLParserConfiguration类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap