On 5/30/21 5:19 PM, John Neffenger wrote:
On 5/19/21 1:17 PM, Ty Young wrote:
Biggest things for JavaFX that I can think of is jextract, a tool for
generating Java headers from a C header, and having all binding code
written in Java.
JavaFX has been doing its own manual form of Project Panama since
2014. Look for the string "extends C.Structure" in the following two
files:
https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MX6Cursor.java
https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/EPDSystem.java
In both cases, the technique was used to let JavaFX bypass the header
file 'mxcfb.h' from NXP (formerly Freescale).
I'm looking forward to replacing those hard-coded offsets with the
tools from Project Panama. In fact, I'm hopeful that Project Panama
will let me remove all of the native C code from the Monocle EPD
platform.
Now that you pointed it out, JavaFX uses SecurityManager:
https://github.com/openjdk/jfx/blob/5e6d4429159e3fab9ec0aab9720393850d179710/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/C.java#L40
Which is being deprecated. Panama has its own runtime flag to enable
native access not tied to SecurityManager.
The C class native implementation can be replaced with Panama easily. A
MemorySegment can be viewed using a ByteBuffer via:
MemorySegment segment = MemorySegment.allocateNative(8,
ResourceScope.newImplicitScope());
ByteBuffer buffer = segment.asByteBuffer();
asByteBuffer() doc says it wraps the MemorySegment, so I'm guessing it
has a strong reference and memory is freed once the buffer and segment
are no longer referenced.
If someone wanted to try swapping out JavaFX's native implementation
with Panama, this would be a good place to start IMO.
John