OK, I got my test case working with my debugger (Eclipse). I wanted to document what worked and document why my test case was not working.
First what worked, assuming that I am starting with my test case, 'StuckLoop.java', and that it has been compiled with the javac debug option, '-g'.
1) Import the source code for the test case so that is viewable with the debugger. Set a break point at line 10 of the example.
2) Create a run configuration in the debugger. In Eclipse, this means select 'Run --> Debug Configurations' and filling out the form that pops up.
The entries that I used were:
name:
stuck (the name could be anything)
project:
stuckProject (the name could be anything)
Connection type:
Standard (Socket Listen)
Connection Properties:
Port:
8787
Allow termination of remote VM (I left this unchecked)
3) After the information in step 2 is entered, click on the 'Debug' button. If you are in the Eclipse debug perspective, the upper left panel will
display that a
thread has started and it will show that it is in the wait state (waiting for the remote JVM on port 8787).
4) Run the StuckLoop class with the following command:
/usr/share/java8/jdk1.8.0_20/bin/java -agentlib:jdwp=transport=dt_socket,address=8787,server=n,suspend=n,timeout=10 my.example.StuckLoop
NOTE: The above line assumes that StuckLoop.java has a package statement showing StuckLoop is in the 'my.example' package. This is package statement
is not included in the example provided.
Taking these steps, I was able to run the command in step 4 and the debugger stopped the program at the right place. It took a bit of time, maybe a minute or two,
to hit the break point since bebuggers are generally slow.
Why was my test case not working originally?
Well, I skipped step 3 and received the error message shown in my original post. My expectation was that when I ran the command, the program would run and
make a connection with the debugger when the debugger thread became available. That is how I would have implemented the connection, if I had written the
code, but it is what it is. I was confused by the message 'connection refused', which was not the case at all. The error message should have said 'debugger connector is
not available'.