Arrays now implement "Arrayish"

Rémi Forax forax at univ-mlv.fr
Thu Apr 28 13:14:31 UTC 2016


Answering to myself,
yes, the prototype support default methods this is currently how arraySize, arrayGet and arraySet are implemented. 

This means by the way that a class can implements Arrayish without providing any implementations so a ClassCastException will be raised.

Perhaps you should have two interfaces,
Arrayish with only abstract methods and ArrayIshImpl (for a lack of better name) which extends Arrayish contains the default methods and is the one which is injected as interface for each array class.

Rémi


Le 28 avril 2016 15:02:52 CEST, "Rémi Forax" <forax at univ-mlv.fr> a écrit :
>Hi David,
>did you check that Arrayish can contain default methods ?
>
>regards,
>Rémi
>
>
>Le 27 avril 2016 14:52:41 CEST, David Simms <david.simms at oracle.com> a
>écrit :
>>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