[英]Looking for something void
I'm looking for a command/line that does literally nothing, is as short and simple as possible, but allows me to place a breakpoint on it. 我正在寻找一个几乎没有任何东西的命令/行,尽可能短而简单,但允许我在它上面放置一个断点。 (in Eclipse)
(在Eclipse中)
What I've tried: 我尝试过的:
System.out.println(""); //Too long, also it prints an empty line
boolean b = false; //Also too long + could cause interferences
; // Doesn't let me place a breakpoint on it in Eclipse
if (true); //Doesn't trigger
I need this for conditional breakpoints. 我需要这个条件断点。 (certain indexes in a for-loop for example)
(例如for循环中的某些索引)
I am aware of conditional breakpoints in Eclipse, but I'm still looking for that void line. 我知道Eclipse中的条件断点,但我仍然在寻找那条空行。 (partially because of plain interest, and partially because I don't like clicking things and relying purely on the IDE)
(部分原因是因为我感兴趣,部分是因为我不喜欢点击内容而完全依赖于IDE)
You could use the assert-Statement: 你可以使用assert-Statement:
assert true;
But you have to activate asserts. 但你必须激活断言。 In Eclipse see Eclipse: enable assertions
在Eclipse中看到Eclipse:启用断言
Rather than adding code simply for setting breakpoints, you can set a java expression as a breakpoint condition in eclise: 您可以在eclise中将java表达式设置为断点条件,而不是仅为设置断点添加代码:
https://wiki.eclipse.org/FAQ_How_do_I_set_a_conditional_breakpoint%3F https://wiki.eclipse.org/FAQ_How_do_I_set_a_conditional_breakpoint%3F
(other IDEs support this as well, but the question was about Eclipse) (其他IDE也支持这个,但问题是关于Eclipse)
Use empty curly brackets {} , that'll probably do, or Semi-colon ; 使用空的大括号{} ,可能会做,或者使用分号; actually will do as well.
实际上也会这样做。
This Eclipse page shows that by right-clicking or double clicking the left margin of the Eclipse code editor, you can toggle breakpoints. 此Eclipse页面显示通过右键单击或双击Eclipse代码编辑器的左边距,可以切换断点。
This post also has some good info on setting breakpoints. 这篇文章也有一些关于设置断点的好信息。
Edit: 编辑:
If you don't want to toggle breakpoints through the Eclipse interface, you could just write your own method of type void and call that. 如果您不想通过Eclipse接口切换断点,您可以编写自己的void类型方法并调用它。 For example:
例如:
public void wait() {} // Empty method
And then you can just call the method wherever you want to set a breakpoint. 然后您可以在任何想要设置断点的地方调用该方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.