Path: csiph.com!usenet.pasdenom.info!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 16:01:41 -0400 Organization: media lab? Lines: 29 Message-ID: References: <4fde76ce$0$287$14726298@news.sunsite.dk> <7kIDr.12088$Bp1.3039@newsfe10.iad> 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:15389 On 18/06/2012 3:44 PM, Lew wrote: > "A class or interface type T will be initialized immediately before the first occurrence of any one of the following: > > - T is a class and a static method declared by T is invoked. This is the case that seems to be applicable here. It should not be erroring out trying to invoke main until after initialization, because the initialization must occur immediately *before* the invocation attempt (since it must have occurred if that attempt succeeds or again the spec is violated). > You are saying that the first case applies, an instance is created because of > the third case, a static field is assigned. But that assignment shouldn't happen > yet because nothing has invoked the class legally, i.e., the sequence to invoke > 'main()' didn't happen. It is, in fact, the invocation of 'main()' that is supposed to > trigger the initialization. That's backwards. Initialization must *precede* the invocation, not *follow* it. The JVM is required to initialize the class just *before* attempting to invoke the main method, and indeed up through Java 6 that is precisely what it did. -- 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.