[英]Change compiled code while debugging in Eclipse
It may sound stupid but: is it possible to tell Eclipse to change some already compiled code (in a .class file) while debugging? 听起来可能很愚蠢,但是:是否可以告诉Eclipse在调试时更改一些已经编译的代码(在.class文件中)?
I would like to check a couple of things for some values. 我想检查几件事以获取一些价值。 I know that if it is compiled I cannot change it, so it makes no sense to try this.
我知道,如果已编译,则无法更改,因此尝试此操作是没有意义的。 Well, in this concrete case it does make sense.
好吧,在这种具体情况下,这确实是有道理的。
I am also aware of the hot code replace functionality of Eclipse but it doesn't work for me because it is for source files. 我也知道Eclipse的热代码替换功能,但是它不适用于我,因为它用于源文件。
EDIT: In my case I don't want to change the value of a variable. 编辑:就我而言,我不想更改变量的值。 I would like to put a 1 instead of a 0 in this call within a .class file
我想在.class文件中的此调用中放置1而不是0
getTabFolder().setSelection(0);
If it is just a variable value you want to change you can do this. 如果它只是一个变量值,您可以更改它。
When you are debugging in the debug view of eclipse there is a variables window. 在eclipse的调试视图中进行调试时,会出现一个变量窗口。 If you right click on the variable you wish to change and press 'Change Value' a window will pop up and you can change the value of that variable in there.
如果右键单击要更改的变量,然后按“更改值”,则会弹出一个窗口,您可以在其中更改该变量的值。
I think that you can change body of existing methods, but you cannot add new methods. 我认为您可以更改现有方法的主体,但是不能添加新方法。
You can also change variable values. 您还可以更改变量值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.