highsource / highsource/jsonix

Compiler execution fails using Java 10

Open
#226 4 comments 6 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
369
Forks
85
PR merge metrics
No merged PRs in 30d

Description

Hi,
unfortunately the latest compiler binary (jsonix-schema-compiler-full.jar, via NPM, version 3.0.0) does not run out of the box with Java 10 (at least at my setup) and fails with the following exception/stacktrace:

```
Exception in thread "main" java.lang.Error: java.lang.reflect.InvocationTargetException
at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.(BGMBuilder.java:147)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:117)
at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:425)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
at org.hisrc.jsonix.JsonixMain.execute(JsonixMain.java:99)
at org.hisrc.jsonix.JsonixMain.main(JsonixMain.java:77)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
... 7 more
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
at com.sun.tools.xjc.reader.xmlschema.BindingComponent.getClassSelector(BindingComponent.java:65)
at com.sun.tools.xjc.reader.xmlschema.ColorBinder.(ColorBinder.java:62)
at com.sun.tools.xjc.reader.xmlschema.BindGreen.(BindGreen.java:63)
... 12 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
... 15 more
Caused by: java.lang.NoClassDefFoundError: javax/activation/MimeTypeParseException
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.base/java.lang.Class.getConstructor0(Unknown Source)
at java.base/java.lang.Class.getDeclaredConstructor(Unknown Source)
at com.sun.tools.xjc.reader.Ring.get(Ring.java:100)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.(DefaultClassBinder.java:98)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector.(ClassSelector.java:214)
... 20 more
Caused by: java.lang.ClassNotFoundException: javax.activation.MimeTypeParseException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 27 more
```

I guessed, that Oracle removed again some classes from the standard classpath. Thus, I tried to load the *javax.activation-api* binary (https://mvnrepository.com/artifact/javax.activation/javax.activation-api/1.2.0) manually into the classpath, which results in another couple of warnings:

```
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/C:/Users/fir3/projects/Test/xml-test/node_modules/jsonix/lib/jsonix-schema-compiler-full.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
```

(This is actually quiet funny because the maintainers of *com.sun.xml.bind.v2.runtime.reflect.opt.Injector* is Oracle...)

I was able to hide those error messages using a property-flag. My final command line command looked like this:

```
java -Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize -cp node_modules\jsonix\lib\jsonix-schema-compiler-full.jar;javax.activation-api-1.2.0.jar org.hisrc.jsonix.JsonixMain -d src\mappings -p PunnyCake my.xsd
```

EDIT: I'm using Java 10 and not Java 9.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.