How to set a breakpoint in <clinit> using JVMTI

D

darthmind

Does anyone know how to get a Method or Constructor object for <clinit>
(which we know
isn't either), to be able use it in JVMTI's SetBreakpoint() in order to
set a breakpoint in
<clinit>? Or how to otherwise obtain a jmethodID for <clinit>?

tia
 
C

Chris Uppal

Does anyone know how to get a Method or Constructor object for <clinit>
(which we know
isn't either), to be able use it in JVMTI's SetBreakpoint() in order to
set a breakpoint in
<clinit>? Or how to otherwise obtain a jmethodID for <clinit>?

As far as the JVM is concerned, <clinit> is just another static method (albeit
one with special rules about how and when it must[n't] be called). So I
imagine that you can get a handle on the method in just the same was as you
would for any other static method. I haven't tried it with JVMTI, but in JNI
calling
GetStaticMethodID(jclass, '<clinit>', '()V').
returns an apparently valid method ID.

-- chris
 
D

darthmind

<clinit> is a special method. And, no, Class.getMethods() and the like
explicitly exclude <clinit>. The problem with GetStaticMethodID() is
that it initializes an uninitialized class, which is not desired in
this case.

Anyone else have any other thoughts?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top