Monthly Archives: April 2009

Oracle to Acquire Sun

After IBM, now is the turn to Oracle. Oracle buys Sun and pays $7.4 billion for that acquisition ($9.50 per share), $5.6 billion if we take into account Sun's cash. Is that a good thing or a bad thing for the Java community? Probably a good thing as it will allow Sun's project to benefit from Oracle's technologies. But only future will tell.

With Java, GlassFish, MySQL, OpenOffice, Solaris and its cloud computing services, that certainly widens Oracle's possibilities. Hopefully Oracle will continue supporting adequately those famous open source projects. I am not concerned about Java, but maybe more about MySQL. While MySQL could certainly benefit from Oracle's expertise in database field, Oracle could also put MySQL behind in order to promote its more profitable flagship product: Oracle's RDBMS. The same is true for GlassFish and WebLogic. In any case, it is a very quick way for Oracle to have an open source offering for their products.

If we only consider Java, I have to admit that I rather see Oracle acquiring Sun than IBM doing it. The reason is simple, IBM already offers a Java runtime and they are competitors in that field. An acquisition by IBM would reduce the competition in that areas, which is always a bad thing for customers. In my opinion, Sun's JVM largely beats IBM's one, but it would still be a bad thing to see one of them die to the benefit of the other.

kill -3 is your friend

One nice feature of Java runtime is when you send the QUIT signal to a Java process, it outputs the full thread dump to stdout. To send the that signal, just open a terminal and type:

kill -QUIT <pid>

or

kill -3 <pid>

Where <pid> is the process Id. This does not terminate the process; all threads will continue doing what they were doing.

That feature can be very useful when the application seems to freeze or when you have a very intermittent issue (intermittent deadlock). With the full thread dump, you can see what every thread was doing at that particular moment. So in case of a deadlock, you will be able to see what monitors and what threads are involved.

This can also be helpful to diagnose performance bottlenecks. Suppose you are load testing an application and it does not deliver the expected throughput, but the CPU usage is not the problem. For instance, with kill -3 you will notice right away that the size of the jdbc connection pool is not big enough and all threads are waiting on it for a connection to free.

Remote Debugging in Java

One thing people ask me from time to time is how to debug a remote Java application. This can be very useful when you experience problems at customer site, but cannot reproduce them in a development environment. We all know logs files do not always contain all information required to solve the issues. In such case, remote debugging can be very useful.

To start remote debugging, one simply needs to add extra VM arguments to the Java command line:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

Then, you can use the remote feature of your IDE to connect to the Java process in using the port specified above (8000). For Instance, in eclipse, you would do:

Run -> Debug Configurations… -> Remote Java Applications -> Create new

In the Host field, you enter the host name or IP of the machine running the Java application. In the Port field, you enter the port specified above (8000).

Note that remote debugging also works nicely with SSH tunnels.