Skip to content

Fully support modular applications by providing module-info.java #284

@RobinPlatt

Description

@RobinPlatt

Agrona as-is does not work in java applications which make full use of the java 9 module system -- i.e. applications where the main file is in a module with a module-info.java. This is because agrona does not depend on the jdk.unsupported module, which is necessary in order to access the Unsafe class. An automatic module name is not sufficient to resolve this, by design of the JDK.

We have for some time been using Agrona with an internal build in which the jar is modified and a module-info.java added, which looks like this:

module org.agrona.core {

    requires java.compiler;
    requires java.management;
    requires jdk.unsupported;

    exports org.agrona;
    exports org.agrona.concurrent;
}

Which is great news, it means Agrona can fully support the Java Platform Module System. It could prove useful to others if Agrona provided the module-info.java itself.

Java has multi-version capability of jars so it should be possible to provide the module-info.java without breaking Java 8 compatibility (this is pretty much the main use case of multi-version jars). However, we didn't need to do this, since we only needed the jar to work with JDK 11+. It should be possible, to do the multi-version approach with Gradle: https://stackoverflow.com/questions/47648533/how-to-make-multi-release-jar-files-with-gradle.

Exporting the above two packages was sufficient for our needs. Presumably a number of the other packages are intended as public apis, and should be added, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions