All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.avaje.metric.agent.asm.commons.FinallyAdapter Maven / Gradle / Ivy

There is a newer version: 4.3.2
Show newest version
package org.avaje.metric.agent.asm.commons;

import org.avaje.metric.agent.asm.Label;
import org.avaje.metric.agent.asm.MethodVisitor;


public abstract class FinallyAdapter extends AdviceAdapter {

	protected Label startFinally = new Label();

	public FinallyAdapter(MethodVisitor mv, int acc, String name, String desc) {
		super(ASM4, mv, acc, name, desc);
	}

	public void visitCode() {
		super.visitCode();
		mv.visitLabel(startFinally);
	}

	public void visitMaxs(int maxStack, int maxLocals) {

		Label endFinally = new Label();
		mv.visitTryCatchBlock(startFinally, endFinally, endFinally, null);
		mv.visitLabel(endFinally);
		onFinally(ATHROW);
		mv.visitInsn(ATHROW);
		mv.visitMaxs(maxStack, maxLocals);
	}

	protected final void onMethodExit(int opcode) {
		if (opcode != ATHROW) {
			onFinally(opcode);
		}
	}

	protected abstract void onFinally(int opcode);
	

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy