本文整理汇总了Java中org.objectweb.asm.Opcodes.ATHROW属性的典型用法代码示例。如果您正苦于以下问题:Java Opcodes.ATHROW属性的具体用法?Java Opcodes.ATHROW怎么用?Java Opcodes.ATHROW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.objectweb.asm.Opcodes
的用法示例。
在下文中一共展示了Opcodes.ATHROW属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hookMethod
/**
* (none-javadoc)
*
* @see AbstractClassHook#hookMethod(int, String, String, String, String[], MethodVisitor)
*/
@Override
public MethodVisitor hookMethod(int access, String name, String desc, String signature, String[] exceptions, MethodVisitor mv) {
if (name.equals("targetUrl")) {
return new AdviceAdapter(Opcodes.ASM5, mv, access, name, desc) {
@Override
protected void onMethodExit(int opcode) {
if (opcode != Opcodes.ATHROW) {
mv.visitInsn(Opcodes.DUP);
invokeStatic(Type.getType(JstlImportHook.class),
new Method("checkJstlImport", "(Ljava/lang/String;)V"));
}
}
};
}
return mv;
}
示例2: insert
private void insert() {
InsnList trInsns = transformerNode.instructions;
AbstractInsnNode node = trInsns.getLast();
while (true) {
if (node == null)
break;
if (node instanceof LabelNode) {
node = node.getPrevious();
continue;
} else if (node.getOpcode() == Opcodes.RETURN) {
trInsns.remove(node);
} else if (node.getOpcode() == Opcodes.ATHROW && node.getPrevious().getOpcode() == Opcodes.ACONST_NULL) {
AbstractInsnNode prev = node.getPrevious();
trInsns.remove(node);
trInsns.remove(prev);
}
break;
}
resultNode.instructions.insert(trInsns);
}
示例3: addDirectExits
private static void addDirectExits(InsnList il, BitSet entryPoints, Map<AbstractInsnNode, int[]> exitPoints) {
int idx = 0; // ignore 0 since it has no preceding instruction
while ((idx = entryPoints.nextSetBit(idx + 1)) != -1) {
AbstractInsnNode prev = il.get(idx - 1);
if (exitPoints.containsKey(prev)) continue;
int type = prev.getType();
if (prev.getOpcode() != Opcodes.ATHROW
&& (prev.getOpcode() < Opcodes.IRETURN || prev.getOpcode() > Opcodes.RETURN)
&& type != AbstractInsnNode.JUMP_INSN
&& type != AbstractInsnNode.TABLESWITCH_INSN
&& type != AbstractInsnNode.LOOKUPSWITCH_INSN) {
exitPoints.put(prev, new int[] { idx });
}
}
}
示例4: visitEnd
public void visitEnd() {
if (isSynchronized()) {
has_monitor_operation = true;
done = true;
Label methodEndLabel = super.mark();
if (exceptions!=null) {
for(String ex: exceptions) {
super.catchException(methodStartLabel,methodEndLabel,Type.getObjectType(ex));
super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_EXIT_METHOD, LOG_CLASS_SIGNATURE);
super.visitInsn(Opcodes.ATHROW);
}
}
super.catchException(methodStartLabel,methodEndLabel,Type.getType(RuntimeException.class));
super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_EXIT_METHOD, LOG_CLASS_SIGNATURE);
super.visitInsn(Opcodes.ATHROW);
}
super.visitEnd();
}
示例5: visitEnd
public void visitEnd() {
if (exit) {
done = true;
Label methodEndLabel = super.mark();
super.catchException(methodStartLabel,methodEndLabel,Type.getType(RuntimeException.class));
super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_STOP_METHOD, LOG_METHOD_SIGNATURE);
super.visitInsn(Opcodes.ATHROW);
if (exceptions!=null) {
for(String ex: exceptions) {
super.catchException(methodStartLabel,methodEndLabel,Type.getObjectType(ex));
super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_STOP_METHOD, LOG_METHOD_SIGNATURE);
super.visitInsn(Opcodes.ATHROW);
}
}
}
super.visitEnd();
}
示例6: visitEnd
public void visitEnd() {
if (!methodDone && methodStartLabel != null && constructor) {
methodDone = true;
Label methodEndLabel = super.mark();
super.catchException(methodStartLabel, methodEndLabel, Type
.getType(RuntimeException.class));
super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
LOG_INTERNAL_ALLOC_DEC, VOID_SIGNATURE);
super.visitInsn(Opcodes.ATHROW);
if (exceptions != null) {
for (String ex : exceptions) {
super.catchException(methodStartLabel, methodEndLabel,
Type.getObjectType(ex));
super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
LOG_INTERNAL_ALLOC_DEC, VOID_SIGNATURE);
super.visitInsn(Opcodes.ATHROW);
}
}
}
super.visitEnd();
}
示例7: hookMethod
/**
* (none-javadoc)
*
* @see com.fuxi.javaagent.hook.AbstractClassHook#hookMethod(int, String, String, String, String[], MethodVisitor)
*/
@Override
public MethodVisitor hookMethod(int access, String name, String desc,
String signature, String[] exceptions, MethodVisitor mv) {
if (name.equals("getConnection") && desc.startsWith("(Ljava/lang/String;Ljava/util/Properties;"
+ "Ljava/lang/Class")) {
return new AdviceAdapter(Opcodes.ASM5, mv, access, name, desc) {
@Override
protected void onMethodEnter() {
loadArg(0);
loadArg(1);
invokeStatic(Type.getType(SQLDriverManagerHook.class),
new Method("checkSqlConnectionOnEnter", "(Ljava/lang/String;Ljava/util/Properties;)V"));
invokeStatic(Type.getType(HookHandler.class),
new Method("preShieldHook", "()V"));
}
@Override
protected void onMethodExit(int i) {
if (Opcodes.ATHROW != i) {
loadArg(0);
loadArg(1);
invokeStatic(Type.getType(SQLDriverManagerHook.class),
new Method("checkSqlConnectionOnExit", "(Ljava/lang/String;Ljava/util/Properties;)V"));
}
invokeStatic(Type.getType(HookHandler.class),
new Method("postShieldHook", "()V"));
}
};
}
return mv;
}
示例8: visitInsn
@Override
public void visitInsn(final int opcode) {
if (mv != null) {
mv.visitInsn(opcode);
}
execute(opcode, 0, null);
if ((opcode >= Opcodes.IRETURN && opcode <= Opcodes.RETURN)
|| opcode == Opcodes.ATHROW) {
this.locals = null;
this.stack = null;
}
}
示例9: asmMethodThrow
/**
* 组装被拦截方法在方法内throw时的拦截动作
*/
@SuppressWarnings("unchecked")
private static void asmMethodThrow(MethodModifierContext context) {
InsnList il = context.mn.instructions;
Iterator<AbstractInsnNode> it = il.iterator();
while (it.hasNext()) {
AbstractInsnNode abstractInsnNode = it.next();
switch (abstractInsnNode.getOpcode()) {
case Opcodes.ATHROW:
il.insertBefore(abstractInsnNode, createThrowInstructions(context));
break;
}
}
}
示例10: isThrow
private static boolean isThrow(AbstractInsnNode insn) {
return Opcodes.ATHROW == insn.getOpcode();
}
示例11: canThrow
private boolean canThrow(AbstractInsnNode insn) {
switch (insn.getOpcode()) {
case Opcodes.AALOAD:
case Opcodes.AASTORE:
case Opcodes.ANEWARRAY:
// ARETURN does not throw in its dex image.
case Opcodes.ARRAYLENGTH:
case Opcodes.ATHROW:
case Opcodes.BALOAD:
case Opcodes.BASTORE:
case Opcodes.CALOAD:
case Opcodes.CASTORE:
case Opcodes.CHECKCAST:
case Opcodes.DALOAD:
case Opcodes.DASTORE:
// DRETURN does not throw in its dex image.
case Opcodes.FALOAD:
case Opcodes.FASTORE:
// FRETURN does not throw in its dex image.
case Opcodes.GETFIELD:
case Opcodes.GETSTATIC:
case Opcodes.IALOAD:
case Opcodes.IASTORE:
case Opcodes.IDIV:
case Opcodes.INSTANCEOF:
case Opcodes.INVOKEDYNAMIC:
case Opcodes.INVOKEINTERFACE:
case Opcodes.INVOKESPECIAL:
case Opcodes.INVOKESTATIC:
case Opcodes.INVOKEVIRTUAL:
case Opcodes.IREM:
// IRETURN does not throw in its dex image.
case Opcodes.LALOAD:
case Opcodes.LASTORE:
case Opcodes.LDIV:
case Opcodes.LREM:
// LRETURN does not throw in its dex image.
case Opcodes.MONITORENTER:
case Opcodes.MONITOREXIT:
case Opcodes.MULTIANEWARRAY:
case Opcodes.NEW:
case Opcodes.NEWARRAY:
case Opcodes.PUTFIELD:
case Opcodes.PUTSTATIC:
// RETURN does not throw in its dex image.
case Opcodes.SALOAD:
case Opcodes.SASTORE:
return true;
case Opcodes.LDC: {
// const-class and const-string* may throw in dex.
LdcInsnNode ldc = (LdcInsnNode) insn;
return ldc.cst instanceof String || ldc.cst instanceof Type;
}
default:
return false;
}
}
示例12: onMethodExit
protected void onMethodExit(int opcode) {
if (done || opcode == Opcodes.ATHROW || !isSynchronized()) return;
has_monitor_operation = true;
super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_EXIT_METHOD, LOG_CLASS_SIGNATURE);
}
示例13: onMethodExit
public void onMethodExit(int opcode) {
if (opcode != Opcodes.ATHROW)
addDec();
}