jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Instrospection and properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Instrospection and properties" Watch "Instrospection and properties" New topic

Instrospection and properties

Rick DeBay
Ranch Hand

Joined: Jul 11, 2003
Posts: 70
I have a class:

public class Foo
long ndc;
long largerNdc;
public long getLargerNdc()
return largerNdc;
public void setLargerNdc(byte b)
if ( b > 99 || b < 0 )
throw new IllegalArgumentException("Larger NDC suffix must be from 0 through 99");
largerNdc = (getNdc_9() * 100) + b;
public long getNdc_9()
return ndc / 100;

When I get the property descriptors, I get null for the write method:

Granted the 'byte' type of the setter is probably confusing Instrospector.getBeanInfo(), but I can't find anything in the API saying this could be a problem.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

The return type of the getter and the argument type of the setter have to match; otherwise the getter is interpreted as a read-only property of its return type.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link: http://aspose.com/file-tools
subject: Instrospection and properties
It's not a secret anymore!