aspose file tools*
The moose likes Java in General and the fly likes How to find Object type. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to find Object type." Watch "How to find Object type." New topic
Author

How to find Object type.

Amit Wadhwaa
Ranch Hand

Joined: Feb 15, 2007
Posts: 74
Basic Qs: How to find the actual concrete class of an object?

Problem: I have this thousands of line of code and there's this object and I want to debug one of its methods. The problem is the whole code uses factory pattern and it's becoming very hard for me to find the actual class of the object.

The code is something like
a.callMethodWhichIWantToDebug();


Few lines before that we have something like a=getA();
getA(){
B b=getC().createB();
a=getC().getA(b)
return a;
}
getC()
{
D d=getE().getD();
...
and soon

Ofcourse D, E,B are all interfaces.


Is there a easier way to find the implementation class of the object

I cannot use a debugger as I have to deploy the program on a server (it doesnt take long though)to run it.
And hence setting up a debugger would take up some time(stubs/skeletons for code)


SCJP 5 94%<br /><a href="http://amit-wadhwa.blogspot.com/" target="_blank" rel="nofollow">My Blog</a>
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

You can call getClass() on any object, which returns java.lang.Class. Then use, e.g., Class.getName() to get the name of the class.


[Jess in Action][AskingGoodQuestions]
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Amit,

I have a little idea; you can play with it:



Perhaps this could solve your problem!



Regards,
cmbhatt


cmbhatt
 
 
subject: How to find Object type.