Questions tagged [jvmti]

JVMTI is the Java Virtual Machine Tool Interface, a native API by which authors can write JVM plugins to monitor or modify the execution of a Java Virtual Machine.

Documentation for the current JVMTI 1.2. Home page for JVMTI in JDK 7.

JVMTI was introduced in JDK 5. It replaces Java Virtual Machine Profiler Interface (JVMPI) and the Java Virtual Machine Debug Interface (JVMDI).

214 questions
1
vote
2 answers

How do I catch the read and writes in a java program?

I am trying to create a tool that can capture all the read and writes made by a java program. Also, I would like to know what fields of what object is access/modified. I currently looked at:- 1) java.lang.instrument I could not do much with that. I…
Ankit
  • 6,772
  • 11
  • 48
  • 84
1
vote
0 answers

JVMTI : Forward captured object to another JVM

I wrote exception handler agent using JVMTI. I am able to capture the StackFrame information at that point in time jvmti_env -> GetLocalVariableTable(frames[i].method, &entry_count_ptr, &table_ptr_test); And able to fetch value for primitive types…
1
vote
1 answer

Java Force Garbage collection without using JVMTI?

The only way I know to force garbage collection is to use ForceGarbageCollection() from JVMTI. Is there any cross-platofrm way to force GC (so I don't need to create a JVMTI library for each platform)?
Nfff3
  • 321
  • 8
  • 24
1
vote
1 answer

Get number of instances of a given Java class using a Java agent?

Is it possible to use a Java agent to get the number of instances of any Java class? For example if we have class Apple { ... } The Java agent will return how many Apple instances are there in the JVM. If it's not possible with a Java agent, is it…
Nfff3
  • 321
  • 8
  • 24
1
vote
1 answer

Why when processing JVMTI EVENT_EXCEPTION the JVM sometimes crashes or starts slowly?

I decided using JVMTI to register all exceptions occured in JVM and build Histogram: ClassName_method_ExceptionName:count Agent attached like this: taskset -c 10,12 java -agentpath:./jni-agent.so ${JVM_OPTION} -cp module.jar…
srg321
  • 105
  • 7
1
vote
2 answers

How can I catch JIT's deoptimization events like "unstable_if" with JNI+JVMTI

I've realy though about how can I catch JIT's deoptimization events. Today, I've read brilliant answer by Andrei Pangin When busy-spining java thread is bound to physical core, can context switch happen by the reason that new branch in code is…
srg321
  • 105
  • 7
1
vote
0 answers

When to use INVOKE_SINGLE_THREADED or INVOKE_NONVIRTUAL when invoking method on com.sun.jdi.ObjectReference?

When invoking a method on an com.sun.jdi.ObjectReference instance, you have to provide some options: either INVOKE_SINGLE_THREADED, or INVOKE_NONVIRTUAL. invokeMethod​(ThreadReference thread, Method method, List arguments, int…
Nfff3
  • 321
  • 8
  • 24
1
vote
1 answer

Race condition in java agent between initializing ThreadStart event callback and agent threads being created

The JVMTI documentation states the following about VMInit events. The VM initialization event signals the completion of VM initialization. The thread start event for the main application thread is guaranteed not to occur until after the handler…
PiRocks
  • 1,708
  • 2
  • 18
  • 29
1
vote
1 answer

Measuring method execution with JVMTI

Using the MethodEntry and MethodExit event hooks provided by the JVMTI how would I measure the time of a method executed in Java? In simple means it's just: time2 - time1 but the problem I see, how to I distinguish between the different methods?…
Konrad Reiche
  • 27,743
  • 15
  • 106
  • 143
1
vote
0 answers

Where is JVMTI's Breakpoint event called?

I cloned OpenJDK8's source code and wanted to check where exactly JVMTI's Breakpoint callback is called. What I found is that all the breakpoints are stored in a list of type JvmtiBreakpoint. What I couldn't find was where exactly the breakpoint…
Nfff3
  • 321
  • 8
  • 24
1
vote
0 answers

How to exclude non-project classes from Step Event in JVMTI?

Currently this is how I generate Step events: ... capabilities.can_generate_single_step_events = 1; ... callbacks.SingleStep = SingleStep; jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL); And then the…
Nfff3
  • 321
  • 8
  • 24
1
vote
0 answers

How to put non-blocking breakpoint in JDI (Java Debug Interface)?

When you have a BreakpointEvent or StepEvent in JDI (Java Debug Interface), what happens is that the currently executing program(debugee) is suspended until the debugger processes the breakpoint event and resumes the debugee. But if you have many…
Nfff3
  • 321
  • 8
  • 24
1
vote
0 answers

JVMTI agent never returns the thread state terminated

Implementing a JVMTI agent, I read the threads state on certain events, for instance ThreadStart, ThreadEnd, VMInit, VMDeath, etc. However, I noticed, that the threads state is never new or terminated, but always runnable, wait, etc. There might be…
Konrad Reiche
  • 27,743
  • 15
  • 106
  • 143
1
vote
1 answer

What is the difference between JVMTI SuspendThread and Javas thread.suspend?

Is there any difference in using SuspendThread from a JVMTI agent and using the plain Java thread.suspend()?
eugen
  • 5,856
  • 2
  • 29
  • 26
1
vote
0 answers

How to suspend the current JVM programmatically and wait for a debugger to connect?

My goal is to implement a small library in Java that would allow to programmatically take some actions and then suspend the current JVM until a debugger is connected to it. I imagine parts of it at least are possible, for ex. when starting a JVM in…
eugen
  • 5,856
  • 2
  • 29
  • 26