JUnion 1.2.x - Struct Types, Feedback Welcome


#1

Hi :slightly_smiling_face:, it was already over a year ago since I posted an update about Project JUnion - Struct Types for Java

I would definitely like to hear your feedback :slightly_smiling_face:

  • After almost a complete redesign of the system, one can now allocate structs on heap, off-heap and stack.
  • Then one can retrieve the underlying primitive array/Buffer
  • As a link between user code and ram is the Bridge interface. DefaultBridge uses Unsafe to read/write memory. It would be interesting to not depend on Unsafe. From Java 9+ eg VarHandleBridge could be implemented which uses VarHandles instead and then let the user choose.
  • StructList [WIP] data structure - resizable struct array
  • Currently all structs use native byte order (primitive Java arrays use native byte order too afaik), support for other byte order can be added
  • Currently all structs use aligned memory access, adding an annotation to mark a struct as unaligned can be added as well, thou unaligned access will be slower

JUnion 1.2.2 Early Access: https://github.com/TehLeo/junion/releases

Since this is early access, expect bugs (eg. StructList is not finished yet).
To make this library actually usable, I think the next stage will be to write detailed test cases. Afterwards, a test project/library to really test it out would be nice. Eg. could write basic vector, quaternion, matrix lib with structs and then have fun with micro benchmarking it against existing Java object math libraries :smiley: Or another use case would be to write Java ECS with structs :slight_smile: .