objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

Support the Java module system (JPMS)

Open Burtan opened this issue 5 years ago • 16 comments

Any plans to support Java Platform Module System (JPMS)? Currently I get errors on a minimal gradle kotlin jpms example and I couldn't find any documentation on jpms with objectbox. It's finally pushed with future gradle versions. So it would be nice to add support :-).

Burtan avatar Mar 28 '20 11:03 Burtan

Thanks for bringing this to our attention.

Notes:

  • Gradle support for the Java module system is in 4.6 nightlies, so not stable, yet.
  • This has nothing to do with Android (which is currently the main focus of the Java/Kotlin libraries).

Edit: also not documented, yet. And more links:

  • https://github.com/square/okhttp/pull/3743
  • https://blog.joda.org/2017/05/java-se-9-jpms-automatic-modules.html

greenrobot-team avatar Mar 30 '20 08:03 greenrobot-team

Any update on a time schedule for this? Or is this on low priority?

Burtan avatar May 22 '20 14:05 Burtan

Are the prerequisites (e.g. Gradle) now in place (cc @greenrobot-team)?

greenrobot avatar May 22 '20 14:05 greenrobot

At least Gradle 6.4 is released.

Burtan avatar May 23 '20 11:05 Burtan

Yes, as far as I can tell.

  • So to do this our Java and Android libraries should not ship code in the same package, which is disallowed with the module system, no? Edit: via #1163, the java and java-api JAR also contain overlapping packages.

  • Then add the "Automatic-Module-Name" MANIFEST.MF entry with the future module name.

  • Also, all dependencies should be modularized and have an automatic module name? Quoting jodastephen:

    Do not release to Maven Central a modular jar file that depends on an automatic module, unless the automatic module has an "Automatic-Module-Name" MANIFEST.MF entry.

    If this is true, we need to migrate away from com.google.code.findbugs:jsr305. Unsure about other dependencies (e.g. essentials and flatbuffers will be runtime only).

greenrobot-team avatar May 26 '20 08:05 greenrobot-team

One more thing to keep in mind. Android does not support JPMS and it relies on byte code < JDK8. So libraries have to compile the java-module.info file with JDK9+ and the rest with JDK8. Java-Modularity plugin for gradle might help.

Burtan avatar May 26 '20 12:05 Burtan

Is this addressed with Objectbox 3.0.0+?

Burtan avatar Nov 04 '20 20:11 Burtan

Any news on this? Meanwhile gradle 6.8.1 enables module support by default.

Burtan avatar Jan 17 '21 20:01 Burtan

No updates because there are no updates :)

greenrobot-team avatar Jan 18 '21 09:01 greenrobot-team

I tried to get ObjectBox 3.0.0-alpha2 working with JPMS. It is better than 2.x.x because io.objectbox.converter is no longer split across two packages (java and java-api). I was able to generate module names using this plugin id("de.jjohannes.extra-java-module-info") version "0.3" However, the objectbox gradle plugins makes all modules fail.

/.../src/main/java/module-info.java:2: error: module not found: kotlin.stdlib
    requires kotlin.stdlib;

If the gradle errors are fixed I think Objectbox 3.0.0-alpha2 could be used with JPMS without too much trouble. If it helps I could create an example repo on github.

Burtan avatar Feb 12 '21 15:02 Burtan

any update on this ?

kinsleykajiva avatar May 26 '22 20:05 kinsleykajiva