@Override public void visitInsn(int opcode) { if ((opcode >= IRETURN && opcode <= RETURN)) { int lvPosReturn; switch (returnType.getSort()) { case Type.ARRAY: if (returnType.getElementType().getSort() == Type.INT) { lvPosReturn = newLocal(returnType); mv.visitVarInsn(Opcodes.ASTORE, lvPosReturn); mv.visitVarInsn(Opcodes.ALOAD, lvPosReturn); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn( GETFIELD, owner, TraceSQL.CURRENT_TRACESQL_FIELD, "Lscouter/agent/batch/trace/TraceSQL;"); mv.visitVarInsn(Opcodes.ALOAD, lvPosReturn); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, ADDS_METHOD, ADDS_SIGNATURE, false); } break; case Type.INT: lvPosReturn = newLocal(returnType); mv.visitVarInsn(Opcodes.ISTORE, lvPosReturn); mv.visitVarInsn(Opcodes.ILOAD, lvPosReturn); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn( GETFIELD, owner, TraceSQL.CURRENT_TRACESQL_FIELD, "Lscouter/agent/batch/trace/TraceSQL;"); mv.visitVarInsn(Opcodes.ILOAD, lvPosReturn); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, ADD_METHOD, ADD_SIGNATURE, false); break; /* case Type.BOOLEAN: lvPosReturn = newLocal(returnType); mv.visitVarInsn(Opcodes.ISTORE, lvPosReturn); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, owner, TraceSQL.CURRENT_TRACESQL_FIELD, "Lscouter/agent/batch/trace/TraceSQL;"); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, STATMENT, GETUPDATECOUNT_METHOD, GETUPDATECOUNT_SIGNATURE,false); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, ADD_METHOD, ADD_SIGNATURE,false); mv.visitVarInsn(Opcodes.ILOAD, lvPosReturn); break;*/ } // Return 결과 셋팅 mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn( GETFIELD, owner, TraceSQL.CURRENT_TRACESQL_FIELD, "Lscouter/agent/batch/trace/TraceSQL;"); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, END_METHOD, END_SIGNATURE, false); } mv.visitInsn(opcode); }
public InitialContextMV( int access, String desc, MethodVisitor mv, String classname, String methodname, String methoddesc) { super(ASM4, access, desc, mv); this.returnType = Type.getReturnType(desc); }
@Override public void visitCode() { AsmUtil.PUSH(mv, fullname_hash); mv.visitLdcInsn(fullname); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, START_METHOD, START_SIGNATURE, false); statIdx = newLocal(Type.getType(Object.class)); mv.visitVarInsn(Opcodes.ASTORE, statIdx); mv.visitLabel(startFinally); mv.visitCode(); }
@Override public void visitCode() { AsmUtil.PUSH(mv, methodName); boolean flag = false; int sidx = isStatic ? 0 : 1; for (int i = 0; i < paramTypes.length; i++) { Type tp = paramTypes[i]; if ("java/lang/String".equals(tp.getInternalName())) { mv.visitVarInsn(Opcodes.ALOAD, sidx); flag = true; break; } sidx += tp.getSize(); } if (flag == false) { AsmUtil.PUSH(mv, ""); } mv.visitMethodInsn(Opcodes.INVOKESTATIC, CLASS, METHOD, SIGNATURE, false); super.visitCode(); }
@Override public void visitMaxs(int maxStack, int maxLocals) { Label endFinally = new Label(); mv.visitTryCatchBlock(startFinally, endFinally, endFinally, null); mv.visitLabel(endFinally); mv.visitInsn(DUP); int errIdx = newLocal(Type.getType(Throwable.class)); mv.visitVarInsn(Opcodes.ASTORE, errIdx); mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitVarInsn(Opcodes.ALOAD, errIdx); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, END_METHOD, END_SIGNATURE, false); mv.visitInsn(ATHROW); mv.visitMaxs(maxStack + 8, maxLocals + 2); }
@Override public void visitMaxs(int maxStack, int maxLocals) { Label endFinally = new Label(); mv.visitTryCatchBlock(startFinally, endFinally, endFinally, null); mv.visitLabel(endFinally); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn( GETFIELD, owner, TraceSQL.CURRENT_TRACESQL_FIELD, "Lscouter/agent/batch/trace/TraceSQL;"); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, END_METHOD, END_SIGNATURE, false); int errIdx = newLocal(Type.getType(Throwable.class)); mv.visitVarInsn(Opcodes.ASTORE, errIdx); mv.visitInsn(ATHROW); mv.visitMaxs(maxStack + 8, maxLocals + 2); }
@Override public MethodVisitor visitMethod( int access, String methodName, String desc, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, methodName, desc, signature, exceptions); if (mv == null) { return mv; } if (SqlMapASM.targetMethod.contains(methodName) == false) { return mv; } return new SqlMapMV( access, desc, mv, Type.getArgumentTypes(desc), (access & ACC_STATIC) != 0, className, methodName, desc); }
public PsExecuteMV(int access, String desc, MethodVisitor mv, String owner, String name) { super(ASM4, access, desc, mv); this.owner = owner; this.returnType = Type.getReturnType(desc); }
public static void main(String[] args) { Type type = Type.getReturnType("(Z)[I"); System.out.println("type = " + type.getSort()); System.out.println("dim = " + type.getDimensions()); System.out.println("element = " + type.getElementType()); }