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 15:57:53 -0400 Organization: media lab? Lines: 75 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:15388 On 18/06/2012 3:47 PM, Lew wrote: > Loading does not imply initialization, and in fact cannot. Wrong. Loading and initialization go hand-in-hand. > The JVM is forbidden to initialize a class except under specific > circumstances, a What? >> Exactly. It loads the specified class, as part of which that class's >> static initializer runs. And if it's an enum, the enum elements' >> initializers run too. > > Not true. Loading does not imply initialization, and in fact is forbidden to. Wrong. Loading and initialization go hand-in-hand. > The initializers only run under specific circumstances, separately from > loading. > > I have cited the relevant JLS sections. You haven't cited anything except my own post, and your quotation of *that* was a jumbled mess with some sections repeated for some reason. > False premise, unreliable conclusion. On your part, Lew. > Loading does not imply initialization. Wrong. Loading and initialization go hand-in-hand. >> However, the observed behavior seems to be out of spec. The main >> method's absence should prompt an error upon the attempt to invoke it, > > Indeed. And not before. When invoking a static method of a non-loaded class, the standard procedure always has been: Load the class. Initialize the class. Invoke the method. In particular, the spec requires that in this: class A { static int x; static { x = 100; } static int foo () { return x; } } a call to A.foo() should return 100, not 0. If it can attempt to invoke foo before the static initializer has executed that would be violated. On the other hand, it complaining that a reflective call to A.bar() can't be resolved sooner than the loading and initializing of A as part of trying to resolve bar is equally anomalous. If it hasn't loaded and initialized A yet, how can it be sure whether or not it has a method bar? On the other hand, if it's a non-reflective call the code calling bar won't even compile. -- 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.