Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "javax.swing.JSnarker" Newsgroups: comp.lang.java.programmer Subject: Re: "Small" Program Challenge. Date: Mon, 18 Jun 2012 19:50:35 -0400 Organization: media lab? Lines: 40 Message-ID: References: <4fde76ce$0$287$14726298@news.sunsite.dk> <20ad5d23-f0a7-4926-9d99-b9dc0a7ea18e@googlegroups.com> NNTP-Posting-Host: 3urdS3lMyXHJXrtKy7vOkg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: NewsTap/3.5.5 (iPhone/iPod Touch) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:15399 On 18/06/2012 5:18 PM, Lew wrote: > Leif Roar Moldskred wrote: >> Lew wrote: >>> "Invocation of certain reflective methods in class Class and in >>> package java.lang.reflect also causes class or interface >>> initialization." >> >> Might this be what is happening? The JLS doesn't seem to specify _how_ >> the main method should be invoked, so might not a Java implementation >> do so through reflection and thus trigger the initialization of the >> class? > > There was no 'main()' method in the example under discussion. > > The JLS says that the JVM is started by invocation of a 'main()' method. > > Without such an invocation, nothing should have been able to call any of the > static methods of the 'enum' or otherwise triggered initialization of that class. There is such an invocation, though -- albeit an unsuccessful one, if no method of that name can be resolved by the reflection code. > The class initialized anyway. Because the two alternatives are: initialize, then try to invoke method; and try to invoke method, then initialize. But in the second case, if the invocation succeeds the method runs and then the initializer instead of the other way around, and that's obviously wrong. -- public final class JSnarker extends JComponent A JSnarker is an NNTP-aware component that asynchronously provides snarky output when the Ego.needsPuncturing() event is fired in cljp.