The attached program uses Introspector.getBeanInfo() to get the BeanInfo associated with the class specified on the command line, and then enumerates the PropertyDescriptor[] returned by BeanInfo.getPropertyDescriptors().
I have a class named "Component" in a package named "test" (attached). This class defines a single getter method (getData()).
When I specify "test.Component" as the class to be introspected, I am getting the following wrong result, which looks more like the result of introspecting
"java.awt.Component":
java Introspect test.Component
class: test.Component
pd.length: 7
0:
public java.awt.Color java.awt.Component.getBackground()
class java.awt.Color
1:
public boolean java.awt.Component.isEnabled()
boolean
2:
public boolean java.awt.Component.isFocusable()
boolean
3:
public java.awt.Font java.awt.Component.getFont()
class java.awt.Font
4:
public java.awt.Color java.awt.Component.getForeground()
class java.awt.Color
5:
public java.lang.String java.awt.Component.getName()
class java.lang.String
6:
public boolean java.awt.Component.isVisible()
boolean
However, when i specify "test.component" (with a lower-case 'c') as
the class to be introspected, I get the expected result:
java Introspect test.component
class: test.component
pd.length: 2
0:
public final native java.lang.Class java.lang.Object.getClass()
class java.lang.Class
1:
public java.lang.String test.component.getData()
class java.lang.String
Introspecting "test.Color" (with upper-case 'C') also seems to work as
expected:
java Introspect test.Color
class: test.Color
pd.length: 2
0:
public final native java.lang.Class java.lang.Object.getClass()
class java.lang.Class
1:
public java.lang.String test.Color.getData()
class java.lang.String