• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to find Object type.

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amit,

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



Perhaps this could solve your problem!



Regards,
cmbhatt
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic