Here's an oldie but goodie: what ever happened to interface injection?

For those unfamiliar, we dynlang guys had an idea years ago that if we
could simply "force" an interface into an existing Java class, with a
handler dangling off the side, we could pass normal Java objects through
languages that have their own supertypes without needing a wrapper.

So in the case of JRuby, where every method signature and every local
variable is typed IRubyObject, we'd inject a default impl of IRubyObject
into java.lang.Object, and it would know how to handle all our dispatch

Back in the day, one of the sticky bits was wiring together the
implementation of all those interface methods. These days, perhaps that's
not a problem with default interface methods from Java 8?

Perhaps the JVM could (at some point) even allow you to cast an object to
*any* interface, so long as all that interface's methods had default or
natural implementations?

- Charlie

- Charlie (mobile)
mlvm-dev mailing list

Reply via email to