Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caller reference?

 
Tom Elix
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a method in another object, how do I access the reference to the object who called me? In other words, how do I find the object which called this object?
 
Chloe Loh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would pass the reference of the caller object into the mentioned method of the object that will be called. The declaration of the method in the class of the called object can be:
e.g. void calledMethod(Object calledObject)
I don't know if there is any more efficient way of doing it. but, if anyone have a better solution, I also want to learn it..
 
Chloe Loh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I made a mistake.
The declaration of the method in the class of the called object can be:
e.g. void calledMethod(Object callerObject)
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want this information for debugging purpose, you can also get it while writing this dirty code:

You will see all the stack, thus the caller .
W.
[ November 28, 2002: Message edited by: Wilfried LAURENT ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic