Wednesday, February 2, 2011

Java News: Java Hanging and Java Desktop Popularity

There have been two significant stories in the world of Java this week and I briefly summarize them in this post.

Hanging javac and java

Rick Regan posted Java Hangs When Converting 2.2250738585072012e-308 to look at an issue which causes the javac compiler and java launcher both to hang. His post is based on Konstantin Preißer's feedback comment to Regan's previous post on a similar issue in PHP. The Regan post lists simple examples of Java code that respectively hang the compiler and the launcher. I include slightly adapted (to be more Javaese) versions of these next.

RuntimeHang.java (Hangs java Launcher)
package dustin.examples;

import static java.lang.System.out;

/**
 * Example that breaks Java runtime adapted from 
 */
public class RuntimeHang
{
   /**
    * Main function demonstrating Java runtime hang.
    *
    * @param args Command-line arguments: none expected.
    */
   public static void main(String[] args)
   {
      out.println("Test of Hanging Double Issue...");
      final double d = Double.parseDouble("2.2250738585072012e-308");
      out.println("Value: " + d);
   }
}

CompileHang.java (Hangs javac Compiler)
package dustin.examples;

import static java.lang.System.out;

/**
 * This class currently hands when javac is used to attempt to compile it.
 */
public class CompileHang
{
   /**
    * Main executable function.
    *
    * @param args Command-line arguments: none expected.
    */
   public static void main(final String[] args)
   {
      final double d = 2.2250738585072012e-308;
      out.println("Value: " + d);
   }
}

This story has received significant Java blogosphere attention. It has been referenced at DZone and is currently the most popular link (see next screen snapshot).


This post is also featured at reddit/Programming and there are already over 350 comments on the story there. Some of the comments point out that various tools can be used to find out a little more about what's happening with the hung application. For example, use of jstack and forcing the printing of the stack trace are mentioned.

The Groovy Programming post Java hangs when converting 2.2250738585072012e-308 — prevent DOS attacks with Groovy talks about preventing a potential denial of service (DoS) attack based on this issue using Groovy. In other alternative JVM language related posts, Charles Nutter demonstrates Working Around the Java Double.parseDouble Bug for JRuby.


Popularity of the Java Desktop

In the post Poll Result: Java on the Desktop Is in Desperate Need of Attention, Java.net editor Kevin Farnham analyzes results of the recent Java.net poll question, "Which area of Java/JVM technology most desperately needs serious attention in 2011?" The high number of responses (600+) and the high number of comments (10+) are both significantly higher than is typical for these poll questions, suggesting serious interest in this particular question.

I was not surprised at all at the feature that Java developers want some love to be shown to: "Java on the desktop." Some were surprised and that is understandable because many of the online resources (blogs, articles, and so forth) don't truly reflect the "typical Java developer." Although there are obviously exceptions, many blogs and articles focus on "newer" things and less on "older things." There are many reasons for this, including the perception that older things are already well covered or are not interesting to anyone. The fact that Sun/Oracle has shown little interest in the desktop outside of JavaFX also probably reduces the number of articles and blog posts on the subject.

One of the reasons I'm not surprised that nearly 1/3 of the respondents said "Java on the desktop" needs some love is that I continually hear Java developers who don't like Flex say they don't want to use Flex because "it's not Java." That's true, but I point out that JavaFX is hardly Java either (though this could change dramatically if Oracle delivers on what was offered at JavaOne 2010). The point is that many developers want the advantages of modern user interface technologies in a truly Java-based and standardized toolkit. There are some nice third-party Java-based toolkits out there, but they lack the commonality and widespread usage that comes with standardization.

On a related but different note, I see this as evidence of something I have long maintained: blog posts and software development social sites (such as DZone and reddit/programming) attract a subset of the software developers that is not necessarily representative of the greater software development community. Developers who choose to write and read posts and to post comments and get involved in discussions on these sites are not representative of all developers. Therefore, it is dangerous to assume that the number of recent posts on a particular subject reflect the true popularity or usage of that subject. Many posts and discussions are fueled by rabid software development enthusiasts and/or consultants needing to provide some new insights. Not all developers fall into this category. I believe more software developers should write blogs so that we can have a better overall picture of the industry via better sampling of the community.


Conclusion

The news about Java's compiler and application launcher hanging when trying to deal with a certain double representation is big news. However, my best guess is that even though many people reading this blog post will have already seen that news, there will be many times that number of Java developers who have not seen this article and may never even be aware of this issue because it will be fixed before they ever hear or read about it. Not all Java developers scour the headlines each day or even each week to see what's happening. The Java.net survey asking Java developers what they want to see receive the most attention seems to be overwhelming evidence that we as a community still wish to see Java on the desktop get some attention and TLC.

Happy Groundhog Day!

5 comments:

@DustinMarx said...

'Mark of the Beast' Bug Topples Java Apps is a new article on the vulnerability covered in the above post published in The Register.

@DustinMarx said...

Rick Regan has delved deeper into the Java hanging double issue in the follow-up post A Closer Look at the Java 2.2250738585072012e-308 Bug.
He states that "Java’s decimal to floating-point conversion routine, the doubleValue() method of its FloatingDecimal class, goes into an infinite loop when converting the decimal string 2.2250738585072012e-308 to double-precision binary floating-point." He also clarifies that "what actually happens is that doubleValue()’s correction loop oscillates between two values, 0x1p-1022 and 0x0.fffffffffffffp-1022." Regan then goes on to state that this is not the same bug as the recently discovered PHP bug and to identify an earlier bug report describing the same underlying bug (and including a proposed fix).

@DustinMarx said...

Rick Regan's post FPUpdater Fixes the Java 2.2250738585072012e-308 Bug documents an Oracle-supplied path for the hanging compiler and Java launcher described in my post. He also states that he has tried out the patch and that it did indeed resolve the compile time and runtime issues.

@DustinMarx said...

Oracle Security Alert for CVE-2010-4476 now formally covers this bug and includes a link to the Java SE Floating Point Updater Tool.

@DustinMarx said...

Java SE 6 Update 24 now addresses the floating point bug described in this blog post.