开发者

Inspect the return value of a method in jdb

开发者 https://www.devze.com 2023-02-09 11:54 出处:网络
Suppose in jdb I am at the following spot in the code: return 22; -->} How do I dump the value of the object (or primitive) that is going to be returned? It seems like a pain to have to store

Suppose in jdb I am at the following spot in the code:

return 22; 
-->} 

How do I dump the value of the object (or primitive) that is going to be returned? It seems like a pain to have to store the return value in a local variable before returning it, just so that I can see what's going to be returned.

Effectively, I want 开发者_开发问答to do in jdb what is described in the link for gdb:

How to inspect the return value of a function in GDB?


Well the VM is stack orientated and so there is nothing like those registers to read. While in the method you can do trace method exit and the return value will be displayed when the method exits. This is not exactly what you asked since you only see the value once the method has exited. Your other option is to print the expression that will be returned, assuming this has no side-effects.

0

精彩评论

暂无评论...
验证码 换一张
取 消