Posts for the month of August 2009

Missed helper methods in subclasses

I came across a problem when subclasses add helper methods to an action or property. Essentially this would not work and the helper methods in the subclass would be added as its own action. To clarify:

public abstract class Customer {
    public String getName() {
        return name;
    }
}

public class CustomerSubclass extends Customer {
    public String disableName() {
        return "No names please";
    }
}

Would have been seen as one property (Name) and one action (Disable Name).

The problem was that in the facet factories the searching for helper methods was done on the class that the property or action method was declared in. So in this example it would be the Customer class even though the CustomerSubclass? was the one being reflected upon.

To resolve this the process method is now called with the original class and the method, rather than just the method. The new signature is:

    boolean process(Class<?> cls, Method method, MethodRemover methodRemover, FacetHolder holder);