commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Seba <>
Subject [BeanUtils] Possible bug or strange behavior
Date Thu, 03 Jul 2008 01:52:15 GMT
This is the first time I'm writing to a list, so I'm not sure whether this
should be sent to DevList or UserList. Sorry if I'm sending this to the
wrong list.
I'm using 1.7.0 version of commons-beanutils. The possible bug (or issue)
I've found is in lines 416 to 418 of class MethodUtils when I'm evaluating
an Enum's constant-specific method, which overrides an abstract one.
Those lines are the following:

415:        // If the declaring class is public, we are done
416:        Class clazz = method.getDeclaringClass();
417:        if (Modifier.isPublic(clazz.getModifiers())) {
418:            return (method);
419:        }

Since every constant of the Enum is compiled as a separate anonymous class
extending the Enum, evaluating its modifiers doesn't return public, which
causes the above return to be skipped.
My question is: should the above code be modified to consider that
particular case? Because the method is actually public and it's declaring
class (the constant, actually) too.

Here I show the code for testing this behavior:

The enum:

public enum SomeEnum {
        public String getLabel() {
            return "a";
        public String getLabel() {
            return "b";
    public abstract String getLabel();

The test class:

public class TestEnum {

    public static void main(String[] args) {
        SomeEnum a = SomeEnum.CONSTANT1;
        Method[] methods = a.getClass().getMethods();
        for (int i = 0; i < methods.length; i++) {
            Method method     = methods[i];
            System.out.println(method.getName() + " - " +

    private static boolean evaluateMethod(Method method) {
        return Modifier.isPublic(method.getDeclaringClass().getModifiers());

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message