<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Dionysios Synodinos&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/synodinos/" />
<modified>2008-02-22T00:26:05Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/synodinos/428</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2008, synodinos</copyright>
<entry>
<title>Report from the “Java Developer Day 2008” in Athens</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/synodinos/archive/2008/02/report_from_the.html" />
<modified>2008-02-22T00:26:05Z</modified>
<issued>2008-02-22T00:25:59Z</issued>
<id>tag:weblogs.java.net,2008:/blog/synodinos/428.9248</id>
<created>2008-02-22T00:25:59Z</created>
<summary type="text/plain">Short outline of what went on during the &quot;Java Developer Day&quot; (2008) in Athens, Greece.</summary>
<author>
<name>synodinos</name>

<email>synodinos@gmail.com</email>
</author>
<dc:subject>Community: Java User Groups</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/synodinos/">
<![CDATA[On my personal blog you can find <a href="http://synodinos.wordpress.com/2008/02/22/report-from-the-%e2%80%9cjava-developer-day-2008%e2%80%9d-in-athens/">a short outline of what went on during the "Java Developer Day" (2008) in Athens, Greece</a>.]]>

</content>
</entry>
<entry>
<title>After Apple more manufacturers refuse to ship latest Java</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/synodinos/archive/2007/11/after_apple_mor.html" />
<modified>2007-11-02T20:08:21Z</modified>
<issued>2007-11-02T20:08:13Z</issued>
<id>tag:weblogs.java.net,2007:/blog/synodinos/428.8557</id>
<created>2007-11-02T20:08:13Z</created>
<summary type="text/plain">After the widespread disapproval of Apple’s choice not to ship Java 6 with its latest Leopard OS it has come to my attention that there are more manufacturers that are adopting this anti-Java approach.</summary>
<author>
<name>synodinos</name>

<email>synodinos@gmail.com</email>
</author>
<dc:subject>J2SE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/synodinos/">
<![CDATA[<p><img align="right" alt="BlackHole.jpg" src="http://weblogs.java.net/blog/synodinos/archive/BlackHole.jpg" width="300" height="240" />After the  widespread disapproval of Apple’s choice not to ship Java 6 with its latest  Leopard OS it has come to my attention that there are more manufacturers that  are adopting this anti-Java approach.</p>
<p>Today, as I  had planned for months now, I went and bought a new laptop to replace my aging Vaio.  When it comes to hardware I always go big, so I went a little over my budget  and got a brand new “<a href="http://puhep1.princeton.edu/~mcdonald/examples/QM/lloyd_nature_406_1047_00.pdf">ultimate  laptop</a>”.</p>
<p>Some might  find it a bit bold for laptop with a mass of 1 kg and a volume of 1 l to  operate at the fundamental limits of speed and memory capacity fixed by physics,  but when it comes to using the Eclipse IDE you need all the performance you can  get. As the benchmarks show it performs about 5.4258x10^50 logical operations  per second on ~1031 bits. There were of course some cooling issues because although  its computational machinery is in fact in a highly specified physical state  with zero entropy, while it performs a computation that uses all its resources  of energy and memory space it appears to an outside observer to be in a thermal  state at ~109 degrees Kelvin. This might prove tricky during the warm greek  summer, but my workplace is heavily air-conditioned so I think I can manage.</p>
<p>The weight  is also a bit of a problem: since the rate at which the components of a<br />
	computer  can communicate is limited by the speed of light, the computation in the “ultimate  laptop” has been speeded up and made more serial by compressing it. In fact it  has been compressed to the black-hole limit of 1.485x10^–27 m where computation  is fully serial.</p>
<p>With all  these said it came as sock to find out that the “ultimate laptop” not only  doesn’t come with Java 6, but also the pre-installed Java 5 that comes with it  is broken. Searching around the blogosphere I found several references about  how the “ultimate laptop” engineers had no resources to update to Sun’s  rendering pipeline for their  new model.  Further disagreement about font rendering, Quartz, Chinese cooking and the  support for the ultimate “filthy rich clients” had lead this marvelous piece of  engineering to come out java-crippled.</p>
<p>Please Sun  do something about Java 6 in the “ultimate laptop”...</p>
]]>

</content>
</entry>
<entry>
<title>The Taming of the Stack Trace</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/synodinos/archive/2007/08/the_taming_of_t_1.html" />
<modified>2007-08-16T23:04:01Z</modified>
<issued>2007-08-16T23:03:54Z</issued>
<id>tag:weblogs.java.net,2007:/blog/synodinos/428.8034</id>
<created>2007-08-16T23:03:54Z</created>
<summary type="text/plain">Everything you ever wanted to know about the Java Stack Trace, but were afraid to ask.</summary>
<author>
<name>synodinos</name>

