<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: &#8220;Object Main extends Application&#8221; considered harmful</title>
	<atom:link href="http://www.drmaciver.com/2008/04/object-main-extends-application-considered-harmful/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.drmaciver.com/2008/04/object-main-extends-application-considered-harmful/</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 22:56:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: david</title>
		<link>http://www.drmaciver.com/2008/04/object-main-extends-application-considered-harmful/#comment-245</link>
		<dc:creator>david</dc:creator>
		<pubDate>Wed, 07 May 2008 08:28:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=104#comment-245</guid>
		<description>I&#039;m not entirely sure why your example doesn&#039;t work. It seems like you should never get to &quot;world&quot;. Here&#039;s an example that does demonstrate it though:

public class ClassLoading { 

  static {
    new Thread(){
      public void run() {
        System.out.println(new ClassLoading());
      }
    }.start();

    System.out.println(&quot;Hello world&quot;);

    boolean x = true;

    while(x){
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }

  public String toString() {
    return &quot;Goodbye world&quot;;
  }

  public static void main(String[] args) {
    
  }
}

This will print &quot;Hello world&quot; but will never print &quot;Goodbye world&quot;</description>
		<content:encoded><![CDATA[<p>I&#8217;m not entirely sure why your example doesn&#8217;t work. It seems like you should never get to &#8220;world&#8221;. Here&#8217;s an example that does demonstrate it though:</p>
<p>public class ClassLoading { </p>
<p>  static {<br />
    new Thread(){<br />
      public void run() {<br />
        System.out.println(new ClassLoading());<br />
      }<br />
    }.start();</p>
<p>    System.out.println(&#8220;Hello world&#8221;);</p>
<p>    boolean x = true;</p>
<p>    while(x){<br />
      try {<br />
        Thread.sleep(1000);<br />
      } catch (InterruptedException e) {<br />
        e.printStackTrace();<br />
      }<br />
    }<br />
  }</p>
<p>  public String toString() {<br />
    return &#8220;Goodbye world&#8221;;<br />
  }</p>
<p>  public static void main(String[] args) {</p>
<p>  }<br />
}</p>
<p>This will print &#8220;Hello world&#8221; but will never print &#8220;Goodbye world&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yang</title>
		<link>http://www.drmaciver.com/2008/04/object-main-extends-application-considered-harmful/#comment-244</link>
		<dc:creator>Yang</dc:creator>
		<pubDate>Tue, 06 May 2008 22:51:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=104#comment-244</guid>
		<description>Do you have a small test case in Java which reproduces this?  The following code seems to work fine, for instance:

public class ClassLoadingThread {
  static {
    System.out.println(&quot;hello&quot;);
    final ClassLoadingThread x = new ClassLoadingThread();
    Runnable r = new Runnable() {
      public void run() {
        synchronized(x) { x.notify(); }
      }
    };
    // If we are currently being classloaded, then we won&#039;t make it past this line, right?
    new Thread(r).start();
    try { synchronized(x) { x.wait(); } }
    catch (Exception ex) { throw new RuntimeException(ex); }
  }
  public static void main(String[] args) {
    System.out.println(&quot;world&quot;);
  }
}</description>
		<content:encoded><![CDATA[<p>Do you have a small test case in Java which reproduces this?  The following code seems to work fine, for instance:</p>
<p>public class ClassLoadingThread {<br />
  static {<br />
    System.out.println(&#8220;hello&#8221;);<br />
    final ClassLoadingThread x = new ClassLoadingThread();<br />
    Runnable r = new Runnable() {<br />
      public void run() {<br />
        synchronized(x) { x.notify(); }<br />
      }<br />
    };<br />
    // If we are currently being classloaded, then we won&#8217;t make it past this line, right?<br />
    new Thread(r).start();<br />
    try { synchronized(x) { x.wait(); } }<br />
    catch (Exception ex) { throw new RuntimeException(ex); }<br />
  }<br />
  public static void main(String[] args) {<br />
    System.out.println(&#8220;world&#8221;);<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://www.drmaciver.com/2008/04/object-main-extends-application-considered-harmful/#comment-199</link>
		<dc:creator>david</dc:creator>
		<pubDate>Tue, 15 Apr 2008 09:30:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=104#comment-199</guid>
		<description>Could be. This might be fixable by changing the way object initialization works. I&#039;ve filed a bug about this: https://lampsvn.epfl.ch/trac/scala/ticket/746</description>
		<content:encoded><![CDATA[<p>Could be. This might be fixable by changing the way object initialization works. I&#8217;ve filed a bug about this: <a href="https://lampsvn.epfl.ch/trac/scala/ticket/746" rel="nofollow">https://lampsvn.epfl.ch/trac/scala/ticket/746</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: German B.</title>
		<link>http://www.drmaciver.com/2008/04/object-main-extends-application-considered-harmful/#comment-198</link>
		<dc:creator>German B.</dc:creator>
		<pubDate>Tue, 15 Apr 2008 02:35:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=104#comment-198</guid>
		<description>&quot;extends Application&quot;: maybe Scala anti-pattern #1 of a hopefully-not-too-long list?</description>
		<content:encoded><![CDATA[<p>&#8220;extends Application&#8221;: maybe Scala anti-pattern #1 of a hopefully-not-too-long list?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

