On 6/25/2010 3:28 AM, Kevin McMurtrie wrote:
In article<vhzUn.41045$_F1.14580@hurricane>,
"Boris Punk"<khgfhf@hmjggg.com> wrote:
Is there anyway to do this? Serialization looks cumbersome and I want to
dump the data of an object onto disk.
eg.
class AClass{
AClass(){
}
}
how do you get a representation of this in byte form? It can't be that
difficult to grab from memory, dump to disk, then retrieve back into
memory
again?
sun.misc.Unsafe will do it. I'm sure you'll find that it's a very aptly
named class. It's like the old peek() and poke() but decades after
fixed memory addresses when out of style.
Before getting too enthusiastic about sun.misc.Unsafe, or any
other sun.xxx package, bear in mind that (1) the package and
everything in it is subject to change without notice, (2) "change"
includes "incompatible change," and (3) sun.xxx packages might not
even exist if you're not using Sun's own JVM. See
http://java.sun.com/products/jdk/faq/faq-sun-packages.html
off-version JRE.