Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: "Small" Program Challenge. Date: Wed, 20 Jun 2012 10:45:22 -0700 (PDT) Organization: http://groups.google.com Lines: 56 Message-ID: References: <7kIDr.12088$Bp1.3039@newsfe10.iad> <4291u795eegvb0j8b09lvqkng3hh13t336@4ax.com> <4732eeb4-9d34-4765-ba6d-c098f0528038@googlegroups.com> NNTP-Posting-Host: 69.28.149.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1340214322 10351 127.0.0.1 (20 Jun 2012 17:45:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Jun 2012 17:45:22 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Received-Bytes: 3981 Xref: csiph.com comp.lang.java.programmer:15455 Andreas Leitgeb wrote: > Lew wrote: > > Leif Roar Moldskred wrote: > >> javax.swing.JSnarker wrote: > >>> Not relevant here, unless you're claiming you've seen in real code wh= ere > >>> a static method began to be invoked and the class was *still* not > >>> initialized. >=20 > It all boils down to the true definition of "invocation". >=20 > Is it the moment when the instruction pointer hits the bytecode for=20 > invokestatic and starts doing it, or is it just before it hits the > first instruction of the callee (iff existing)? >=20 > JVM7-behaviour implies the latter. I admit having difficulties myself > to actually read it unambiguously from JLS =A712.4.1. Probably this > is defined elsewhere. >=20 > Anyway, between these two moments, there's plenty time for the JVM=20 > to load the class, check availability of the method, and only if ok > then initialize the class and proceed with the callee's code,=20 > otherwise skip initialization and just throw some exception.=20 > And for a certain definition of "invocation", initialization > would still always precede it. The gap "between these two moments" is the gap between the attempt to=20 invoke, and the invocation proper. JLS =A712.4.1 lives in a context, one that include JLS =A712.4.2,=20 op. cit. upthread. Even so,=20 "A class or interface type T will be initialized immediately before the fir= st=20 occurrence of any one of the following:=20 "T is a class and an instance of T is created.=20 "T is a class and a static method declared by T is invoked. ..." is pretty clear. Whatever the definition of "invocation", initialization oc= curs=20 just before it. This means that the system identifies "immediately before". That moment of "immediately before" can only be at the point of the attempt= =20 to invoke, right before the invocation proper. I call "immediately before",= =20 therefore, the "attempt to invoke". This distinguishes it from the invocati= on,=20 which occurs after initialization. Note that this passage does not say that the class is loaded at that point. That's because the class may have been loaded considerably earlier, but=20 not initialized. --=20 Lew