further to Stephen's thoughts on Value Objects
twhitmore.nz at gmail.com
Mon Jan 5 23:16:33 UTC 2015
Hi Stephen, people,
Just one further thought about Value Objects -- Stephen's objection was in
regard to repeated boxing in/out of API.
> Consider an OSS library released for
> JDK8 that has a method process(Object). The intent is that the method
> accepts anything, we don't care what the type is. When used with
> JDK10/11 it still accepts anything, except that instead of a small,
> known number of types being boxed (for which the library might have a
> process(int) overload, there are now *lots* of boxing operations.
I'm not a VM expert, but I understand that locality is the main issue in
terms of memory performance. Would it be possible for the 'Value Object
boxes' to just hold a pointer to the original Value Object struct, to
retain locality & avoid copying?
This would still incur cost of creating a box, but keep the benefit of
I did look at Albert Noll's report on heisenboxing, and it sounds good --
I'd support formally sidelining or eliminating identity for primitive
wrappers -- but didn't discuss the implementation details of boxing, only
unboxing. Quite possibly this has already been considered.
More information about the valhalla-dev