Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #36533
| From | Marcel Mueller <news.5.maazl@spamgourmet.org> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Generics and downcasts |
| Date | 2017-04-25 22:40 +0200 |
| Organization | MB-NET.NET for Open-News-Network e.V. |
| Message-ID | <odoc85$5b4$1@gwaiyur.mb-net.net> (permalink) |
| References | <generics-20170424231405@ram.dialup.fu-berlin.de> <odoaaj$9q$1@gwaiyur.mb-net.net> <odob39$s00$1@gioia.aioe.org> |
On 25.04.17 22.20, Arne Vajhøj wrote: > .NET got generics relative early in its history, so MS decided > that compatibility with old collection classes was not that important. > Java was in a different situation, so type erasure and collection > compatibility was chosen. And we have to live with it. The bad news is that although this breaking change they did not manage to give their new container classes a consistent interface. There are at least 4 distinct and fully equivalent implementation of the Count property. And methods with the same name (like Add) have significantly different semantics in different container types. >> There are other pitfalls that are by far more expensive. >> E.g. if you miss to declare a trivial Java method as final. This >> prevents the JIT from inlining the method body. This may add an overhead >> of an order of magnitude or even more. > > I think this is a myth. > > https://www.ibm.com/developerworks/library/j-jtp1029/ (Brian Goetz 2002) > > <quote> > Like many myths about Java performance, the erroneous belief that > declaring classes or methods as final results in better performance is > widely held but rarely examined. The argument goes that declaring a > method or class as final means that the compiler can inline method calls > more aggressively, because it knows that at run time this is definitely > the version of the method that's going to be called. But this is simply > not true. Just because class X is compiled against final class Y doesn't > mean that the same version of class Y will be loaded at run time. So the > compiler cannot inline such cross-class method calls safely, final or > not. Only if a method is private can the compiler inline it freely, and > in that case, the final keyword would be redundant. > </quote> I never said that the Java compiler might inline such function calls. This is up to the JIT. Marcel
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Generics and downcasts Marcel Mueller <news.5.maazl@spamgourmet.org> - 2017-04-25 22:07 +0200
Re: Generics and downcasts Arne Vajhøj <arne@vajhoej.dk> - 2017-04-25 16:20 -0400
Re: Generics and downcasts Eric Douglas <e.d.programmer@gmail.com> - 2017-04-25 13:35 -0700
Re: Generics and downcasts Arne Vajhøj <arne@vajhoej.dk> - 2017-04-25 19:54 -0400
Re: Generics and downcasts Marcel Mueller <news.5.maazl@spamgourmet.org> - 2017-04-25 22:40 +0200
Re: Generics and downcasts Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-04-25 18:13 -0400
Re: Generics and downcasts Arne Vajhøj <arne@vajhoej.dk> - 2017-04-25 19:53 -0400
csiph-web