Closed urn1ce closed 1 year ago
This is no bug, this is by design. A TreeSet/TreeMap may have an own Comparator and the Java API has no official way, to get them, therefore reflection is the only way. So, do as the exception says, run your application with run time option "--add-opens java.base/java.util=ALL-UNNAMED"
This is no bug, this is by design. A TreeSet/TreeMap may have an own Comparator and the Java API has no official way, to get them, therefore reflection is the only way. So, do as the exception says, run your application with run time option "--add-opens java.base/java.util=ALL-UNNAMED"
I known your meaning, but if i change like this (still not use "--add-opens java.base/java.util=ALL-UNNAMED") public static void main(String[] args) { var ts = new TreeSet
Yes, because how should XStream know, if a comparator has been set? There's just one way: Look into the private field.
Yes, because how should XStream know, if a comparator has been set? There's just one way: Look into the private field.
So even if not use comparator, also need "--add-opens java.base/java.util=ALL-UNNAMED", it maybe a bit redundant, if catch and handle exception may have a better experience., but i understand, thank you
if you deserialize of TreeSet/TreeMap at java17 like this
you will see error
I think the problem is at TreeSetConverter -> TreeSetConverter.Reflections.sortedMapField TreeMapConverter -> TreeMapConverter.Reflections.comparatorField Fields.locate -> field.setAccessible(true); related exception also need fix
maybe influence after java9 i guess