Arrays now implement "Arrayish"

Brian Goetz brian.goetz at oracle.com
Thu Apr 28 14:58:20 UTC 2016


Guys -- this is a first cut prototype so we can play with it.  We are not even sure how, or if, it will be exposed.  It is radically premature to bikeshed on names or syntax at this point.....

Sent from my iPad

> On Apr 28, 2016, at 10:22, Stephen Colebourne <scolebourne at joda.org> wrote:
> 
> Why arraySize() and not size(). We already have the mess betwen
> length() and size(), so why a third method name?
> Stephen
> 
> 
>> On 27 April 2016 at 13:52, David Simms <david.simms at oracle.com> wrote:
>> Greetings,
>> 
>> I've just pushed a set of changes to enable all arrays to implement the
>> "java.lang.Arrayish" interface:
>> 
>>   public interface Arrayish<any T> extends Cloneable,
>>   java.io.Serializable {
>>        int arraySize();
>>        T arrayGet(int index);
>>        void arraySet(int index, T element);
>>   }
>> 
>> Thanks to John Rose for the original patch, which I have adapted somewhat.
>> 
>> How does it work ?
>> 
>> * "Klass->extra_super()" contains an optional "InstanceKlass*"
>>   pointer, which all array klasses have set to their appropriate
>>   Arrayish, i.e.:
>>     o int[] extra_super() = "Arrayish<int>"
>>     o Object[] extra_super() = "Arrayish"
>> * Classes used as "extra_super" must currently be interfaces, and have
>>   their own "self itable" generated at load time.
>> * The extra_super mechanism allows the "Arrayish" interface to be
>>   injected during JVM start-up, but after the basic array types need
>>   to be initialized
>> * "extra_super()" is used when, checkcast/instanceof and looking up
>>   interface methods
>> * See jtreg test: "hotspot/runtime/valhalla/arrays/ArrayTypes.java"
>> 
>> 
>> This is a prototype, there are caveats (and dragons):
>> 
>> * The current "Model 3" implementation uses a specializer written in
>>   Java, for bootstrapping the Arrayish specializations, these are
>>   currently built at JDK compile time (placed
>>   "$JAVA_HOME/valhalla-prespecialized")
>>     o There is no support yet for double slot types (double and long,
>>       and hence their arrays)
>>     o These classes are specific to the JVM runtime, and must not be
>>       seen by "javac" ( "VALHALLA_PRESPECIALIZED_DIR" is known to the
>>       classloader implementation, but not the classpath).
>> * x86 32 & 64 bit architectures only at this point
>>     o arrays on other architectures will simply not implement "Arrayish"
>> * Nothing about this implementation is set in stone, prototype code
>>   and quality (piggy-backing on these changes, then ymmv)
>> * The type hierarchy for arrays will no doubt continue to be in flux
>> 
>> 
>> Cheers
>> /David Simms
>> 



More information about the valhalla-dev mailing list