I have the following code
String innerText = null;
innerText = this.getException(detail.getChildElements());
causing this warning
Type safety: The expression of type Iterator needs unchecked conversion to conform to Iterator
The referenced method is
private String getException(Iterator<OMElementImpl> iterator) { ... }
The other method, getChildElements()
, is in a JAR file that I can't touch. There are no other warnings or errors.
From Googling, it seems like the usual way to get rid of this sort of warning is
@SuppressWarnings("unchecked")
String innerText = this.getException(detail.getChildElements());
because the compiler can't guarantee safety ahead of time, but I'd prefer to avoid using SuppressWarnings
if possible... is there a better way?
EDIT: getChildElements()
is documented here