JVMTI agent to load a different .class file format

Z

zhangyuan.cau

I meet some difficulties about JVMTI and bytecode transform.

I'm using JVMTI to load some different formats of .class file.
It begins with magic number 0xdeadbabe instead of original Java's
0xcafebabe and some different following byte chunks.

Now, I use a callback to handle JVMTI_EVENT_CLASS_FILE_LOAD_HOOK event
and transform received bytes content into original Java bytecode
format.

At first, this method works with Hello World and some toy examples.
However, when it works with a real game server, something wrong
happens: The jrockit JVM reports a class named "ItemManager" with an
invalid magic number and stop to load. But when I use the same agent
to run ItemManager directly, no such an error happens.: JVM only
complains about no main method.

To make things worse, I see from log the "ItemManager.class" is loaded
not from my callback of JVMTI_EVENT_CLASS_FILE_LOAD_HOOK at all. It
comes from somewhere else. so the 0xdeadbabe magic number and
different format will certainly not be correctly loaded :-(

Is there other way JVM load .class that bypasses the
JVMTI_EVENT_CLASS_FILE_LOAD_HOOK callbacks, or the use of reflection
or AspectJ will also cause the problem?

Please give me some suggestion and hint. Thanks a lot :)
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top