How to load applet bytecode to HotSpot VM
David.Holmes at oracle.com
Thu Aug 19 15:45:23 PDT 2010
The appletviewer is just a command that runs the JVM using a special
class as the main application (AppletContext?) - that class knows how to
load and execute applets.
Hotspot can't tell that it is running an applet - it is all just Java
bytecode - some belonging to the libraries that enable you to run the
applet and some to the applet itself.
If you wanted to know when the applet was running then you could add
instrumentation hooks into the VM and then turn them on from Java code
by modifying the AppletContext so that it turns the hooks on/off around
the calls to the Applet control methods (eg start(), stop()). But it all
depends on what methods you are interested in.
It might pay to start by looking at how the applet viewer works.
Yi Yang said the following on 08/20/10 03:53:
> Hello John,
> Thanks for your reply. Sure. I can use appletviewer to test the applet.
> However, my object is not this. I want to add a small code snippet to
> the HotSpot VM so that it can print out the methods invoked information
> when an applet is running. I think the appletviewer is linked with the
> HotSpot under jdk7 directory. How can I link the appletviewer to "my"
> HotSpot project? Does it mean I need to directly change the HotSpot code
> under jdk7 directory? Thank you very much.
> 2010/8/19 John Pampuch <john.pampuch at oracle.com
> <mailto:john.pampuch at oracle.com>>
> You'll need to use "appletviewer", which is included in the JDK (in
> the bin directory) in order to run an applet outside of the context
> of a web browser.
> On 8/19/10 9:43 AM, Yi Yang wrote:
>> Hello everyone,
>> I have a question about HotSpot VM. Thanks for your attention in
>> My object is to load applet bytecode (applet.class) to HotSpot VM
>> and then record the methods invoked by the applet. However, I have
>> no idea how to load the applet bytecode. For example, I can use
>> the command "gamma testClass" to load the file "testClass.class".
>> But how about the applet bytecode without a main entry point? If I
>> use "gamma applet", then here is the error message: Exception in
>> thread "main" java.lang.NoSuchMethodError: main
>> Could you please give me some hints?Hope to hearing from you soon.
>> Thank you.
More information about the hotspot-dev