K
KevinSimonson
I'm trying to figure out how LimeWire works in the Eclipse debugger.
In
particular, when you run LimeWire in Eclipse, a GUI comes up with a
text field
at the top with "Search..." grayed out inside it, and with a green
button
immediately to its right with the tool tip "Search P2P Network", and I
need to
figure out what happens when I press that button.
I found a series of code that goes like this:
InputStream istream = socket.getInputStream();
socket.setSoTimeout(10000);
ByteReader byteReader = new ByteReader(istream);
OutputStream os = socket.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os);
BufferedWriter out = new BufferedWriter(osw);
out.write(type + " " + handoffLink + " ");
out.write("\r\n");
out.flush();
String str = byteReader.readLine();
and if I put a breakpoint on the line with the <out.flush()> and
another one on
the line with the <byteReader.readLine()>, and let LimeWire run until
it hits
the first breakpoint, and then hit run to take it to the next
breakpoint, the
GUI comes up in between those two breakpoints.
So it looks pretty clear to me that the code that brings up the GUI
must be in
some other thread. Doesn't that have to be the case? I mean, all
that's
happening is a <flush()> call; _that_ can't be causing a GUI to come
up. On the
other hand, a <flush()> call, being an I/O call, might cause the
current thread
to block which would result in another thread starting to execute,
mightn't it?
I guess I don't see any other explanation for this behavior except
that the GUI
must be coming up in another thread.
Anyhow, I wrote a Java program that put code into each LimeWire source
file that
has a <run()> method a few lines of code that create a file that I can
associate
back with that source file, and then ran LimeWire in the debugger
until the GUI
came up. Only two such files showed up when the GUI showed up. I
stepped
through the execution of those two <run()> methods, all the way to the
end of
each <run()> method, and the GUI didn't come up. How is that
possible? If the
code that brings up the GUI is indeed in a separate thread, doesn't it
have to
be either _in_ a <run()> method, or in a method called directly or
indirectly by
a <run()> method in a class that implements <Runnable>?
I'm really confused by this, and if someone can give me some input on
how I can
track the creation of this GUI in the debugger, I'd really appreciate
it.
Kevin S
In
particular, when you run LimeWire in Eclipse, a GUI comes up with a
text field
at the top with "Search..." grayed out inside it, and with a green
button
immediately to its right with the tool tip "Search P2P Network", and I
need to
figure out what happens when I press that button.
I found a series of code that goes like this:
InputStream istream = socket.getInputStream();
socket.setSoTimeout(10000);
ByteReader byteReader = new ByteReader(istream);
OutputStream os = socket.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os);
BufferedWriter out = new BufferedWriter(osw);
out.write(type + " " + handoffLink + " ");
out.write("\r\n");
out.flush();
String str = byteReader.readLine();
and if I put a breakpoint on the line with the <out.flush()> and
another one on
the line with the <byteReader.readLine()>, and let LimeWire run until
it hits
the first breakpoint, and then hit run to take it to the next
breakpoint, the
GUI comes up in between those two breakpoints.
So it looks pretty clear to me that the code that brings up the GUI
must be in
some other thread. Doesn't that have to be the case? I mean, all
that's
happening is a <flush()> call; _that_ can't be causing a GUI to come
up. On the
other hand, a <flush()> call, being an I/O call, might cause the
current thread
to block which would result in another thread starting to execute,
mightn't it?
I guess I don't see any other explanation for this behavior except
that the GUI
must be coming up in another thread.
Anyhow, I wrote a Java program that put code into each LimeWire source
file that
has a <run()> method a few lines of code that create a file that I can
associate
back with that source file, and then ran LimeWire in the debugger
until the GUI
came up. Only two such files showed up when the GUI showed up. I
stepped
through the execution of those two <run()> methods, all the way to the
end of
each <run()> method, and the GUI didn't come up. How is that
possible? If the
code that brings up the GUI is indeed in a separate thread, doesn't it
have to
be either _in_ a <run()> method, or in a method called directly or
indirectly by
a <run()> method in a class that implements <Runnable>?
I'm really confused by this, and if someone can give me some input on
how I can
track the creation of this GUI in the debugger, I'd really appreciate
it.
Kevin S