brettwooldridge / NuProcess

Low-overhead, non-blocking I/O, external Process implementation for Java
Apache License 2.0
710 stars 84 forks source link

Add Java 9/JPMS module support #116

Open thekalinga opened 3 years ago

thekalinga commented 3 years ago

Currently even latest version 2.0.1 of the library does not have support for java modules. Since this is a utility, its will everyone who want to use this with JPMS modules post Java-9

thekalinga commented 3 years ago

As of now temporarily using gradle's plugin to create a module-info.java module with the following info

plugins {
    java
    id("de.jjohannes.extra-java-module-info") version "0.1"
}

extraJavaModuleInfo {
    module("nuprocess-2.0.1.jar", "com.zaxxer.nuprocess", "2.0.1") {
        exports("com.zaxxer.nuprocess")

        requires("com.sun.jna")
    }
}

And the plugin automatically generates the following module-info.class as part of the build process

open module com.zaxxer.nuprocess {
  requires java.base;
  requires com.sun.jna;

  exports com.zaxxer.nuprocess;
}
bturner commented 1 year ago

2.0.4 will add Automatic-Module-Name to the manifest, which should get you at least part of the way there. I'll need to do a little more investigation on what my options are for retaining Java 8 support (technically Java 7, but it's pretty difficult to actually build this library with that) while introducing full module support. Further progress on this may need to wait for a NuProcess 3.0 that drops support for Java 8.

It's worth noting that, unfortunately, workarounds like this don't work for NuProcess because it uses java.nio.ByteBuffer and there are binary-incompatible return type changes to methods on that class. That means if you compile NuProcess with Java 9+, even targeting Java 8 bytecode, the result is broken on Java 8 (see #128). To get a NuProcess jar that works correctly with Java 8, it must actually be compiled with Java 8.