Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe08.iad.POSTED!83aa503d!not-for-mail From: Daniel Pitts User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: "Small" Program Challenge. References: <4fde76ce$0$287$14726298@news.sunsite.dk> <7kIDr.12088$Bp1.3039@newsfe10.iad> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Lines: 40 Message-ID: X-Complaints-To: abuse@newsrazor.net NNTP-Posting-Date: Fri, 22 Jun 2012 19:54:48 UTC Date: Fri, 22 Jun 2012 12:54:47 -0700 X-Received-Bytes: 2327 Xref: csiph.com comp.lang.java.programmer:15523 On 6/20/12 4:11 AM, Wanja Gayk wrote: > In article, -@. says... > >> It's just the order that things are done by default. >> >> Before the code was: >> >> 1. Load class with initialization. >> 2. Run 'main' method. >> >> Now, they do the special step of loading without initialization: >> >> 1. Load class without initialization. >> 2. Verify 'main' method, throw error if not present >> 3. Initialize class >> 4. Run 'main' method. >> >> You can see how the new method takes more effort. > > I'd rather see it as an extension of the bytecode validation mechanism, > that has to exist anyway: > > 1. Load bytecode > 2. Validate bytecode > (exits if there is no 'main' method for the main class) > 3. Initialize class > 4. Run 'main' method. Actually, the way I understand it is that Loading is immediately followed by verification. How I would expect this to work in reality. 1. Load class 2. get a reference to the static method "void main(String[])" 3. Attempt to execute that reference 3.1 Causes class initialization before execution. 3.2 actual execution occurs.