Stateless traits & default interface methods question
david.holmes at oracle.com
Wed Nov 13 19:21:10 PST 2013
On 13/11/2013 9:14 AM, Millies, Sebastian wrote:
> Hi Matthew,
> I've just tested this, and you'll get the implementation at time t1, i. e. the implementation as it is at runtime.
> However, I don't know by what mechanism.
The normal mechanism by which you get whatever bytecode is in the
compiled interface's .class file when it is loaded at runtime. Logically
the class delegates to the interface's default method implementation.
Nothing special happens at Java source code compilation time.
> -- Sebastian
> -----Original Message-----
> From: lambda-dev-bounces at openjdk.java.net [mailto:lambda-dev-bounces at openjdk.java.net] On Behalf Of Matthew Adams
> Sent: Wednesday, November 13, 2013 5:50 PM
> To: lambda-dev at openjdk.java.net
> Subject: Stateless traits & default interface methods question
> _Note: This may be a FAQ. RTFMs are fine._
> I have a question about default interface methods, thinking in terms of stateless traits.
> Assume at time t0 I define an interface I with a given default method implementation and class C implements I. Later, at time t1, I modify the implementations of I's default methods _without_ recompiling C. The next time that I execute a method on C that came from a default method on I, do I get I's implementation as it was at t0 or t1?
> In other words, are default method implementations woven into classes at compile time, do classes delegate to the interface's default method implementation at runtime, or is it via some other mechanism?
> mailto:matthew at matthewadams.me <matthew at matthewadams.me>
> googletalk:matthew at matthewadams.me
> Software AG – Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Dr. Wolfram Jost, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Dr. Andreas Bereczky - http://www.softwareag.com
More information about the lambda-dev