Wang Hailong created LANG-1738: ---------------------------------- Summary: using ReflectionToStringBuilder.toString on the "HashSet" Key: LANG-1738 URL: https://issues.apache.org/jira/browse/LANG-1738 Project: Commons Lang Issue Type: Bug Components: lang.builder.* Affects Versions: 3.14.0 Reporter: Wang Hailong
when using ReflectionToStringBuilder.toString on the HashSet<String> it just throw an (java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.lang.Object java.util.HashSet.PRESENT accessible: module java.base does not "opens java.util" to unnamed module @37f8bb67) the test code is {color:#bbb529}@Test {color}{color:#bbb529} {color}{color:#cc7832}public void {color}{color:#ffc66d}testReflectionHierarchyHashSet{color}() { HashSet<String> set = {color:#cc7832}new {color}HashSet<>(){color:#cc7832}; {color}{color:#cc7832} {color}set.add({color:#6a8759}"element1"{color}){color:#cc7832}; {color}{color:#cc7832} {color}set.add({color:#6a8759}"element2"{color}){color:#cc7832}; {color}{color:#cc7832} {color}{color:#cc7832} {color}String result = ReflectionToStringBuilder.toString(set){color:#cc7832}; {color}{color:#cc7832} {color}{color:#cc7832} {color}assertNotNull({color:#6a8759}"Result should not be null"{color}{color:#cc7832}, {color}result){color:#cc7832}; {color}{color:#cc7832} {color}assertTrue({color:#6a8759}"Result should contain elements from the HashSet"{color}{color:#cc7832}, {color}result.contains({color:#6a8759}"element1"{color}) && result.contains({color:#6a8759}"element2"{color})){color:#cc7832}; {color}{color:#cc7832} {color}} } -- This message was sent by Atlassian Jira (v8.20.10#820010)