Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!feeder.news-service.com!feeder.erje.net!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: Style Police (a rant) Date: Sat, 27 Aug 2011 17:59:38 +0200 Organization: albasani.net Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net Z/G449wosysItH0Yj5mror3Fjs9l7BWo1vDxMngjQqqZDmp1dQo0ynafZfZOV3EhjGHyF+cQO4xwMEDjWaPozw== NNTP-Posting-Date: Sat, 27 Aug 2011 15:59:47 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="FVlcjs77MZf+HRoQ7Cus99Z9Hn92uGJN2o/z6uWe/MH1wgL0jBdbVlgBnxtJUPCEc+5GocLg/TPZAirkUmWfurbjszY3dn+oQ2eGKXUkEgD6VQpHIqN8jVrMLzNLAqJO"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110820 Firefox/6.0 SeaMonkey/2.3.1 In-Reply-To: Cancel-Lock: sha1:OLPuN+Dx4wBwYjWXb6u7oRDhpMM= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7420 Lew schrieb: > Jan Burse wrote: >>> I have noticed that final methods sometimes execute faster >>> than non-final methods. The final modifier gives a hint to >>> the optimizers. > > How did you "notice" that - by what measurements under what conditions? > It is around 1% - 10% in a crucial spot in my application. Without the final keyword a JIT potentially needs to reoptimize code, when classes are later loaded. Since although an analysis might yield that a class method is actually not overridden, it might still get overridden at run time. It might get overridden by Class.forName or even more massive by URLClassLoader.addURL. May application makes use of the former, therefore I am always doing the final where I can. Bye