<email>synodinos@gmail.com</email>
</author>
<dc:subject>Programming</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/synodinos/">
<![CDATA[<p><img alt="shakespeare.jpg" align="right" src="http://weblogs.java.net/blog/synodinos/archive/shakespeare.jpg" width="130" height="186" />One concept  of Java development that is intimidating to fresh developers and a mystery to  funs of other languages is the Stack Trace (ST). There is little available  documentation out there and most of the times a useful ST can be very long and  verbose. </p>
<p>The public  was familiarized with the ST from poorly developed and configured web  applications that used to spit out their internal state for every little error  they encountered. For example you can find yourself a variety of <a href="http://www.google.com/search?q=intitle%3A%22Apache+Tomcat%22+%22Error+Report%22">Tomcat  hosted broken web apps that print out a ST just by googling for it</a>. These  might range from a simple “Too many connections” error to broken installations  and more.</p>
<h2>But what is actually a Java Stack Trace..? </h2>
<p>Basically it  is a snapshot of the all threads and monitors in a JVM. Depending on how  complex your application is a ST can range from a few lines to thousands of  lines of diagnostics. Regardless of the size the ST is one of the most valuable  diagnostics tool you can have as a Java developer. It cannot be substituted by the  output generated by java.util.logging or Log4J since these cannot show thread  dumps.</p>
<h2>How can I get a Stack Trace?</h2>
<p>Essentially  you can get a ST either by:</p>
<ul>
	<li>Working  with your operating system, </li>
	<li>Programmatically  from within the code or</li>
	<li>Outside  of the JVM with JMX</li>
</ul>
<p>On UNIX  platforms you can send a signal to a program by using the kill command. This is  the quit signal (signal 3 - SIGQUIT) which is handled by the JVM. A signal is a  message which can be sent to a running process and each Unix signal has a  default set of effects on a program. Programmers can code their applications to  respond in customized ways to most signals and these custom pieces of code are  called signal handlers. </p>
<p>For example  you can use the command:</p>
<pre>
kill -3  process_id, or
kill -QUIT  process_id, 
</pre>
<p>where  process_id is the process number of your Java program.</p>
<p>As far as I  know in order to get  this on Windows you  must be at the console with  command  prompt window running the application and press &lt;Ctrl&gt;+Break.</p>
<p>Programmatically  you can generate a partial Java stack trace, which in this case is only the threads  information, by using <a href="http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html#getStackTrace()">getStackTrace()</a> or <a href="http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html#printStackTrace()">printStackTrace()</a> of the Throwable class. </p>
<p>Sometimes  it is necessary to generate a ST remotely or without disrupting the  application. One of the mechanisms to control ST generation from outside the  JVM uses RMI. Just create a remote interface, register the ST generator with  the rmiregistry and call it using a RMI client. The J2SE since version 5  provides the management and monitoring APIs that use JMX as the underlying  mechanism to expose the JVM information. The use of JMX allows the information  to be available locally and remotely to applications that support JMX.</p>
<p> Of course  you can get a ST if the JVM experiences an internal error. As in the case of  the broken web apps mentioned earlier, it will call its own signal handler to  print out the threads information.</p>
<h2>Where can I find it?</h2>
<p>Sometimes  the ST is a bit tricky to find. There are several start up scripts out there  that choose to redirect the console to /dev/null or some file. </p>
<p>For example  this is part of a JBoss start up script that would send your ST to /dev/null:</p>
<pre>
#!/bin/sh
#
#  description: JBoss Application Server Start-Up Script
...
#define  what will be done with the console log
#  JBOSS_CONSOLE=/dev/tty9 
JBOSS_CONSOLE="/dev/null"
if [ -n  "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
if [ -n "$SUBIT" ]; then
chown $JBOSS_USER $JBOSS_CONSOLE
fi
fi 
#if [ -n  "$JBOSS_CONSOLE" ] &amp;&amp; [ -e "$JBOSS_CONSOLE" ]; then
#  echo "WARNING: location for saving  console log invalid: $JBOSS_CONSOLE"
#  echo "WARNING: ignoring it and using  /dev/null"
#  JBOSS_CONSOLE="/dev/null"
#fi
</pre>
<p>As for your  own application, Java gives you the choice of directing program messages to the  system console, but error messages, say to a file. The class System has a  variable out that represents the standard output, and the variable err that  represents the standard error device. By default, they both point at the system  console. This shows how the standard error output could be re-directed:</p>
<pre>
Stream st =  new Stream(new FileOutputStream("output.txt")); 
System.setErr(st); 
</pre>
<h2>So what can the Stack Trace tell me?</h2>
<p>There are  several pieces of useful information that the ST can provide you with. Here are  some examples:</p>
<ul type="disc">
	<li><strong>Find the current thread</strong>: In theory the current thread should be the       last thread that was running when the snapshot was taken. If you have seen       a ST before you may have noticed that often the current thread is labeled       “current thread” next to the appropriate thread. Of course this is only a       good guess by the signal handler and sometimes the signal handler will be       marked as the current thread or on some platforms none of the threads will       be marked as the current thread.</li>
	<li><strong>Determine the thread states</strong>: You will see many different threads in       many different states in a snapshot from a ST – running, suspended,       waiting etc. This will help you resolve the execution state of your       application.</li>
	<li><strong>Locate deadlocks</strong>: If your program is in a deadlock then some of the system threads       will probably show up as the current threads, because there is nothing       else for the JVM to do.</li>
	<li><strong>Find why teh program hangs</strong>: Knowing the state of the threads you can see which ones are       waiting (states MW or CW). This is especially valuable for debugging       distributed applications or applications which open socket and have to       deal with network time-outs.</li>
	<li><strong>Debug third-party applications</strong>: If you don’t have access to the source       code, examining the ST can give you a good insight of how the application       is working or why it is not :-)</li>
</ul>
<h2>Isn’t it sometimes… TOO  verbose..?!?</h2>
<p>Yes a ST, can  get pretty verbose and this has been <a href="http://ptrthomas.wordpress.com/2006/06/06/java-call-stack-from-http-upto-jdbc-as-a-picture/">discussed  by people in great length</a> but this is partially due to the fact that Java  applications use all kinds of abstraction and components. Abstractions are  good: if it weren’t for the abstraction of the OSI Network Model you wouldn’t  be seeing this web page.</p>]]>

</content>
</entry>

</feed>