Clarification on migration to value types and boxed vs unboxed representations
john.r.rose at oracle.com
Tue Jan 6 03:55:01 UTC 2015
On Jan 5, 2015, at 5:58 PM, Vitaly Davidovich <vitalyd at gmail.com> wrote:
> What's the plan to avoid such copying costs with proposed value types in java?
Value types are designed for small structures of a few words, like complex numbers or foreign pointers, not wide aggregates like "struct stat".
If there are enough use cases for wide values, we can reduce copying by adding hidden indirections. But building indirections into the design defeats one of our goals, which is memory locality. Locality is obtained by placing a value inside of its containing object or array. Clever bit-sharing indirections, at least for small values, would probably add too much overhead.
Value types are not structs, and will be useful for emulating only those C structs which are passed by value.
Do you have another use case in mind?
More information about the valhalla-dev