commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (BEANUTILS-66) [beanutils] MethodUtils.getAccessibleMethod does not work for enums
Date Fri, 03 Nov 2006 23:40:17 GMT
     [ http://issues.apache.org/jira/browse/BEANUTILS-66?page=all ]

Henri Yandell resolved BEANUTILS-66.
------------------------------------

    Resolution: Won't Fix

No suggestions were forthcoming, so resolving this one wontfix.

> [beanutils] MethodUtils.getAccessibleMethod does not work for enums
> -------------------------------------------------------------------
>
>                 Key: BEANUTILS-66
>                 URL: http://issues.apache.org/jira/browse/BEANUTILS-66
>             Project: Commons BeanUtils
>          Issue Type: Bug
>         Environment: Operating System: other
> Platform: Other
>            Reporter: Chris
>
> I dont know if this is supposed to work or not, but it would be nice if 
> MethodUtils.getAccessibleMethod correctly detected accessible enum methods.  I 
> am in the most recent production beanutils.jar (1.7.0).
> I have an enum like this in its own file:
> public enum DataEditDataType {
>   /** string data type */
>   STRING {
>     @Override
>     public String getValueName() {
>       return "string";
>     }
>     
>   },  ...
> Then I am getting the property descriptor ok
> PropertyDescriptor propertyDescriptor = PropertyUtils.getPropertyDescriptor
> (DataEditDataType.STRING, "valueName");
> Then the method is fine
> Method method = propertyDescriptor.getReadMethod();
> But then it is seen as not accessible
>     Method method = MethodUtils.getAccessibleMethod(method);
> Which return null
> The problem is line 415 of MethodUtils
>         // If the declaring class is public, we are done
>         Class clazz = method.getDeclaringClass();
>         if (Modifier.isPublic(clazz.getModifiers())) {
>             return (method);
>         }
> For some reason, Modifer.isPrivate(clazz.getModifiers()) returns true (since 
> STRING is a subclass of the DataEditDataType enum.  but this is an enum 
> (DataEditDataType) which is publicly available???   There could be a line here 
> to see if it is an enum, then if the superclass is public in which case it is 
> ok?  Something like this
> if (Enum.class.isAssignableFrom(clazz) && Modifier.isPublic(clazz.getSuperclass
> ().getModifiers()) {
>   return method;
> }
> That would work for me, but not sure if it would work in all cases or break 
> something else or if there is another workaround I can do for my enum code.
> Thanks!
> Chris

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message