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

Java 9 got released! #334

Closed
dustContributor opened this issue Sep 22, 2017 · 24 comments
Closed

Java 9 got released! #334

dustContributor opened this issue Sep 22, 2017 · 24 comments

Comments

@dustContributor
Copy link

So, how well LWJGL 3 plays with it and jigzaw? I remember @Spasi mentioning something about moving to VarHandles instead of relying on sun.misc.Unsafe. What would this entail?

@Spasi
Copy link
Member

Spasi commented Sep 23, 2017

LWJGL 3 works great on Java 9. You don't have to do anything special and it runs without --illegal-access warnings.

There are no JPMS modules, but the JARs include Automatic-Module-Name entries in their manifests. This should be good enough for users that want to make their projects modular. I don't think we'll do anything more involved with modules until LWJGL 4.

The other Java 9 feature in LWJGL is multi-release JAR files. The core library is such a JAR and it includes custom code that uses the new StackWalker API to improve performance when MemoryStack debugging is enabled.

something about moving to VarHandles instead of relying on sun.misc.Unsafe

Unfortunately java.lang.invoke.VarHandle is not a full replacement for sun.misc.Unsafe. The first problem is worse performance when accessing off-heap memory. The second is that the security mechanisms in VarHandle won't let you access private class details. This is required for a very simple, but also very critical, reason in LWJGL: to be able to instantiate direct buffers in Java code (see Strategy #3 in Memory Management in LWJGL 3 for more information).

sun.misc.Unsafe is a special case in Java 9. It is obviously not removed and there are no warnings for accessing it. There is now a more powerful but inaccessible Unsafe, used internally by the JDK itself, but the old Unsafe will remain public as long as there are so many projects using it. The plan is to get rid of it in LWJGL 4, but it all depends on when and in what form Project Panama becomes available.

@francogp
Copy link

It works for me, but I'm getting this warning when I use java 9 only:
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.lwjgl.system.MemoryAccess (file:/C:/Users/franc/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl/3.1.0/fae7a04425666311d5dfe5ef7d89021ca0308d8d/lwjgl-3.1.0.jar) to field java.nio.Buffer.address WARNING: Please consider reporting this to the maintainers of org.lwjgl.system.MemoryAccess WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

@TheMrMilchmann
Copy link
Collaborator

TheMrMilchmann commented Sep 26, 2017

@francogp This should already be fixed in more recent releases (starting from 3.1.1 as pointed out by @Spasi).

See e3879b2

@Spasi
Copy link
Member

Spasi commented Sep 26, 2017

@TheMrMilchmann indeed, LWJGL 3.1.1 and up should not produce a warning.

@francogp it looks like you're on 3.1.0, upgrading to the latest release is highly recommended.

@gudenau
Copy link
Contributor

gudenau commented Sep 29, 2017

It also appears as though it is not building correctly, but knowing me it is me screwing it up and not Java 9. .-.

Java version:
java version "9" Java(TM) SE Runtime Environment (build 9+181) Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

Here is what I did:

C:\Users\gudenau\Desktop\LWJGL3>git clone
C:\Users\gudenau\Desktop\LWJGL3>git clone https://github.com/LWJGL/lwjgl3.git
Cloning into 'lwjgl3'...
remote: Counting objects: 46118, done.
remote: Compressing objects: 100% (290/290), done.
remote: Total 46118 (delta 165), reused 288 (delta 91), pack-reused 45642
Receiving objects: 100% (46118/46118), 16.51 MiB | 4.10 MiB/s, done.
Resolving deltas: 100% (23877/23877), done.
Checking out files: 100% (1356/1356), done.

C:\Users\gudenau\Desktop\LWJGL3>cd lwjgl3

C:\Users\gudenau\Desktop\LWJGL3\lwjgl3>ant init
Buildfile: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml

init:
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\core\src\generated
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Core
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Generator
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Templates
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Tests
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\windows\x64

check-dependencies:
  [kotlinc] C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\libs\kotlinc\build.txt doesn't exist

update-dependencies:
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\libs

-lib-download:

-kotlinc-download:
  [kotlinc] Getting: https://github.com/JetBrains/kotlin/releases/download/v1.1.4/kotlin-compiler-1.1.4.zip
  [kotlinc] To: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\libs\kotlin-compiler-1.1.4.zip
  [kotlinc] https://github.com/JetBrains/kotlin/releases/download/v1.1.4/kotlin-compiler-1.1.4.zip moved to https://github-production-release-asset-2e65be.s3.amazonaws.com/3432266/76b69b30-8129-11e7-9006-d4debf387f70?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20170929%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20170929T182902Z&X-Amz-Expires=300&X-Amz-Signature=ab764e9097ac5c3c65ef2ebbb97f265711e152dba9bc0474d80e0484ba1d659f&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dkotlin-compiler-1.1.4.zip&response-content-type=application%2Foctet-stream
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ....................................................
  [kotlinc] ...................................................
  [kotlinc] Expanding: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\libs\kotlin-compiler-1.1.4.zip into C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\libs
  [kotlinc] Deleting: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\libs\kotlin-compiler-1.1.4.zip
  [kotlinc] The Kotlin compiler was updated to build: 1.1.4

BUILD SUCCESSFUL
Total time: 7 seconds

C:\Users\gudenau\Desktop\LWJGL3\lwjgl3>ant init
Buildfile: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml

init:

check-dependencies:

BUILD SUCCESSFUL
Total time: 0 seconds

C:\Users\gudenau\Desktop\LWJGL3\lwjgl3>ant init-generated
Buildfile: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml

init-generated:
    [input] The modules\core\src\generated directory contents will be replaced with a fresh clone of the lwjgl3-generated repository. Continue? (y, [n])
y
   [delete] Deleting directory C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\core\src\generated
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\core\src\generated
     [exec] Cloning into 'modules\core\src\generated'...
     [exec] Checking out files:  22% (501/2262)
     [exec] Checking out files:  23% (521/2262)   Checking out files:  24% (543/2262)   Checking out files:  25% (566/2262)   Checking out files:  26% (589/2262)   Checking out files:  27% (611/2262)   Checking out files:  28% (634/2262)   Checking out files:  29% (656/2262)   Checking out files:  30% (679/2262)   Checking out files:  31% (702/2262)   Checking out files:  32% (724/2262)   Checking out files:  33% (747/2262)   Checking out files:  34% (770/2262)   Checking out files:  35% (792/2262)   Checking out files:  36% (815/2262)   Checking out files:  37% (837/2262)   Checking out files:  38% (860/2262)   Checking out files:  39% (883/2262)   Checking out files:  40% (905/2262)   Checking out files:  41% (928/2262)   Checking out files:  41% (947/2262)   Checking out files:  42% (951/2262)   Checking out files:  43% (973/2262)   Checking out files:  44% (996/2262)   Checking out files:  45% (1018/2262)   Checking out files:  46% (1041/2262)   Checking out files:  47% (1064/2262)   Checking out files:  48% (1086/2262)   Checking out files:  49% (1109/2262)   Checking out files:  50% (1131/2262)   Checking out files:  51% (1154/2262)   Checking out files:  52% (1177/2262)   Checking out files:  53% (1199/2262)   Checking out files:  54% (1222/2262)   Checking out files:  55% (1245/2262)   Checking out files:  56% (1267/2262)   Checking out files:  57% (1290/2262)   Checking out files:  58% (1312/2262)   Checking out files:  59% (1335/2262)   Checking out files:  60% (1358/2262)   Checking out files:  61% (1380/2262)   Checking out files:  62% (1403/2262)   Checking out files:  62% (1422/2262)   Checking out files:  63% (1426/2262)   Checking out files:  64% (1448/2262)   Checking out files:  65% (1471/2262)   Checking out files:  66% (1493/2262)   Checking out files:  67% (1516/2262)   Checking out files:  68% (1539/2262)   Checking out files:  69% (1561/2262)   Checking out files:  70% (1584/2262)   Checking out files:  71% (1607/2262)   Checking out files:  72% (1629/2262)   Checking out files:  73% (1652/2262)   Checking out files:  74% (1674/2262)   Checking out files:  75% (1697/2262)   Checking out files:  76% (1720/2262)   Checking out files:  77% (1742/2262)   Checking out files:  78% (1765/2262)   Checking out files:  79% (1787/2262)   Checking out files:  80% (1810/2262)   Checking out files:  81% (1833/2262)   Checking out files:  82% (1855/2262)   Checking out files:  83% (1878/2262)   Checking out files:  84% (1901/2262)   Checking out files:  84% (1912/2262)   Checking out files:  85% (1923/2262)   Checking out files:  86% (1946/2262)   Checking out files:  87% (1968/2262)   Checking out files:  88% (1991/2262)   Checking out files:  89% (2014/2262)   Checking out files:  90% (2036/2262)   Checking out files:  91% (2059/2262)   Checking out files:  92% (2082/2262)   Checking out files:  93% (2104/2262)   Checking out files:  94% (2127/2262)   Checking out files:  95% (2149/2262)   Checking out files:  96% (2172/2262)   Checking out files:  97% (2195/2262)   Checking out files:  98% (2217/2262)   Checking out files:  99% (2240/2262)   Checking out files: 100% (2262/2262)   Checking out files: 100% (2262/2262), done.

BUILD SUCCESSFUL
Total time: 14 seconds

C:\Users\gudenau\Desktop\LWJGL3\lwjgl3>ant init-wiki
Buildfile: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml

init-wiki:
     [exec] Cloning into 'wiki'...

BUILD SUCCESSFUL
Total time: 1 second

C:\Users\gudenau\Desktop\LWJGL3\lwjgl3>ant compile-templates
Buildfile: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml

init:

check-dependencies:

-compile-generator:
[Generator] Compiling Kotlin generator...
  [kotlinc] Compiling [C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\generator\src\main\kotlin] => [C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Generator]
  [kotlinc] info: kotlinc-jvm 1.1.4 (JRE 1.8.0_144-b01)
  [kotlinc] info: PERF: INIT: Compiler initialized in 461 ms
  [kotlinc] info: PERF: ANALYZE: 18 files (8246 lines) in 13496 ms - 610.996 loc/s
  [kotlinc] info: PERF: GENERATE: 18 files (8246 lines) in 7471 ms - 1103.734 loc/s
  [kotlinc] info: PERF: GC time for PS Scavenge is 277 ms
  [kotlinc] info: PERF: GC time for PS MarkSweep is 505 ms
  [kotlinc] info: PERF: JIT time is 45158 ms
  [kotlinc] info: PERF: Find Java class performed 0 times
  [kotlinc] info: PERF: Type info performed 27155 times, total time 10660 ms
  [kotlinc] info: PERF: Call resolve performed 15813 times, total time 8239 ms
  [kotlinc] info: PERF: Binary class from Kotlin file performed 259 times, total time 70 ms
    [touch] Creating C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Generator\touch.txt
[javac: Generator Tools & Doclets] Compiling 5 source files to C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Generator

bindings:

