more band aid coming - Object methods on 'any' tvars
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Jan 13 16:35:40 UTC 2015
Hi,
in order to further facilitate experiments with the current prototype,
I've put together a compiler/specializer patch that adds some restricted
support for calling 'harmless' Object methods on 'any' type-variables.
Methods currently supported are:
* toString
* hashCode
* equals
The remaining Object methods are unsupported (most of them are related
to locking ); the only two 'interesting' methods left out are:
* clone
* getClass
While it wouldn't be impossible to support them in the future, they are
not as straightforward to get to (esp. getClass) - and we decided to
leave them out for now.
One caveat about using Object methods on 'any' type-variables is that
the signature of 'equals' is stricter; that is, you can imagine that an
'any' type-variable T defines a method
equals(T)
and not
equals(Object)
That is: the compared values must have the same static type or the
compiler will bark.
I hope you will find this useful.
Happy hacking!
Maurizio
More information about the valhalla-dev
mailing list