Method size in bytes

"Peter Rader" ([email protected]) <[email protected]> Sat, 1 Jun 2024 16:30:17 +0200
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <trinity-35258a90-ffc1-4a5d-9423-c651109b96a0-1717252217478@3c-app-gmx-bap51>
This is a multi-part message in MIME format...

------------=_1717252557-3335859-7
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


Hello,
=C2=A0
I try to find the biggest size of all methods in a class. What I can find i=
s the amount of instructions. But how to measure the bytes? This is my Visi=
tor:


public static class MethodMeter extends MethodVisitor {

	private final AtomicInteger maxInstructionSize;
	private final AtomicInteger currentInstructionSize =3D new AtomicInteger(0=
);
	public MethodMeter(final AtomicInteger maxBytecodeSize) {
		super(Opcodes.ASM4);
		this.maxInstructionSize =3D maxBytecodeSize;
	}
	@Override
	public void visitAttribute(final Attribute attribute) {
		super.visitAttribute(attribute);
	}
	@Override
	public void visitEnd() {
		if (currentInstructionSize.get() > maxInstructionSize.get()) {
			maxInstructionSize.set(currentInstructionSize.get());
		}
		currentInstructionSize.set(0);
	}
	@Override
	public void visitInsn(final int opcode) {
		currentInstructionSize.addAndGet(1);
	}
	@Override
	public void visitIntInsn(final int opcode, final int operand) {
		currentInstructionSize.addAndGet(1);
	}
}

=C2=A0
Kind regards

Peter Rader
--
Fachinformatiker AE / IT Software Developer
Peter Rader
Wilsnacker Strasse 17
10559 Berlin - GERMANY
Tel: 0049 (0)30 / 6 29 33 29 6
Fax: 0049 (0)30 / 6 29 33 29 6
Handy: 0049 (0)176 / 87 521 576

------------=_1717252557-3335859-7
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

------------=_1717252557-3335859-7--