Security Type: uncheck an object on a JAXBElement <User> object

I have a problem with cast

JAXBElement<User> jaxbElement = (JAXBElement<User>)unmarshaller.unmarshal(sr); 

This does not work, can eveybody help me?


I can not do this: I will show you my code:

StringReader sr = new StringReader(this.message);
JAXBElement<Utilisateur> jaxbElement = (JAXBElement<Utilisateur>) unmarshaller.unmarshal(sr);   

If I do this, I have an error because I am using StringReader:

JAXBElement<User> jaxbElement = unmarshaller.unmarshal(sr, User.class); 
+4
source share
1 answer

If you want to avoid a compiler warning, you can use one of the non-marshal methods that takes a parameter Class.

JAXBElement<User> jaxbElement = unmarshaller.unmarshal(sr, User.class);

Note

Your code should work just fine, as you have it in your question.

+8
source

Source: https://habr.com/ru/post/1538193/


All Articles