8/6/2023 0 Comments Java interface default methodOtherwise do nothing, which might cause an error.) Otherwise, if the class has a non-trivial noSuchMethod, add a nSM-forwarder. (Effectively: If a class has an interface member with no non-synthetic implementation, if precisely one interface default method applies, mix that in. (Can happen if also implementing another interface with a more specific signature and no default method). It is a compile-time error if this mixed-in implementation does not satisfy the interface of the class. (We might need to reconsider that if it breaks mocks).Ī default method must be usable as a mixin member declaration with no super-class requirement, so the default method cannot do super-invocations on anything except Object members. If a class has a non-trivial noSuchMethod and an applicable default method, the default method is used. (We may need to define what mixing in a single member means, but it's completely consistent with what a mixin application does to all the mixin members.)Ī synthetic member is either a noSuchMethod forwarder or another default method. This uses the existing member mix-in functionality which is used to mix-in mixin members into mixin application classes, only just for the individual default methods. Instead it is mixed in on any class which implements the interface where the default method was introduced, and which does not already declare or inherit a non-synthetic concrete member with the same name. The method is not just inherited along the normal superclass path. Default double get distanceFromOrigo => sqrt(x * x + y * y)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |