Is there a way to provide a default toString() to an interface?
John Rose
john.r.rose at oracle.com
Wed Mar 12 08:02:05 UTC 2014
On Mar 12, 2014, at 12:45 AM, Wang Weijun <weijun.wang at oracle.com> wrote:
> I do not want to rename it to getString() and let all child classes call it in their toString().
It is probably best to define a *static* method to hold the default implementation, so that the only candidate for overriding is toString itself.
See MethodHandleInfo and InfoFromMemberName (in java.lang.invoke) for one example of this pattern.
— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/security-dev/attachments/20140312/61aa160a/attachment.htm>
More information about the security-dev
mailing list