Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34270
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: When to use dynamic binding over dynamic dispatch? |
| Date | 2016-05-08 23:16 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ngovei$b6i$1@gioia.aioe.org> (permalink) |
| References | (2 earlier) <dp8if4Fqm9cU1@mid.individual.net> <ngnb33$1rif$1@gioia.aioe.org> <ngnctb$pp9$1@dont-email.me> <ngniup$8u0$1@gioia.aioe.org> <ngo87v$c68$1@dont-email.me> |
On 5/8/2016 4:44 PM, Eric Sosman wrote:
> On 5/8/2016 10:37 AM, Arne Vajhøj wrote:
>> On 5/8/2016 8:57 AM, Eric Sosman wrote:
>>> On 5/8/2016 8:23 AM, Arne Vajhøj wrote:
>>>> then how can it be?
>>>
>>> class Super {
>>> public void method() {}
>>> }
>>>
>>> class Sub extends Super {
>>> public final void method() {}
>>> }
>>>
>>> ...
>>>
>>> Super obj = new Sub();
>>> obj.method();
>>
>> As a starting point I would not call Sub.method
>> a virtual method due to above definition.
>
> Let's try another example, if you dislike my first one:
>
> class Worker implements Runnable {
> @Override
> public final void run() {}
> }
>
> The Worker#run method is quite obviously final, and not
> overridable. Do you maintain that it isn't virtual? If
> we follow the above with
>
> new Thread(new Worker()).start();
>
> ... should the thread's invocation of Worker#run use something
> other than virtual invocation?
It certainly need to use virtual invocation, because it is
calling Runnable run which is virtual.
But does that make Worker run virtual when it is final?
Seems to be the Java way. But not natural to me.
Arne
PS: I don't think the above will use virtual invocation - it will
use interface invocation as Runnable is an interface. But
I don't think that is particular relevant.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
When to use dynamic binding over dynamic dispatch? cdalten@gmail.com - 2016-05-02 18:08 -0700
Re: When to use dynamic binding over dynamic dispatch? Sebastian <news@seyweiler.dyndns.org> - 2016-05-03 20:47 +0200
Re: When to use dynamic binding over dynamic dispatch? Lew <lewbloch@gmail.com> - 2016-05-03 12:14 -0700
Re: When to use dynamic binding over dynamic dispatch? Arne Vajhøj <arne@vajhoej.dk> - 2016-05-03 21:23 -0400
Re: When to use dynamic binding over dynamic dispatch? Martin Gregorie <martin@address-in-sig.invalid> - 2016-05-04 10:48 +0000
Re: When to use dynamic binding over dynamic dispatch? Robert Klemme <shortcutter@googlemail.com> - 2016-05-08 12:24 +0200
Re: When to use dynamic binding over dynamic dispatch? Arne Vajhøj <arne@vajhoej.dk> - 2016-05-08 08:23 -0400
Re: When to use dynamic binding over dynamic dispatch? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-08 08:57 -0400
Re: When to use dynamic binding over dynamic dispatch? Arne Vajhøj <arne@vajhoej.dk> - 2016-05-08 10:37 -0400
Re: When to use dynamic binding over dynamic dispatch? Robert Klemme <shortcutter@googlemail.com> - 2016-05-08 22:30 +0200
Re: When to use dynamic binding over dynamic dispatch? Arne Vajhøj <arne@vajhoej.dk> - 2016-05-08 23:08 -0400
Re: When to use dynamic binding over dynamic dispatch? Robert Klemme <shortcutter@googlemail.com> - 2016-05-09 08:16 +0200
Re: When to use dynamic binding over dynamic dispatch? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-08 16:44 -0400
Re: When to use dynamic binding over dynamic dispatch? Arne Vajhøj <arne@vajhoej.dk> - 2016-05-08 23:16 -0400
Re: When to use dynamic binding over dynamic dispatch? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-09 00:39 -0400
csiph-web