What should default interfaces be for?
Brian Goetz
brian.goetz at oracle.com
Thu Mar 15 17:15:34 PDT 2012
> a good option, which I feel is in line with what the Lambda team has
> proposed so far, is that default methods are necessary to allow
> lambdas to be used fruitfully with existing libraries, but that care
> is being taken to leave the door open to future improvements (post JDK
> 8) to the default method feature.
This is our plan....
> Personally, I would prefer to see an absolutely rock-solid, performant
> implementation of lambda, plus associated JDK library extensions to
> use them, for JDK 8, and suggest that Oracle's time is best spent
> doing just that and not taking even more on.
Yep.
> Regarding default methods, the only concern I have is whether the
> proposed approach will also prove useful for non-Java languages on the
> JVM, such as Scala - in this interview with Martin Odersky he suggests
> it doesn't cover all the cases he would like for Scala
> (http://www.infoq.com/articles/odersky-scala-interview).
"Useful for non-Java languages" is pretty broad. You are right that Scala traits cannot in general be implemented on top of default methods. But the feature can be useful to other languages anyway. For example, because this is a VM feature and not a Java language feature, when a class in another language says it implements java.util.List, it will get all the default method behavior without having to do anything special. And I could imagine that other languages would find it a useful substrate for mixin- or trait-like behaviors, even if Scala does not.
More information about the lambda-dev
mailing list