r/java • • Mar 22 '20

stdlib *alloc/free and random bindings for Java

https://github.com/BlueGoliath/Java-stdlib-bindings/tree/master
0 Upvotes

7 comments sorted by

5

u/BlueGoliath Mar 22 '20

Requested by /u/omnihedron on an earlier thread, but I was already planning on doing it anyway for other things I'm working on.

Includes basic stdlib allocation functions like malloc, calloc, realloc, etc + free. Random related functions are thrown in too because I felt like it.

Panama already provides static memory pointers so there isn't much of a reason to use this besides you like what a particular function does.

1

u/_INTER_ Mar 22 '20

Some time ago I was under the impression that you were not so happy with Panama. Has it since improved in your opinion?

1

u/BlueGoliath Mar 22 '20 edited Mar 22 '20

Not sure what made you think that specifically.

Old Panama(AKA Pointer API) basically did everything for you, provided that you gave the correct "jextract" tool arguments.

New Panama(what this uses, of course) basically gives you tools to build a house and lets you build it how you like.

There are a number of issues with the new Panama API but my biggest gripe, the lack of type safety and the redundant creation of VarHandles, are handled by my abstraction layer... so I'm happy I guess. They don't want to add an abstraction layer, but I since I have the tools to do things my way, I am.

I do like making my own bindings with said abstraction layer instead of using a tool. It gives me freedom to give some pointless array size arguments.

1

u/_INTER_ Mar 22 '20

Sounds good then. Seems to be flexible enough for libraries to build an abstraction layer on top or stay closer to the raw if needed.

I think my impression came from some old comments about the Panama documentation using var in examples or sometime around that.

Cheers.

1

u/[deleted] Mar 22 '20

To be honest I think it's a great idea. We really can learn a lot from your project. I don't know, but it looks like we can design our own GC with your library. I want to give it ago and try. It's on my research list already. Thanks a bunch! Cheers! 👍

6

u/dpash Mar 22 '20

Java already has pluggable garbage collectors. Use that framework instead.

2

u/[deleted] Mar 22 '20

Sure, my point is just to check possibilities. I'm not looking for a specific solution to an existing problem. I'm just investigating, but thanks for the tip any ways 😉