JEP draft: Frozen Arrays (Preview)

Suminda Sirinath Salpitikorala Dharmasena sirinath1978m at
Mon Feb 22 09:21:10 UTC 2021

Minor corrections below:

> Since the type system (of both language and VM) gives no way to
distinguish between variables which always refer to mutable arrays, always
refer to frozen arrays, or may refer to a mix of arrays, there will in
general be a dynamic check (for "frozen-ness") as part of any store to an
array (as a[i]=x, or bytecodes like iastore or aastore). This check is
similar to the existing checks for null references (potentially raising
NullPointerException) or reference array subtypes (potentially raising

I am wondering if the array can have a marker interface `UnFrozenArray` &
`ForzenArray` which can be used to track if the array is frozen or not.
Also perhaps this can be used to eliminate the dynamic check. The array API
can use these maerker interfaces.

Also have a user facing method to create a frozen by birth array. Say `A[]
a = {...}.frozen;`.

Also it would be great if an array related API can migrate away from using
`Object` to a marker say `Array<T>` or `PrimitiveArray` so that
arbitrary objects cannot be passed to these methods. This change will only
break incorrect code where an non array is passed to an array specific


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list