Reference pointers in compact value objects (primitive classes)

Glavo zjx001202 at gmail.com
Tue Apr 25 14:05:57 UTC 2023


>
> Meanwhile, I have another question about nullable object
> representation in value classes: Suppose we have
> Optional<Optional<Optional<String>>>, what will the representation be?
> How will we distinguish Optional.empty() with
> Optional.of(Optional.empty())?
>

To my knowledge, value objects as fields are usually not inlined, so
the representation of Optional.of(Optional.empty()) in heap remains the
same as it is now.

If you want a field to be inlined, its class should be a primitive class.
Value objects are usually only inlined when used as local variables.

Glavo

On Tue, Apr 25, 2023 at 9:39 PM - <liangchenblue at gmail.com> wrote:

> Hello,
> I just wonder if nullable reference pointers can be part of compact
> value objects.
>
> For instance, in the Classfile API, there is StackMapGenerator.Type, a
> record with (int type, ClassDesc reference, int bci). The default
> state (0, null, 0) is valid and a desirable default (0 type means
> top-type). If the ClassDesc field can be part of the compact
> representation, then the whole structure can be optimized, which looks
> promising to me.
>
> Meanwhile, I have another question about nullable object
> representation in value classes: Suppose we have
> Optional<Optional<Optional<String>>>, what will the representation be?
> How will we distinguish Optional.empty() with
> Optional.of(Optional.empty())?
>
> Thanks,
> Chen Liang
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-dev/attachments/20230425/9e0b6b9b/attachment.htm>


More information about the valhalla-dev mailing list