See you at JVMLS

Palo Marton palo.marton at
Fri Aug 21 14:42:07 UTC 2015

> Keep going and you'll end up fully reinventing Scala traits ;)

I'm not familiar with Scala... seems to be something very similar ;-)

But anyway - implementing "traits" in JVM is not a part of Valhalla, but
may be they will get into Java somewhere in the future and that's a good
reason to choose conservative approach to Foo$any <-> Bar problem that will
leave this option open:

1) leave the low level relation between Foo$any and Bar unspecified (=its
up to each JVM how it implements it)
2) leave isAssignableFrom unspecified
3) compile f.barMethod()  as ((Bar)f).barMethod()

And in the first Valhala JVM implement it this way:

4) no low level relation between Foo$any and Bar
5) Bar methods will not be recreated in Foo$any and no "shadow" interface
created for Bar (there is no need for that as Bar method calls are compiled
with cast to Bar)
6) isAssignableFrom will return false (but it is unspecified, so some
future JVM may return true)

More information about the valhalla-dev mailing list