[ http://issues.apache.org/jira/browse/BEANUTILS-66?page=all ]
Henri Yandell updated BEANUTILS-66:
-----------------------------------
Bugzilla Id: (was: 39271)
Fix Version/s: LATER THAN 1.8.0
> [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
> Components: Bean / Property Utils
> Environment: Operating System: other
> Platform: Other
> Reporter: Chris
> Fix For: LATER THAN 1.8.0
>
>
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]