Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: glen herrmannsfeldt Newsgroups: comp.lang.java.programmer Subject: Re: trigger static init Date: Mon, 9 Apr 2012 09:18:04 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 21 Message-ID: References: <5605o7di8le7conanmf0g70p1ltipeqct4@4ax.com> NNTP-Posting-Host: H0vc4U5LIRkRHNPyGCs2dA.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org User-Agent: tin/1.9.6-20100522 ("Lochruan") (UNIX) (Linux/2.6.32-5-amd64 (x86_64)) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:13455 Roedy Green wrote: > What is the canonical way to explicitly trigger a static class to load > and run thestatic init without actually invoking a real method? > you can't necessarily use newInstance since the class may not > have constructors. As far as I know, a class automatically has a no argument constructor, even if you don't write one. class myclass { static int x; } compiles just fine, as does creating an object from it. > Do you have to invent some dummy static method? Not that I know of. -- glen