I'm moving a project to Java11
I already changed sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl with java.lang.reflect.ParameterizedType (as specified here), now is the turn of MalformedByteSequenceException:
warning: MalformedByteSequenceException is internal proprietary API and may be removed in a future release import com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException;
it's being use in a snippet of code that create objects from XML files. More precisely in a try-catch.
try {
...
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(stream);
NodeList list = document.getChildNodes();
fillProcessStack(document);
...
list = list.item(0).getChildNodes();
createItems(list, parent);
} catch (MalformedByteSequenceException e) {
//"Any char in your xml file has a wrong format: " + e.getLocalizedMessage()
} catch (SAXParseException sax) {
...
} catch (Exception e) {
...
}
Anyway I cant find anything online regarding this.
The closest I can think of is UnsupportedEncodingException, but I'm not sure.
Also, it's possible this is a relict of some old code copied from the net, and apparently if I remove it everything looks still fine for the compiler.
So, is there any general/good recommendations about it regarding Java11?
Edit: for the guy seeking to close this question because
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Reproducible Example.
I'll try to be explain clearer.
There is no debugging help here, in Java11 some packages are not exported to public, like sun.* and they shouldnt be used normally (unless specific conditions). Code works fine under jdk8, but under ojdk11 it complains, so I could either use some workarounds to make them visible anyway at runtime or make it right and get rid of them. The latter is what I'm trying to do.
Given I couldn't find anything online, I'm asking here.
MalformedByteSequenceExceptionextendsCharConversionException, which extendsIOException, which theparsemethod forces you to catch anyway. So when catchingIOExceptionorCharConversionException, you’ll also catchMalformedByteSequenceExceptionif thrown directly.However there seems to be a behavioral change of the XML parser in JDK 11. When I try, e.g.
I get
instead of the
of previous versions.
In other words,
parsenow throws aSAXParseExceptionwith a cause initialized to aMalformedByteSequenceException. So, to detect that the problem is a malformed byte sequence, resp. text in the wrong encoding, you’d need something likeTo handle newer and older versions, you’d need something like
resp.