March 30th, 2007

The difference between introspection and reflection in Java

I haven’t used any of the fun introspection/reflection stuff in Java for quite some time, so I got confused about terminology, recently. I kept using the words introspection and reflection interchangeably, but it sounded wrong/made me feel stupid every time I did. A quick Google search provided me with a concise explanation of the differences.

From Java Tip 71 on javaworld.com:

One question that is asked often is, What’s the difference between introspection and reflection? The answer: Reflection allows you to find out which members an object has; and introspection allows you to identify which (JavaBean) properties an object has. That’s why the java.lang.reflect lives in a separate package, and the Introspector object is in the java.beans package. Links to these packages on Sun’s Java site, as well as further information on JavaBeans, are available in the Resources section below.

The key things to recognize are:

  • reflection can be done on any class
  • introspection provides additional info about JavaBeans

One Response to “The difference between introspection and reflection in Java”

  1. Broadband Packages Says:

    it will take a long time to understand me the difference between introspection n reflection in java…there’s lots of confusion regarding this term..:-?

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>