I know this might be a broad question, but I am looking at JVMTI as a possible method to count the number of executed Java bytecode operations and was wondering if this was possible? To be more specific, is there a way to count only the executed bytecodes from a specific code region, say the number bytecodes within a certain loop iteration, for example. I am not looking for a full solution, but maybe rather someone to point me in the right direction.
Basically you need to implement the stepi feature of a debugger. I would suggest you to take a look
at the jdb source code. Which is available for free at openjdk.java.net. Download the jdk source code
and the jdb source is in src/share/classes/com/sun/tools/examples/tty directory.