Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version reports SNAPSHOT on module-path #770

Closed
sormuras opened this issue Jun 13, 2022 · 2 comments · Fixed by #771
Closed

Version reports SNAPSHOT on module-path #770

sormuras opened this issue Jun 13, 2022 · 2 comments · Fixed by #771

Comments

@sormuras
Copy link
Contributor

sormuras commented Jun 13, 2022

Version

3.3.1

Platform

Linux x64, Linux arm64, Linux arm32, macOS x64, macOS arm64, Windows x64, Windows x86, Windows arm64

JDK

JDK 9+

Module

LWJGL Core

Bug description

Actual

java --module-path lib --add-modules org.lwjgl org.lwjgl.Version

3.3.1 SNAPSHOT
3.3.1

Expected

java --class-path lib/org.lwjgl.jar org.lwjgl.Version

3.3.1 build 7
3.3.1

This is due to the following specification in java.lang.Package

A Package automatically defined for classes in a named module has the following properties:

  • The name of the package is derived from the binary names of the classes. Since classes in a named module must be in a named package, the derived name is never empty.
  • The package is sealed with the module location as the code source, if known.
  • The specification and implementation titles, versions, and vendors are unspecified. ⬅️
  • Any annotations on the package are read from package-info.class as specified above.

Therefore Version.class.getPackage().getImplementationVersion() as used here returns null.

Notes

Note that the compiled module descriptors do contain the correct version information.

java --module-path lib --list-modules

...
org.lwjgl@3.3.1+7 file:///.../org.lwjgl.jar
org.lwjgl.glfw@3.3.1+7 file:///.../org.lwjgl.glfw.jar
org.lwjgl.glfw.natives@3.3.1+7 file:///.../org.lwjgl.glfw.natives.jar
org.lwjgl.natives@3.3.1+7 file:///.../org.lwjgl.natives.jar
org.lwjgl.opengl@3.3.1+7 file:///.../org.lwjgl.opengl.jar
org.lwjgl.opengl.natives@3.3.1+7 file:///.../org.lwjgl.opengl.natives.jar
sormuras added a commit to sormuras/lwjgl3 that referenced this issue Jun 13, 2022
@sormuras
Copy link
Contributor Author

sormuras commented Aug 9, 2022

Related to #644 - so, the new implementation proposed in

needs to be checked, whether it works in a native image as well.
Or, fall back to Version.class.getPackage().getImplementationVersion() in case a JAR file is not present.

Spasi pushed a commit to sormuras/lwjgl3 that referenced this issue Aug 24, 2022
- Package::getImplementationVersion is unspecified when loading a JAR
  file from the module path. The new multi-release code uses the module
  descriptor to retrieve the implementation version.
- Restored code that retrieves the implementation version from the JAR
  manifest, as a fallback. Also added the suggested fix from LWJGL#644, when
  running on a GraalVM native image.
- Changed the LWJGL version string to match the Java version format.

Close LWJGL#770

Co-authored-by: Leon Linhart <themrmilchmann@gmail.com>
Spasi pushed a commit to sormuras/lwjgl3 that referenced this issue Aug 24, 2022
- Package::getImplementationVersion is unspecified when loading a JAR
  file from the module path. The new multi-release code uses the module
  descriptor to retrieve the implementation version.
- Restored code that retrieves the implementation version from the JAR
  manifest, as a fallback. Also added the suggested fix from LWJGL#644, when
  running on a GraalVM native image.
- Changed the LWJGL version string to match the Java version format.

Close LWJGL#770

Co-authored-by: Leon Linhart <themrmilchmann@gmail.com>
Spasi pushed a commit that referenced this issue Aug 24, 2022
- Package::getImplementationVersion is unspecified when loading a JAR
  file from the module path. The new multi-release code uses the module
  descriptor to retrieve the implementation version.
- Restored code that retrieves the implementation version from the JAR
  manifest, as a fallback. Also added the suggested fix from #644, when
  running on a GraalVM native image.
- Changed the LWJGL version string to match the Java version format.

Close #770

Co-authored-by: Leon Linhart <themrmilchmann@gmail.com>
@Spasi
Copy link
Member

Spasi commented Aug 24, 2022

Thank you @sormuras!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants