To make the long story short, after java 11, the ReflectionAllocator keeps breaking again and again! (At least it does on Linux, I do not know about Windows or Mac)
SEVERE: Buffer cannot be destroyed: java.nio.DirectFloatBufferU
By a glance at this class source code, you can see the code smells!
with java 11+ we are required to add this VM option to fix it
"--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED"
but it broke up again in java 16+, which now requires also adding:
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED"
I do not know when it will break again.
But should we expect developers to know about this and add them? I believe not!
Lwjgl3 already has its own native allocator, and thanks to the contribution from @Pavl_G, Android now has its own native allocator in the JME 3.6 too. Leaving out iOS, only lwjgl2 now uses ReflectionAllocator.
With the behind the scene works that we have done on preparing lwjgl2 to run on java 11+ on Linux, the ReflectionAllocator is the only barrier left I believe.
I am proposing to deprecate ReflectionAllocator and make the PrimitiveAllocator
the default one, which will let the GC clean the buffers on lwjgl2. I believe this is no more a concern in today’s java, especially with the arrival of ZGC and Shenandoah GC.
If someone has any feedback or concerns about this please let me know here before it is too late!
Edit:
Here is the test case if you want to try it with java 11+
Regards