Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Roedy Green Newsgroups: comp.lang.java.programmer Subject: Re: trigger static init Date: Mon, 09 Apr 2012 06:09:53 -0700 Organization: Canadian Mind Products Lines: 21 Message-ID: References: <5605o7di8le7conanmf0g70p1ltipeqct4@4ax.com> Reply-To: Roedy Green NNTP-Posting-Host: Z2l1DcCELS0rATq8NqV4Sw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Forte Agent 6.00/32.1186 Xref: csiph.com comp.lang.java.programmer:13457 On Mon, 09 Apr 2012 10:32:21 +0300, Jukka Lahtinen wrote, quoted or indirectly quoted someone who said : >, you can refer to some public static attribute >of the class. But it had better not be a static final known at compile time, or it will be optimised to a literal and referencing it won't load the class. I decided to handle it by putting in dummy public static void fireup() methods that as a side effect load the class and run static init. If I fail to call them, class loading is just procrastinated until first use. -- Roedy Green Canadian Mind Products http://mindprod.com When you were a child, if you did your own experiment to see if it was better to put to cocoa into your cup first or the hot milk first, then you likely have the programmer gene..