Foreign memory access with classes

Red IO redio.development at gmail.com
Tue Nov 8 06:52:32 UTC 2022


I just had a crazy idea on how to make foreign memory access work and feel
like java native class member access.
The idea is that you define special classes maybe with an interface or a
special class keyword. This class can then be "constructed" using a
MemorySegment being bound by its special and temporal bounds. The object
would be either null or every memory access throws an exception when the
bounds are breached. The class would be implicitly final and would extend a
class Native.
This could look something like this :

//c struct
typedef struct {
int x;
int y;
} Point;

//java native class
public native class Point {

int x;
int y;

//implicit and forced private constructor
//normal creation would make things difficult
}

MemorySegment data =... //native memory
Point p = data.object(Point.class);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20221108/dffa4441/attachment.htm>


More information about the panama-dev mailing list