ObjectHunter
Hunting and gathering in the JEE landscape

I am Frank, a freelance Java developer specialized in backend development from south western germany.

An Unsafe look at the JVM

posted by fas on 2010-10-08 . Tagged as java, jvm

On his blog Stephen Gennard shows how to use the Unsafe class from Sun to manipulate objects on the heap directly. With this trick it's possible to change memory addresses or contents of any object. Only the JVM has to be started in a different manner for this to work, since permissions to access the restricted classes is needed. The "-Xbootclasspath/p:" option tells the JVM to prepend the class to the bootloader, so that it can access the restricted sun.misc.Unsafe class. Check out "Fiddling with the JVM" on Gennard's blog.

Tags: java, jvm