Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
3.14.0
-
None
-
None
Description
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
@Test public void testReflectionHierarchyHashSet() {
HashSet<String> set = new HashSet<>(); set.add("element1"); set.add("element2"); String result = ReflectionToStringBuilder.toString(set); assertNotNull("Result should not be null", result); assertTrue("Result should contain elements from the HashSet", result.contains("element1") && result.contains("element2")); {color}}
}
The test environment is jdk18
Attachments
Issue Links
- duplicates
-
LANG-1685 [JDK17] ToStringBuilder.reflectionToString fails with InaccessibleObjectException on java.lang classes
- Open