Skip to main content

A way to find out who called this method

2 replies [Last post]
keeskuip
Offline
Joined: 2003-06-17

I need a way to look up what object/class did call the method that is executing now.
for instance: when executing a.b.getC() I would like get access to object a automatically (without parameter passing)
(I want to use it for poor-mans-aspect-oriented-programming)

Is this already possible? or is it a feature that we want?

Kees.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
euxx
Offline
Joined: 2003-06-10

If you don't care about performance you can use stack trace.

There is also experimental JRockit JVM with AOP on the VM level. Take a look at http://forums.bea.com/bea/thread.jspa?threadID=600006865&tstart=0

alexlamsl
Offline
Joined: 2004-09-02

I think such feature is implemented since J2SE 5 update 4; the way Netbeans Profiler works is via redefineClasses(ClassDefinition ... definitions) in java.lang.instrument.Instrumentation Interface.