Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jukka Lahtinen Newsgroups: comp.lang.java.programmer Subject: Re: trigger static init Date: Mon, 09 Apr 2012 10:32:21 +0300 Organization: A noiseless patient Spider Lines: 15 Message-ID: References: <5605o7di8le7conanmf0g70p1ltipeqct4@4ax.com> Mime-Version: 1.0 Content-Type: text/plain;charset="iso-8859-1" Content-Transfer-Encoding: 8bit Injection-Info: ipa.eternal-september.org; posting-host="paPmXfJqRejvVuAyXZaB8g"; logging-data="6772"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uFEyIXa4CSXOgrLi5bbHB" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:a4zutj9WuxHmpRbppJSVltjcsOo= sha1:pPkUVSky4yQkKT9ml25ioPEz00I= X-no-archive: yes Xref: csiph.com comp.lang.java.programmer:13454 Roedy Green writes: > What is the canonical way to explicitly trigger a static class to load > and run thestatic init without actually invoking a real method? I suggest Class.forName(String classname), if you just want to avoid invoking a method of the class to be loaded and don't mind invoking one of the Class class. If you insist on not invoking any method of *any* class and thus don't want to use Class.forName, you can refer to some public static attribute of the class. -- Jukka Lahtinen