P
puchacz
Hi,
Is it possible to get a reference to caller object (and recursively
all the way up the call stack)? I know about Thread.dumpStack() that
calls new Exception() internally and about sun.reflect.Reflection
class, but you can only get information about classes, method names
and lines - not reference to live objects that in turn can be
inspected using reflection for all field values etc. I know in general
it is probably possible, because this is what debuggers do when
showing stack frame.
What would it take to get this information? It does not have to be
100% compatible with all versions of JDK. Anything in reflection
internal packages? Or maybe there's a library that already does it? To
what degree it is possible without (a) running the whole jvm in
special mode - like debug mode and (b) without processing the whole
program in AspectJ or Hibernate bytecode postprocessors style, and of
course (c) without rewriting the source to pass around "this"
everywhere?
Cheers,
Piotr
Is it possible to get a reference to caller object (and recursively
all the way up the call stack)? I know about Thread.dumpStack() that
calls new Exception() internally and about sun.reflect.Reflection
class, but you can only get information about classes, method names
and lines - not reference to live objects that in turn can be
inspected using reflection for all field values etc. I know in general
it is probably possible, because this is what debuggers do when
showing stack frame.
What would it take to get this information? It does not have to be
100% compatible with all versions of JDK. Anything in reflection
internal packages? Or maybe there's a library that already does it? To
what degree it is possible without (a) running the whole jvm in
special mode - like debug mode and (b) without processing the whole
program in AspectJ or Hibernate bytecode postprocessors style, and of
course (c) without rewriting the source to pass around "this"
everywhere?
Cheers,
Piotr