Can encode can now support child class of JAXBElement

fix issue on https://github.com/spring-projects/spring-framework/pull/32977

See comment https://github.com/spring-projects/spring-framework/pull/32977#issuecomment-2243482641

Comment From: snicoll

@deblockt the code as it is is ok and that change would actually introduce the problem you've described.