Java access local variable name

I'm writing a program. I want to access the variable names of local variables during program execution and pass them externally I know that Java dumps local variable names during compilation unless compiled in debug mode

@H_ 301_ 8@

After reading it, it seems that JDI / JPDA works in this way Assuming ref refers to threadreference, here is what I have done so far: @ h_ 301_ 8@

@H_ 301_ 8@

ref.suspend();
StackFrame currentFrame = ref.frame(0);
List<LocalVariable> vars = currentFrame.visibleVariables();
ref.resume();

Two questions: @ h_ 301_ 8@

>Am I on the right track, or is there a better way to do it? > How do I get threadreference to set to ref? Locatable event seems to be what I need, but can anyone provide an example of how to use it@ H_ 301_ 8@

Thank you in advance@ H_ 301_ 8@

Solution

Many people have no experience in this field

@H_ 301_ 8@

Look elsewhere for answers I have links to code, but they are no longer This answer cannot be deleted because it has been accepted@ H_ 301_ 8@

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>