attach agent to applet running in firefox (attach api)

C

craiget

Hi,

I am trying to use the Java 6 "Attach API" to examine the contents of
a running applet's top-level Frame via reflection. I can get at the
frame by attaching to Firefox's PID and calling Frame.getFrames().
This returns a single frame and works fine. However, what I *really*
want is to get the top-level frame from a *second* applet that is
loaded in a new browser window by clicking on a button in the first
applet. Even though two applets are running, Frame.getFrames() only
returns the single frame of the original. Any suggestions on how to
get at that second frame?

If you're still with me, here's a bit more detail:

I wanted to fool around with the Attach API as demonstrated at
http://www.fasterj.com/articles/hotpatch1.shtml

After a bit, I ended up with something like this to attach my Agent to
a running instance of Firefox:

class Attach {
public static void main(String args[]) {
String pid = "1234"; //get firefox's pid
VirtualMachine vm = VirtualMachine.attach(pid);
vm.loadAgent("myagent.jar", null);
}
}

So far so good. When I run that code, it successfully attaches to FF
and my Agent ends up with an instance of Instrumentation that has
access to all the classes currently loaded by the JVM.

class MyAgent {
public static void agentmain(String agentArgs, Instrumentation inst)
{
for(Class klass : inst.getAllLoadedClasses())
{
//do stuff
}
}
}

By invoking the static Frame.getFrames() method via reflection, I am
able to get the top-level frame for ONE but not BOTH of the running
Applets. There are a couple of static calls available, (getWindows(),
getOwnerlessWindows()) and they all return the same instance of
java.awt.Frame.

So, any suggestions on how I can get at that second Frame?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top