cxbrooks / test

Second test for bugzilla to git
0 stars 0 forks source link

Eclipse Java 9 has problems with javax.xml.bind.DatatypeConverter #22

Closed cxbrooks closed 6 years ago

cxbrooks commented 6 years ago

Note: the issue was created automatically with bugzilla2github tool

Original bug ID: BZ#553 From: @cxbrooks Reported version: unspecified CC: accessors-devel@terraswarm.org

cxbrooks commented 6 years ago

Under Java 9, javax.xml.bind.DatatypeConverter is in a different module.

With Apache Ant, the workaround is to use --add-modules java.xml.bind:

There does not appear to be an easy way to do this under Eclipse.

We are using DatatypeConverter in the following places:

HelperBase.java:

return DatatypeConverter.parseHexBinary(stringObject.substring(2));

HttpServerHelper.java:

byte[] bytes = DatatypeConverter.parseBase64Binary(body);

An alternative is to use Apache Common Codec. The Hex class will handle the first case:

http://commons.apache.org/proper/commons-codec/apidocs/org/apache/commons/codec/binary/Hex.html

The Base64 case will handle the second:

http://commons.apache.org/proper/commons-codec/apidocs/org/apache/commons/codec/binary/Base64.html

cxbrooks commented 6 years ago

Instead, we use BigInteger:

return new BigInteger(stringObject.substring(2),16).toByteArray();

and

byte[] bytes = new BigInteger(body, 64).toByteArray();

cxbrooks commented 6 years ago

In HttpServerHelper, for encoding images we use Base64.getDecoder().decode(body).

This seems to work, so this bug may be closed.