Menu

#1307 Java 9 compatibility

4.1
closed-out-of-date
None
5
2019-04-14
2017-02-16
No

This ticket tracks compatibility issues running OmegaT under Java 9.

Under JDK 9 Early Access Build 156 the following issues have been noted:

JAXB error on launch

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
    at org.omegat.filters2.master.FilterMaster.<clinit>(FilterMaster.java:113)
    at org.omegat.Main.main(Main.java:171)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBContext
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:532)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:186)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:473)
    ... 2 more

This is because JAXB classes are not visible from the unnamed module by default

Workaround 1

Add the arguments --add-modules java.xml.bind to the java invocation. This suffices to launch OmegaT; it is unknown if all features work correctly (OS X integration definitely does not work; see below).

Note that these arguments cause Java 8 to fail, so they are not appropriate for addition to existing launch scripts, etc., as long as we are supporting Java 8.

Workaround 2

Bundle dependency JARs to replace the built-in java.xml.bind module. By experiment it seems that these three packages suffice to allow OmegaT to launch:

compile 'javax.xml.bind:jaxb-api:2.3.0'
compile 'org.glassfish.jaxb:jaxb-runtime:2.3.0'
compile 'javax.activation:activation:1.1.1'

Solution

The solution appears to be to modularize OmegaT and declare an explicit dependency on java.xml.bind in the module-info.java file.

There are many hurdles to clear before this can be done:

  • Modularization requires targeting Java 9. It is not clear if we can target both Java 8 and 9 at the same time, in which case targeting Java 9 requires dropping Java 8.
  • Tooling support is very immature at this stage: the most recent releases (as of 2017-9-24) of Eclipse and NetBeans do not support Java 9 out of the box; even with experimental Java 9 support, Eclipse does not appear to promote dependencies to automatic modules.
  • Gradle apparently does support modules to some degree, but following their guide reveals that many of OmegaT's dependencies are currently split packages, which likely means we must wait for them to produce properly modularized versions before we can modularize OmegaT.

See:

OS X integration failures

80246: Error: java.lang.IllegalAccessException: class org.omegat.util.gui.OSXIntegration cannot access class com.apple.eawt.Application (in module java.desktop) because module java.desktop does not export com.apple.eawt to unnamed module @6fd02e5

These APIs have been replaced entirely. We will have to add support for the new APIs as well, which we cannot do without targeting Java 9.

Workaround

It may be possible to create, as a separate project, a bridge that wraps the old and new APIs.

See:

Related

Feature Requests: #1436

Discussion

  • Aaron Madlon-Kay

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -14,22 +14,48 @@
        ... 2 more
     ```
    
    -This is because JAXB classes are not visible from the unnamed module by default. Supply the arguments `--add-modules java.xml.bind` to the VM as a workaround.
    +This is because JAXB classes are not visible from the unnamed module by default
    
    -To investigate: See if this dependency can be specified in a `module-info.java` file.
    +## Workaround 1
    +Add the arguments `--add-modules java.xml.bind` to the `java` invocation. This suffices to launch OmegaT; it is unknown if all features work correctly (OS X integration definitely does not work; see below).
    +
    +Note that these arguments cause Java 8 to fail, so they are not appropriate for addition to existing launch scripts, etc., as long as we are supporting Java 8.
    +
    +## Workaround 2
    +Bundle dependency JARs to replace the built-in `java.xml.bind` module. By experiment it seems that these three packages suffice to allow OmegaT to launch:
    +
    +```
    +compile 'javax.xml.bind:jaxb-api:2.3.0'
    +compile 'org.glassfish.jaxb:jaxb-runtime:2.3.0'
    +compile 'javax.activation:activation:1.1.1'
    + ```
    +
    +## Solution
    +The solution appears to be to modularize OmegaT and declare an explicit dependency on `java.xml.bind` in the `module-info.java` file.
    +
    +There are many hurdles to clear before this can be done:
    +
    +- Modularization requires targeting Java 9. It is not clear if we can target both Java 8 and 9 at the same time, in which case targeting Java 9 requires dropping Java 8.
    +- Tooling support is very immature at this stage: the most recent releases (as of 2017-9-24) of Eclipse and NetBeans do not support Java 9 out of the box; even with experimental Java 9 support, Eclipse does not appear to promote dependencies to automatic modules.
    +- Gradle apparently does support modules to some degree, but following their [guide](https://guides.gradle.org/building-java-9-modules/#modify_the_code_compilejava_code_task_to_produce_a_module) reveals that many of OmegaT's dependencies are currently [split packages](https://blog.codefx.org/java/java-9-migration-guide/#Split-Packages), which likely means we must wait for them to produce properly modularized versions before we can modularize OmegaT.
    
     See:
    
     - [java.corba and EE modules not resolved by default](http://mail.openjdk.java.net/pipermail/jdk9-dev/2016-May/004309.html)
     - [JEP 261: Module System](http://openjdk.java.net/jeps/261)
     - [Project Jigsaw: Quick Start Guide](http://openjdk.java.net/projects/jigsaw/quick-start)
    +- [Gradle: Building Java 9 Modules](https://guides.gradle.org/building-java-9-modules/#modify_the_code_compilejava_code_task_to_produce_a_module)
    +- [Java 9 Migration Guide](https://blog.codefx.org/java/java-9-migration-guide)
    
     # OS X integration failures
     ```
     80246: Error: java.lang.IllegalAccessException: class org.omegat.util.gui.OSXIntegration cannot access class com.apple.eawt.Application (in module java.desktop) because module java.desktop does not export com.apple.eawt to unnamed module @6fd02e5
     ```
    
    -These APIs have been replaced entirely. We will have to add support for the new APIs as well.
    +These APIs have been replaced entirely. We will have to add support for the new APIs as well, which we cannot do without targeting Java 9.
    +
    +## Workaround
    +It may be possible to create, as a separate project, a bridge that wraps the old and new APIs.
    
     See:
    
     
  • Aaron Madlon-Kay

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -28,7 +28,7 @@
     compile 'javax.xml.bind:jaxb-api:2.3.0'
     compile 'org.glassfish.jaxb:jaxb-runtime:2.3.0'
     compile 'javax.activation:activation:1.1.1'
    - ```
    +```
    
     ## Solution
     The solution appears to be to modularize OmegaT and declare an explicit dependency on `java.xml.bind` in the `module-info.java` file.
    
     
  • Aaron Madlon-Kay

    Java 10 has now been released. The same issues blocking Java 9 compatibility apply to 10 as well; it is not clear if 10 introduces additional issues.

     
  • khagaroth

    khagaroth - 2018-06-23

    So, considering the above, what's the plan for Java support after September when Java 8 gets EOL and Oracle releases Java 11 and fully switches to the new release cycle of a new Java version every 6 months (with LTS version evey 3 years, but only as a paid option)?

     
  • Aaron Madlon-Kay

    • assigned_to: Aaron Madlon-Kay
    • Group: future --> 4.1
     
  • Aaron Madlon-Kay

    • status: open --> closed-out-of-date
     
  • Aaron Madlon-Kay

    I am hoping to make OmegaT usable on Java 11 very soon. I'm closing this ticket as out-of-date in favor of [#1436].

     

    Related

    Feature Requests: #1436


Log in to post a comment.