Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: calling own methods from constructor Date: Thu, 07 Apr 2011 07:19:08 -0400 Organization: albasani.net Lines: 27 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net khjL6wVMiQLUrCYTHmg2ZKonDO3rObOrBIgyg6Im9lrsXRSDHMEIKunpu/qwUxh8NIwOyRoVQFtFhO/MxzPhDg== NNTP-Posting-Date: Thu, 7 Apr 2011 11:19:01 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="ekSeZYj8eM4YEYs2xLqSIKPqcS8F79v2pImrSIMoG8RWOlvsFHoPyZENC8Q1yZ6o30eCYNUsZXMB2tNg8rb+dhHlvGC3SSRYJ9b92OXlfamg9qL+eFnGdvqlLlPgv5in"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: Cancel-Lock: sha1:3e56Mab4LOBSvWkTem049RpIaC4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2924 On 04/07/2011 04:44 AM, Andreas Leitgeb wrote: > Lew wrote: >> Andreas Leitgeb wrote: >>>> Is there any *good* use of having the constructor call a method that >>>> actually *can* be overridden in a subclass? I mean, are there >>>> (non-anti)patterns of explicitly allowing subclasses to hook into >>>> base-class's construction? >> >> import org.apache.log4j.Logger; >> import static org.apache.log4j.getLogger; >> public class Foo >> { >> private final Logger logger = getLogger( getClass() ); >> // ... >> } > > I thought, I made it clear, that calling static methods was not relevant > to my question. So, kind of thanks for pointing out that I should have > written non-static in the very line of the question, rather than consider > that clear from the other (snipped by you) paragraphs of my post... I did not realize that 'getClass()' was static. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg