Closed Boris-de closed 7 months ago
Note: This is using reflection to use Method.canAccess()
. An alternative would be to create a multi-release jar that provides different implementations for java8 and java9+. As the implementation is heavily using reflection anyway going the reflective way seemed fine to me, but I can adapt this PR to a multi-release jar if you want.
Another very simple fix might be to have a special handling for XMLGregorianCalendar (and possibly Duration?) in DefaultCopyStrategy.copyInternal()
. This would only fix it for those classes, which might be enough because in reality it should only affect classes from the java.xml module?
Closing as worked done in jaxb-tools repository
XMLGregorianCalender is not cloneable with the current implementation when using java 17. The implementation did not select the method
XMLGregorianCalendar.clone()
which is accessible to anyone, but rather the methodXMLGregorianCalenderImpl.clone()
to which access is prohibited in recent java versions ending up in an IllegalAccessError.This fixes the problem by searching for the first clone() method in the classes hierarchy that is public and accessible. This removes the need of calling
setAccessible()
because the method will be accessible. For java8 it will still use the old logic becauseMethod.canAccess()
does not exist until java9.(This is a possible fix for #130)