I doubt you'd ever notice the difference. Let the JIT take care of
optimising this rather than doing it explicitly.
What evidence do you have that it is possible to optimise away the
extra overhead of interface references? When you think about what has
to happen under the hood it would be quite a feat.
See the Goldfish book:
The Java Virtual Machine
ISBN10: 1-56592-194-1
Joshua Engel
http://www.amazon.com/gp/product/15...mp=1789&creative=9325&creativeASIN=1565921941
I have heard that the JVMs have been gradually improving the
implementation of interface references, however if I were given some
code to optimise for speed, one thing I would try would be to convert
interface to class references where possible at least for leaf calls
where the CPU spends most of its time.
There is no virtue in deliberately choosing a slower solution unless
there is some compensating benefit.
There is a sentiment you hear from people who have read Knuth but who
are not of his generation, reminiscent of the conspicuous consumption
of movie stars that there is some virtue in deliberately wasting
resources.
What Knuth was talking about was making code unreadable with peephole
optimisations better done by the compiler. I don't think that many
Java programmers are old enough to have ever even seen the kind of
ghastly code he was talking about. He did not intend for you to close
your eyes to speed considerations or deliberately choose the slowest
implementation on your first cut. You might as well write fast code
first time out if it is readable and easy to write.
Knuth would unlikely bawl you out for choosing the best algorithm
first time out. That's where you get your massive speed improvements
for the least amount of work.