Custom Primitives?

David Holmes david.holmes at oracle.com
Tue Feb 22 01:43:08 UTC 2022


Hi Scott,

Please take this to valhalla-dev at openjdk.java.net to discuss.

Thanks,
David

On 22/02/2022 11:40 am, Scott Morgan wrote:
> Hi All,
> 
>     I've been messing around with some data structures / arrays lately and I
> am wondering if Java will ever have custom primitives, and if those
> custom primitives could contain optional pointers in some way.  I have
> found a number of similar things Value Classes,
> https://openjdk.java.net/jeps/401
> Primitive Value Classes, etc, but I'm really looking for something a little
> lower level.
> 
> Ideally I would like to store an array (with a single pointer pointing at
> it) of one boolean and one optional pointer / reference, in a primitive
> array structure to reduce the space of the null pointers.
>     However this creates some obvious problems as length of the boolean only
> could be one bit and the boolean + the pointer / reference could be 8 bytes
> and one bit (on 64 bit JVMs).  Without the fixed length size of the
> primitive, I imagine that the mapping to bytes and array indexes would be
> quite challenging & slow.  However I have a gut feeling that something like
> this path must be possible.
> 
> Are there any plans to solve problems like these in the current JEPs?
> Is anyone doing similar research?
> 
> Cheers,


More information about the discuss mailing list