This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

introspection  RSS feed

 
Rahul Shilpakar
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybudy tell me what is introspection in Java? where it is used and whts the application of this introspection?
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rahul Shilpakar:
can anybudy tell me what is introspection in Java? where it is used and whts the application of this introspection?


When humans introspect, they look inside themselves. When our programs introspect, they also look inside themselves, but in a different way. In object-oriented languages, introspection is the idea that program code can get information on itself. In object-oriented languages, introspection permits programs to get and use information on classes and objects at run-time. Using introspection, one can ask an object for its class, ask a class for its methods and constructors, find out the details of those methods and constructors, and tell those methods to execute.

Introspection in Java also reflects the idea that everything is or can be an object. In particular, you can have objects of type Class and objects of type Method.

Is that the information you was looking for.???

Let me know if you need further clarifications...
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well for more information you can also check out the following link...

Effeicient Introspection in JAVA .


If still any concern then revert with concerns....
 
Rahul Shilpakar
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yikes! That article is pretty advanced for this forum. I'd suggest the original poster skip it for a while.

Just to keep us on our toes, the Java designers introduced a new word and gave us "introspection" through the "reflection" APIs. Here's a common bit of reflection code:

Look at the JavaDoc for Class and Method, methods like forName(), getMethod() and see if you can work out what this code does.

Also see if you can make up a good reason to create a class or invoke a method when you only know its name in a String. We have some really good reasons, but it will be a lot more fun if you try to think up your own scenarios where that would be useful.
[ March 27, 2007: Message edited by: Stan James ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!