eclipse-sirius / sirius-emf-json

JSON-based EMF Resource implementation - part of Eclipse Sirius
https://eclipse.dev/sirius/sirius-web.html
Eclipse Public License 2.0
5 stars 10 forks source link

Remove the need to use Java 11 max #2

Closed pcdavid closed 5 months ago

pcdavid commented 3 years ago

The build currently requires the use of Java 11, and does not work with later versions. There are actually two issues.

First, running the build with Java 12 or later causes this error:

[ERROR] Cannot resolve target definition:
[ERROR]   Problems resolving provisioning plan.:
[ERROR]      Unable to satisfy dependency from tycho-ee-1603441963827 0.0.0.1603441963827 to org.eclipse.equinox.p2.iu; a.jre.javase [12.0.0,12.0.0].

This is because we currently use Tycho 1.7.0, which does not know about Java 12 or later.

Switching to Tycho 2.0.0 reveals the second problem:

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.0.0:compile (default-compile) on project org.eclipse.sirius.emfjson: Compilation failure: Compilation failure: 
[ERROR] /home/pcdavid/src/eclipse-sirius/sirius-emf-json/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/utils/GsonEObjectSerializer.java:[34] 
[ERROR]     import javax.xml.bind.DatatypeConverter;
[ERROR]            ^^^^^^^^^^^^^^
[ERROR] The import javax.xml.bind cannot be resolved
[ERROR] /home/pcdavid/src/eclipse-sirius/sirius-emf-json/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/utils/GsonEObjectSerializer.java:[1055] 
[ERROR]     jsonArray.add(new JsonPrimitive(DatatypeConverter.printHexBinary((byte[]) object)));
[ERROR]                                     ^^^^^^^^^^^^^^^^^
[ERROR] DatatypeConverter cannot be resolved
[ERROR] /home/pcdavid/src/eclipse-sirius/sirius-emf-json/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/utils/GsonEObjectSerializer.java:[1062] 
[ERROR]     jsonElement = new JsonPrimitive(DatatypeConverter.printHexBinary((byte[]) value));
[ERROR]                                     ^^^^^^^^^^^^^^^^^
[ERROR] DatatypeConverter cannot be resolved
[ERROR] 3 problems (3 errors)

We currently use javax.xml.bind.DatatypeConverter in GsonEObjectSerializer.serializeEByteArrayEAttribute(EObject, EAttribute) to encode byte arrays as hex strings, but javax.xml.bind is no longer part of the JDK. What is strange is that we explicitly have javax.xml and javax.xml.bind in our target platform (taken from Orbit), and still they are not found.

Given the very limited reason we have this dependency, the best way is probably to drop is completely and use a custom implementation. I have a patch in progress to do this, but it's not ready yet (not fully tested).

pcdavid commented 5 months ago

Since 0f420f3e4dfcb3d9bc8efa8c05a9106b7453c3f0 we're using Maven 3.0.4, and with #16 merged I guess both issues are now fixed.