[ 
https://issues.apache.org/jira/browse/LANG-1765?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory updated LANG-1765:
----------------------------------
    Summary: Fix Javadoc for FieldUtils.read[Declared][Static]Field()  (was: 
Fix Javadoc for FieldUtils.readDeclaredStaticField())

> Fix Javadoc for FieldUtils.read[Declared][Static]Field()
> --------------------------------------------------------
>
>                 Key: LANG-1765
>                 URL: https://issues.apache.org/jira/browse/LANG-1765
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.17.0
>            Reporter: Wang Hailong
>            Priority: Major
>             Fix For: 3.18.0
>
>
> The mimal test case is like that:
> {color:#cc7832}class {color}ChildClass
> { 
> static String fieldName{color:#cc7832};
> }{color}
>     @org.junit.jupiter.api.Test // Corrected annotation usage
>     public void testReadStaticFieldAcrossInheritance() throws Exception {
>         // Data Preparation
>         Class<?> cls = ChildClass.class;
>         Field field = cls.getDeclaredField("fieldName");
>         field.setAccessible(true);
>         // API Invocation
>         Object value = FieldUtils.readDeclaredStaticField(cls, "fieldName");  
>   }
> And it just throw a nullpointerException
> And I find out why it could happen:
> in the method : getDeclaredField
> try {
>             Field field = cls.getDeclaredField(fieldName);
>             if (!MemberUtils.isAccessible(field)) {
>                 if (!forceAccess) {
>                     return null;
>                 }
>                 field.setAccessible(true);
>             }
>   The method "MemberUtils.isAccessible(field)"  it can not recognize that I 
> have set the filed to be accessible by java reflection. So it just return 
> null and the it will throw a nullPointerException
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to