ice1000 / jimgui

:sparkling_heart: Pure Java binding for dear-imgui
Apache License 2.0
185 stars 13 forks source link

[URGENT] JDK9: define a valid automatic module name #55

Closed aeris170 closed 3 years ago

aeris170 commented 3 years ago

JDK9 is out and introduces a module system.

Problem

jimgui does not currently use modules. When we use it in a JDK9 modular application, Java turns the JAR into a so-called automatic module, whose name is derived from the JAR archive name. However, the default name cannot be used in a requires directive because the jar itself is named in such a way that Java cannot strip the version number.

requires core.v0.9; raises the error Syntax error on token ".9", delete this token requires core.v0; (and any other alternative I've used) raises the error core.v0 cannot be resolved to a module

Proposed Solutions:

In order for jimgui to be useable with projects using JDK9+, it has to either rename the jar file or define a module name.

Rename the jar and let Java create an automatic module

Renaming the jar file in Maven/Gradle dependency platforms will solve the problem of Java not being able to require the jar, but it will possibly break the convention used so far. This solution is ill-advised.

Define a module name in the manifest

It is possible to specify a stable automatic module name through a Automatic-Module-Name manifest entry, while still targeting JDK8:

For example: Automatic-Module-Name: ice1000.jimgui

Selecting a stable module name is very important, because Java does not allow two modules to own the same package, and you may end up with a module hell. The naming issues are well-explained on Stephen Colebourne's blog:

http://blog.joda.org/2017/04/java-se-9-jpms-module-naming.html http://blog.joda.org/2017/05/java-se-9-jpms-automatic-modules.html <- the explanation of module hell problem

I will prepare a PR with the second proposed solution. Feel free to change the module name to whatever you find fit.

aeris170 commented 3 years ago

Please link this PR: https://github.com/ice1000/jimgui/pull/56

ice1000 commented 3 years ago

Please link this PR: #56

You can put a "Fix #55" into your PR description which will leads github to close this issue at the merging of #56