[jboss-jira] [JBoss JIRA] Updated: (JBREFLECT-50) ReflectMethodInfoImpl.setMethod needs to consider class modifiers in determining setAccessible need
Flavia Rainone (JIRA)
jira-events at lists.jboss.org
Fri Nov 27 07:12:29 EST 2009
[ https://jira.jboss.org/jira/browse/JBREFLECT-50?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Flavia Rainone updated JBREFLECT-50:
------------------------------------
Fix Version/s: JBossReflection.2.2.0.GA
> ReflectMethodInfoImpl.setMethod needs to consider class modifiers in determining setAccessible need
> ---------------------------------------------------------------------------------------------------
>
> Key: JBREFLECT-50
> URL: https://jira.jboss.org/jira/browse/JBREFLECT-50
> Project: JBoss Reflection
> Issue Type: Bug
> Components: BeanInfo
> Affects Versions: JBossReflection.2.0.2.GA
> Reporter: Scott M Stark
> Assignee: Scott M Stark
> Fix For: JBossReflection.2.2.0.GA
>
>
> I ran across an access problem when using the bean info api on a class which has public methods but is not a public class (Its the mbean returned by the java.lang.management.ManagementFactory.getClassLoadingMXBean() method).
> Any properties resolved by the bean info api cannot be accessed because of errors like the following:
> Caused by: java.lang.IllegalAccessException: Class org.jboss.reflect.plugins.introspection.ReflectionUtils can not access a member of class sun.management.ClassLoadingImpl with modifiers "public"
> at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
> at java.lang.reflect.Method.invoke(Method.java:578)
> at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
> at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
> at org.jboss.beans.info.plugins.DefaultPropertyInfo.get(DefaultPropertyInfo.java:133)
> The problem is that the modifiers of the class affect the visibility of the methods. The current check of whether setAccessible needs to be called needs to consider the class modifiers in addition to the method modifiers. The following change to setMethod allows the returned PropertyInfo to be used:
> public void setMethod(Method method)
> {
> if (method != null)
> accessCheck(Modifier.isPublic(method.getModifiers()));
> this.method = method;
> int classModifiers = method.getDeclaringClass().getModifiers();
> boolean isPublic = isPublic() && Modifier.isPublic(classModifiers);
> if (isPublic == false && method != null)
> setAccessible();
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list