compile-templates:
[Templates] Compiling Kotlin templates. This will take 1-2 minutes...
  [kotlinc] Compiling [C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\assimp, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\bgfx, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\egl, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\glfw, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\nanovg, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\nuklear, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\openal, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\opencl, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\opengl, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\opengles, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\openvr, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\stb, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\vulkan, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\dyncall, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\jawt, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\jemalloc, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\rpmalloc, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\jni, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\libc, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\linux, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\macosx, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\templates, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\system\windows, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\util\lmdb, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\util\nfd, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\util\par, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\util\simd, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\util\tinyexr, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\util\tinyfd, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\util\xxhash, C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\util\yoga] => [C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Templates]
  [kotlinc] info: kotlinc-jvm 1.1.4 (JRE 1.8.0_144-b01)
  [kotlinc] info: PERF: INIT: Compiler initialized in 253 ms
  [kotlinc] info: PERF: ANALYZE: 1032 files (168295 lines) in 48504 ms - 3469.714 loc/s
  [kotlinc] info: PERF: GENERATE: 1032 files (168295 lines) in 33655 ms - 5000.595 loc/s
  [kotlinc] info: PERF: GC time for PS Scavenge is 2585 ms
  [kotlinc] info: PERF: GC time for PS MarkSweep is 0 ms
  [kotlinc] info: PERF: JIT time is 45960 ms
  [kotlinc] info: PERF: Find Java class performed 0 times
  [kotlinc] info: PERF: Type info performed 278404 times, total time 53635 ms
  [kotlinc] info: PERF: Call resolve performed 144272 times, total time 45970 ms
  [kotlinc] info: PERF: Binary class from Kotlin file performed 528 times, total time 124 ms
  [kotlinc] C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\templates\src\main\kotlin\org\lwjgl\util\yoga\templates\yoga.kt:479:47: warning: parameter 'type' is never used
  [kotlinc]     fun YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO(type: NativeType, name: String) {
  [kotlinc]                                               ^
    [touch] Creating C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Templates\touch.txt

BUILD SUCCESSFUL
Total time: 1 minute 47 seconds

C:\Users\gudenau\Desktop\LWJGL3\lwjgl3>ant generate
Buildfile: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml

init:

check-dependencies:

bindings:

generate:
[Generator]     UPDATING: modules\core\src\generated\java\org\lwjgl\system\JNI.java
[Generator]     UPDATING: modules\core\src\generated\c\system\org_lwjgl_system_JNI.c

BUILD SUCCESSFUL
Total time: 2 seconds

C:\Users\gudenau\Desktop\LWJGL3\lwjgl3>ant generate
Buildfile: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml

init:

check-dependencies:

bindings:

generate:
[Generator]     UPDATING: modules\core\src\generated\java\org\lwjgl\system\JNI.java
[Generator]     UPDATING: modules\core\src\generated\c\system\org_lwjgl_system_JNI.c

BUILD SUCCESSFUL
Total time: 2 seconds

C:\Users\gudenau\Desktop\LWJGL3\lwjgl3>ant compile
Buildfile: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml

init:

check-dependencies:

bindings:

generate:

-init-compile:

compile:
[javac: Core] Compiling 1841 source files to C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Core
[javac: Core] C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\core\src\generated\java\org\lwjgl\util\tinyexr\EXRMultiPartHeader.java:292: error: sizeof() in Buffer cannot override sizeof() in CustomBuffer
[javac: Core]           protected int sizeof() {
[javac: Core]                         ^
[javac: Core]   attempting to assign weaker access privileges; was public
[javac: Core] C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\core\src\generated\java\org\lwjgl\util\tinyexr\EXRMultiPartImage.java:292: error: sizeof() in Buffer cannot override sizeof() in CustomBuffer
[javac: Core]           protected int sizeof() {
[javac: Core]                         ^
[javac: Core]   attempting to assign weaker access privileges; was public
[javac: Core] 2 errors

BUILD FAILED
C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml:364: Compile failed; see the compiler error output for details.

Total time: 24 seconds

C:\Users\gudenau\Desktop\LWJGL3\lwjgl3>ant compile-native
Buildfile: C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml

init:

check-dependencies:

bindings:

generate:

-init-compile:

compile:
[javac: Core] Compiling 304 source files to C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\bin\Core
[javac: Core] C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\core\src\generated\java\org\lwjgl\util\tinyexr\EXRMultiPartHeader.java:292: error: sizeof() in Buffer cannot override sizeof() in CustomBuffer
[javac: Core]           protected int sizeof() {
[javac: Core]                         ^
[javac: Core]   attempting to assign weaker access privileges; was public
[javac: Core] C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\modules\core\src\generated\java\org\lwjgl\util\tinyexr\EXRMultiPartImage.java:292: error: sizeof() in Buffer cannot override sizeof() in CustomBuffer
[javac: Core]           protected int sizeof() {
[javac: Core]                         ^
[javac: Core]   attempting to assign weaker access privileges; was public
[javac: Core] 2 errors

BUILD FAILED
C:\Users\gudenau\Desktop\LWJGL3\lwjgl3\build.xml:364: Compile failed; see the compiler error output for details.

Total time: 3 seconds```

Edit:
So nice that it does not have a vertical scroll bar. .-.

@Spasi
Copy link
Member

Spasi commented Sep 29, 2017

That's a problem with the lwjgl3-generated repository, the two EXRMultiPart* classes shouldn't be there. Remove them (or run ant clean-generated), try again and it should work.

Btw, the targets init-generated and init-wiki are optional. The former is useful when developing bindings and the latter if you're interested in contributing to the wiki.

@gudenau
Copy link
Contributor

gudenau commented Sep 29, 2017

I understand that those are optional, figured it would be best to do those just in case.

@dustContributor
Copy link
Author

Unfortunately java.lang.invoke.VarHandle is not a full replacement for sun.misc.Unsafe. The first problem is worse performance when accessing off-heap memory. The second is that the security mechanisms in VarHandle won't let you access private class details.

Ahh that sucks. Well at least with the 6 month release cycle we might get Panama sooner, I hope.

The other Java 9 feature in LWJGL is multi-release JAR files. The core library is such a JAR and it includes custom code that uses the new StackWalker API to improve performance when MemoryStack debugging is enabled.

Multi-release JARs are pretty cool, I didn't know about them. On the other hand, StackWalker API was long overdue. Makes no sense hoping the JIT works it's magic when you only want to traverse a single stack level to find the calling method name rather than printing the whole stack trace.

Thanks for your answer! Do we close this then? Or leave it open for any other Java 9 questions people might have?

@Spasi
Copy link
Member

Spasi commented Oct 1, 2017

Do we close this then? Or leave it open for any other Java 9 questions people might have?

Lets keep it open for a while.

The latest 3.1.4 snapshot (build 3) has a change that fixes the SharedLibraryLoader when all LWJGL binaries are added to the module path (as automatic modules). See here for more information.

Also, all natives JARs now have a manifest, with an automatic module name similar to the corresponding binding (e.g. org.lwjgl.glfw and org.lwjgl.glfw.natives.windows). This makes --list-modules cleaner for example.

@gudenau
Copy link
Contributor

gudenau commented Oct 1, 2017

Will there be support for those multi-jar things to allow one native jar file?

@Spasi
Copy link
Member

Spasi commented Oct 2, 2017

Will there be support for those multi-jar things to allow one native jar file?

Not sure what you mean exactly. Multi-release JAR files allow you to have a class multiple times, implemented differently for different Java versions.

There's no technical issue with having all natives in one JAR file. They are in different files to avoid excessive download times (you only need 1/3 of them on a given system). If necessary, they can be recombined in whatever way makes sense for the application that uses LWJGL.

@gudenau
Copy link
Contributor

gudenau commented Oct 2, 2017

I guess I mis-read, thought you could do resources and code per-platform with those. My mistake.

@Spasi
Copy link
Member

Spasi commented Oct 7, 2017

I've been experimenting with modules in another project and found an important problem with automatic modules; the jlink tool cannot use them to create a custom run-time image. The entire project must be contained in explicit modules.

It is possible to add module-info to a non-modular jar. I used the ModiTect maven plugin, it's simple and it works, but it's a massive pita if you have lots of dependencies (all transitive dependencies must be fixed too).

Using jlink won't be critical for a lot of projects, but I think projects using LWJGL (e.g. games) will be very interested in having a compact runtime (or using AOT compilation in the future). I'll try to make the build produce binaries with automatic modules when building on Java 8 and with explicit modules when building on Java 9+.

Spasi added a commit that referenced this issue Oct 24, 2017
This enables applications using LWJGL to be bundled in custom run-time images with the jlink tool.
@Spasi
Copy link
Member

Spasi commented Oct 25, 2017

The latest 3.1.4 snapshot (build 5) has replaced Automatic-Module-Name with explicit JPMS modules. LWJGL can now directly participate in jlink builds, assuming your other dependencies are also explicitly modular.

Technical details

LWJGL classes continue to be compiled with Java 8 and all jars are Java 8 compatible. The above change adds a module-info.class to the jar file root, that has been compiled with Java 9 and describes the module. The Java 8 run-time will simply ignore it, as there's nothing that attempts to load that class file, but please report any issues that tools/IDEs/etc might have with it.

The LWJGL module definitions can be found here. It is not valid Java code, these files would normally be called module-info.java in the appropriate folder of a modular code base. We don't want to refactor LWJGL to do that now, so there's a tool that uses them to generate the corresponding module-info.class. Notes:

  • Modules are named: org.lwjgl for the LWJGL core and org.lwjgl.<binding> for everything else. Note that the module name does not necessarily match the package of the binding (e.g. the LMDB classes are in the org.lwjgl.util.lmdb package, but the module is named org.lwjgl.lmdb).
  • Every binding module has a transitive dependency to org.lwjgl.
  • Every module with natives has a transitive dependency to the corresponding org.lwjgl.<binding>.natives module.
  • Native modules for a binding have the same name, regardless of platform.

Example

Assuming the LWJGL jars have been downloaded to lwjgl3/ and you want to run a non-modular application, compiled to bin/, that uses GLFW & OpenGL, you can do so with:

java --module-path lwjgl3 --add-modules org.lwjgl.glfw,org.lwjgl.opengl --class-path bin <main-class> <args>

Notes:

  • Because of requires transitive in the module definitions, you only need to add org.lwjgl.glfw and org.lwjgl.opengl. Everything else is resolved automatically, including the natives.
  • Because all native modules for a binding have the same name, the lwjgl3/ folder cannot contain native jars for more than 1 platform. For example, having both lwjgl-glfw-natives-linux.jar and lwjgl-glfw-natives-windows.jar in lwjgl3/ would result in an error when the application is launched.

@Spasi
Copy link
Member

Spasi commented Nov 19, 2017

No further issues related to Java 9 have been reported, so I'm closing this. Thanks everyone!

@Spasi Spasi closed this as completed Nov 19, 2017
@philipguin
Copy link

philipguin commented Dec 22, 2017

So I may be missing something here, but I'm attempting to modularize a previously working project in Eclipse Oxygen 4.7.2, with Java 9 and LWJGL 3.1.5 stable, and am receiving this message (with org.lwjgl.util.DebugLoader=true and org.lwjgl.util.Debug=true)

[LWJGL] Version: 3.1.5 build 1
[LWJGL] 	 OS: Windows 10 v10.0
[LWJGL] 	JRE: 9.0.1 amd64
[LWJGL] 	JVM: Java HotSpot(TM) 64-Bit Server VM v9.0.1+11 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL] 	lwjgl.dll not found in java.library.path
[LWJGL] Failed to load a library. Possible solutions:
	a) Add the directory that contains the shared library to -Djava.library.path or -Dorg.lwjgl.librarypath.
	b) Add the JAR that contains the shared library to the classpath.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to locate library: lwjgl.dll
	at org.lwjgl/org.lwjgl.system.Library.loadSystem(Library.java:146)
	at org.lwjgl/org.lwjgl.system.Library.loadSystem(Library.java:66)
	at org.lwjgl/org.lwjgl.system.Library.<clinit>(Library.java:49)
	at org.lwjgl/org.lwjgl.system.MemoryAccessJNI.<clinit>(MemoryAccessJNI.java:13)
	at org.lwjgl/org.lwjgl.system.Pointer.<clinit>(Pointer.java:22)
	at org.lwjgl/org.lwjgl.system.Platform.mapLibraryNameBundled(Platform.java:80)
	at org.lwjgl.glfw/org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:642)
	at phil.glfw/phil.glfw.GlfwDisplayManager.<init>(GlfwDisplayManager.java:196)
	at cafun/main.CaMain.startApp(CaMain.java:24)
	at cafun/main.CaMain.main(CaMain.java:16)

Generated command line (sanitized slightly):
javaw.exe -Dorg.lwjgl.util.DebugLoader=true -Dorg.lwjgl.util.Debug=true -Dfile.encoding=Cp1252 -p <workspace_path>\CellularAutomataFun\bin;<workspace_path>\PhilMath\bin;<workspace_path>\Uphilities\bin;<libs_path>\trove-3.1a1\3.1a1\output\lib\trove-current.jar;<workspace_path>\GameCommon\bin;<workspace_path>\PhilInput\bin;<workspace_path>\PhilGlfwInput\bin;<libs_path>\lwjgl\3.1.5\lwjgl-glfw-natives-linux.jar;<libs_path>\lwjgl\3.1.5\lwjgl-glfw-natives-macos.jar;<libs_path>\lwjgl\3.1.5\lwjgl-glfw-natives-windows.jar;<libs_path>\lwjgl\3.1.5\lwjgl-glfw.jar;<libs_path>\lwjgl\3.1.5\lwjgl-natives-linux.jar;<libs_path>\lwjgl\3.1.5\lwjgl-natives-macos.jar;<libs_path>\lwjgl\3.1.5\lwjgl-natives-windows.jar;<libs_path>\lwjgl\3.1.5\lwjgl.jar;<workspace_path>\PhilGl\bin;<libs_path>\jdom\2.0.6\jdom.jar;<libs_path>\lwjgl\3.1.5\lwjgl-egl.jar;<libs_path>\lwjgl\3.1.5\lwjgl-opengl-natives-linux.jar;<libs_path>\lwjgl\3.1.5\lwjgl-opengl-natives-macos.jar;<libs_path>\lwjgl\3.1.5\lwjgl-opengl-natives-windows.jar;<libs_path>\lwjgl\3.1.5\lwjgl-opengl.jar;<libs_path>\lwjgl\3.1.5\lwjgl-opengles-natives-linux.jar;<libs_path>\lwjgl\3.1.5\lwjgl-opengles-natives-macos.jar;<libs_path>\lwjgl\3.1.5\lwjgl-opengles-natives-windows.jar;<libs_path>\lwjgl\3.1.5\lwjgl-opengles.jar;<libs_path>\lwjgl\3.1.5\lwjgl-stb-natives-linux.jar;<libs_path>\lwjgl\3.1.5\lwjgl-stb-natives-macos.jar;<libs_path>\lwjgl\3.1.5\lwjgl-stb-natives-windows.jar;<libs_path>\lwjgl\3.1.5\lwjgl-stb.jar;<libs_path>\lwjgl\3.1.5\lwjgl-vulkan.jar -m cafun/main.CaMain

Basically, imagine I have two projects, "GameProject" and "LwjglProject," both of which are modules compiled with Java 9. In Eclipse terminology, underneath Project Properties -> Java Build Path, LwjglProject includes the appropriate LWJGL jars on its "Modulepath" under "Libraries," and exports all of them under "Order and Export." Meanwhile, GameProject requires LwjglProject on its Modulepath under "Projects," and requires the LwjglProject module in its module-info.java. Running this configuration produces the above error message, I'm guessing because LWJGL is searching whatever "Classpath" is funneled into rather than wherever Modulepath goes.

Throwing everything into the Classpath isn't a great option for a number of reasons (firstly because I'd like to use jlink to create a compressed runtime image for my project, secondly because Eclipse chokes even harder when I attempt to do so (projects fail to import anything from modules placed on the classpath, weirdly), which is probably an issue on their end. Eclipse is giving me a lot of dang issues with this.)

If this isn't a bug an your end, then any ideas would still be greatly appreciated. Thank you!

@Spasi
Copy link
Member

Spasi commented Dec 22, 2017

I'm not familiar with Eclipse so I cannot advise about the project setup.

You could try running the generated command line manually, with --validate-modules. It should provide enough hints to help you resolve the issue. Note that you don't have to specify each LWJGL jar individually in -p, using <libs_path>/lwjgl/3.1.5 should be enough.

Unless demonstrated otherwise, there are no bugs related to JPMS in LWJGL. We even have applications in production running via jlinked images using LWJGL. Btw, jlink requires everything to be in the module path, in explicit modules (Automatic-Module-Name does not work). So there are no shortcuts taken and usually the problem is other libraries that have not been modularized, not LWJGL.

@philipguin
Copy link

philipguin commented Dec 22, 2017

Ahah!

I ran with --validate-modules as you described, and discovered that the different natives jars were "shadowing" each other. Removing all native jars except the ones for the current system from the modulepath resolved it (though that was definitely working before modularizing things, not sure what the intended behavior actually is.)

Thanks much, never would have guessed that without that command line option.

@Spasi
Copy link
Member

Spasi commented Jan 12, 2018

Looks like native modules must be required explicitly after #363. Before:

require org.lwjgl;
require org.glfw;
require org.opengl;

After:

require org.lwjgl;
require org.lwjgl.natives;
require org.lwjgl.glfw;
require org.lwjgl.glfw.natives;
require org.lwjgl.opengl;
require org.lwjgl.opengl.natives;

Compilation works without the native modules, but:

  • IntelliJ does not add them to the runtime module path, unless explicitly required.
  • jlink does not add them to the image, unless explicitly required. Manually adding them with --add-modules fails too.

Given the above, using requires static <natives module> in Java modules doesn't do anything useful. We could do the opposite though:

  • Remove requires static <natives module> from the Java module.
  • Add requires transitive <java module> to the natives module.

That way the native modules remain optional, but if used, the above example becomes:

require org.lwjgl.natives;
require org.glfw.natives;
require org.opengl.natives;

and everything resolves nicely in both javac and jlink/IDEs.

@Spasi Spasi reopened this Jan 12, 2018
@TheMrMilchmann
Copy link
Collaborator

TheMrMilchmann commented Jan 13, 2018

  • jlink does not add them to the image, unless explicitly required. Manually adding them with --add-module fails too.

I'm not quite sure what you mean here. What exactly fails? (btw: The option is called --add-modules. I assume this is just a typo though.)

For me the following is working perfectly fine:
Example

(I'm fully aware that those are not the actual modules but the behaviour should theoretically be the same.)

@Spasi
Copy link
Member

Spasi commented Jan 13, 2018

I tested again using --add-modules and jlink indeed adds the natives module to the image (it is listed in java --list-modules). However, the natives are not resolved when the application runs. I just figured out that if you do java --add-modules <native modules>, then it works.

My argument is that even though the current setup is technically correct, it is not very helpful. You need to worry about lwjgl3 natives when running jlink (which is not trivial in the first place) and also when running the output image.

@philipguin
Copy link

philipguin commented Jan 13, 2018 via email

@Spasi
Copy link
Member

Spasi commented Jan 15, 2018

@philipguin Isn't there a ProGuard option to ignore module-info.class when obfuscating?

@Spasi
Copy link
Member

Spasi commented Jan 25, 2018

The latest 3.1.6 snapshot (build 11) includes the following changes:

A natives module now has a transitive dependency to the corresponding Java module.

As described above, this fixes applications that deploy shared libraries in a custom way. Such an application would declare:

require org.lwjgl;
require org.lwjgl.glfw;
require org.lwjgl.opengl;
// ...
require org.lwjgl.vulkan;

and then use a custom classpath or library path when launching the application.

Applications that need to ensure that the natives are in the module path, again declare one line per binding (like on LWJGL 3.1.5), but with the .natives suffix. For example:

require org.lwjgl.natives; // read as: "org.lwjgl with natives", org.lwjgl will be resolved by the transitive dependency
require org.lwjgl.glfw.natives;
require org.lwjgl.opengl.natives;
// ...
require org.lwjgl.vulkan; // the Vulkan bindings do not have natives

Warning to Maven users:

Maven tries to produce an appropriate --module-path when compiling a modular project. Unfortunately it does not honor transitive dependencies and compilation will fail if they are not explicitly declared. This is not an issue with LWJGL or javac, but a Maven bug. It has not been fixed as of 3.5.3-SNAPSHOT-20171222.

module-info.class is now stored under META-INF/version/9/

That means that all LWJGL jars are now multi-release JAR files. It should hopefully eliminate issues with tools that do not support Java 9 yet, like @philipguin describes above.

Java 9 sources are also stored under META-INF/version/9/

This currently includes module-info.java files and StackWalkUtil.java in the core module. I'm not sure if that's the official way to include multi-release sources in a sources JAR file (IntelliJ IDEA for example is not able to resolve them). But I couldn't find any information about it and I guess it's better than not shipping those sources at all.

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

No branches or pull requests

6 participants