Why Arrayish implements Cloneable?

Brian Goetz brian.goetz at oracle.com
Wed Apr 27 14:45:56 UTC 2016


Currently, the array classes (int[].class, String[].class) are totally 
magical and spring into existence when referenced.  They all happen to 
have some common supertypes (Cloneable, Serializable).

This patch moves things forward incrementally (see John's talk on Arrays 
2.0, http://medianetwork.oracle.com/video/player/1785452137001) by 
providing all arrays with a real supertype, Arrayish, which exposes 
element accessors.  This allows, for example, abstraction over array 
types (<T extends Arrayish>), as well as being a precursor to some other 
cool stuff.

On 4/27/2016 10:32 AM, Paul Benedict wrote:
> Oh, okay ... so basically when you let the native "any" type be boxed, 
> you're exposing the same functionality through an interface.
>
> Cheers,
> Paul
>
> On Wed, Apr 27, 2016 at 9:25 AM, Brian Goetz <brian.goetz at oracle.com 
> <mailto:brian.goetz at oracle.com>> wrote:
>
>     Because array types (int[], String[]) *already* implement
>     Cloneable and Serializable.
>
>
>
>
>
>     On 4/27/2016 10:18 AM, Paul Benedict wrote:
>
>         I only ask because Cloneable is typically looked at as a poor
>         mechanism for
>         duplicating objects. That's the sentiment, anyway, widely
>         popularized by
>         the Effective Java book.
>
>         Cheers,
>         Paul
>
>
>




More information about the valhalla-dev mailing list