本文整理汇总了Java中scouter.javassist.bytecode.Bytecode.write16bit方法的典型用法代码示例。如果您正苦于以下问题:Java Bytecode.write16bit方法的具体用法?Java Bytecode.write16bit怎么用?Java Bytecode.write16bit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.javassist.bytecode.Bytecode
的用法示例。
在下文中一共展示了Bytecode.write16bit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFinally
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
/**
* Adds a finally clause for earch return statement.
*/
private void addFinally(ArrayList returnList, Stmnt finallyBlock)
throws CompileError
{
Bytecode bc = bytecode;
int n = returnList.size();
for (int i = 0; i < n; ++i) {
final int[] ret = (int[])returnList.get(i);
int pc = ret[0];
bc.write16bit(pc, bc.currentPc() - pc + 1);
ReturnHook hook = new JsrHook2(this, ret);
finallyBlock.accept(this);
hook.remove(this);
if (!hasReturned) {
bc.addOpcode(Opcode.GOTO);
bc.addIndex(pc + 3 - bc.currentPc());
}
}
}
示例2: atSyncStmnt
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
private void atSyncStmnt(Stmnt st) throws CompileError {
int nbreaks = getListSize(breakList);
int ncontinues = getListSize(continueList);
compileExpr(st.head());
if (exprType != CLASS && arrayDim == 0)
throw new CompileError("bad type expr for synchronized block");
Bytecode bc = bytecode;
final int var = bc.getMaxLocals();
bc.incMaxLocals(1);
bc.addOpcode(DUP);
bc.addAstore(var);
bc.addOpcode(MONITORENTER);
ReturnHook rh = new ReturnHook(this) {
protected boolean doit(Bytecode b, int opcode) {
b.addAload(var);
b.addOpcode(MONITOREXIT);
return false;
}
};
int pc = bc.currentPc();
Stmnt body = (Stmnt)st.tail();
if (body != null)
body.accept(this);
int pc2 = bc.currentPc();
int pc3 = 0;
if (!hasReturned) {
rh.doit(bc, 0); // the 2nd arg is ignored.
bc.addOpcode(Opcode.GOTO);
pc3 = bc.currentPc();
bc.addIndex(0);
}
if (pc < pc2) { // if the body is not empty
int pc4 = bc.currentPc();
rh.doit(bc, 0); // the 2nd arg is ignored.
bc.addOpcode(ATHROW);
bc.addExceptionHandler(pc, pc2, pc4, 0);
}
if (!hasReturned)
bc.write16bit(pc3, bc.currentPc() - pc3 + 1);
rh.remove(this);
if (getListSize(breakList) != nbreaks
|| getListSize(continueList) != ncontinues)
throw new CompileError(
"sorry, cannot break/continue in synchronized block");
}