Sunday Sep 30, 2012

The Java Specialist: An Interview with Java Champion Heinz Kabutz

Dr. Heinz Kabutz is well known for his Java Specialists’ Newsletter, initiated in November 2000, where he displays his acute grasp of the intricacies of the Java platform for an estimated 70,000 readers; for his work as a consultant; and for his workshops and trainings at his home on the Island of Crete where he has lived since 2006 -- where he is known to curl up on the beach with his laptop to hack away, in between dips in the Mediterranean.

Kabutz was born of German parents and raised in Cape Town, South Africa, where he developed a love of programming in junior high school through his explorations on a ZX Spectrum computer. He received a B.S. from the University of Cape Town, and at 25, a Ph.D., both in computer science.

He will be leading a two-hour hands-on lab session, HOL6500 – “Finding and Solving Java Deadlocks,” at this year’s JavaOne that will explore what causes deadlocks and how to solve them.

Q: Tell us about your JavaOne plans.

A: I am arriving on Sunday evening and have just one hands-on-lab to do on Monday morning. This is the first time that a non-Oracle team is doing a HOL at JavaOne under Oracle's stewardship and we are all a bit nervous about how it will turn out. Oracle has been immensely helpful in getting us set up. I have a great team helping me: Kirk Pepperdine, Dario Laverde, Benjamin Evans and Martijn Verburg from jClarity, Nathan Reynolds from Oracle, Henri Tremblay of OCTO Technology and Jeff Genender of Savoir Technologies.

Monday will be hard work, but after that, I will hopefully get to network with fellow Java experts, attend interesting sessions and just enjoy San Francisco. Oh, and my kids have already given me a shopping list of things to get, like a GoPro Hero 2 dive housing for shooting those nice videos of Crete. (That's me at the beginning diving down.)

Q: What sessions are you attending that we should know about?

A: Sometimes the most unusual sessions are the best. I avoid the "big names". They often are spread too thin with all their sessions, which makes it difficult for them to deliver what I would consider deep content. I also avoid entertainers who might be good at presenting but who do not say that much.

In 2010, I attended a session by Vladimir Yaroslavskiy where he talked about sorting. Although he struggled to speak English, what he had to say was spectacular. There was hardly anybody in the room, having not heard of Vladimir before. To me that was the highlight of 2010. Funnily enough, he was supposed to speak with Joshua Bloch, but if you remember, Google cancelled. If Bloch has been there, the room would have been packed to capacity.

Q: Give us an update on the Java Specialists’ Newsletter.

A: The Java Specialists' Newsletter continues being read by an elite audience around the world. The apostrophe in the name is significant.  It is a newsletter for Java specialists. When I started it twelve years ago, I was trying to find non-obvious things in Java to write about. Things that would be interesting to an advanced audience.

As an April Fool's joke, I told my readers in Issue 44 that subscribing would remain free, but that they would have to pay US$5 to US$7 depending on their geographical location. I received quite a few angry emails from that one. I would have not earned that much from unsubscriptions. Most readers stay for a very long time.

After Oracle bought Sun, the Java community held its breath for about two years whilst Oracle was figuring out what to do with Java. For a while, we were quite concerned that there was not much progress shown by Oracle. My newsletter still continued, but it was quite difficult finding new things to write about. We have probably about 70,000 readers, which is quite a small number for a Java publication. However, our readers are the top in the Java industry. So I don't mind having "only" 70000 readers, as long as they are the top 0.7%.

Java concurrency is a very important topic that programmers think they should know about, but often neglect to fully understand. I continued writing about that and made some interesting discoveries. For example, in Issue 165, I showed how we can get thread starvation with the ReadWriteLock. This was a bug in Java 5, which was corrected in Java 6, but perhaps a bit too much. Whereas we could get starvation of writers in Java 5, in Java 6 we could now get starvation of readers. All of these interesting findings make their way into my courseware to help companies avoid these pitfalls.

Another interesting discovery was how polymorphism works in the Server HotSpot compiler in Issue 157 and Issue 158. HotSpot can inline methods from interfaces that have only one implementation class in the JVM. When a new subclass is instantiated and called for the first time, the JVM will undo the previous optimization and re-optimize differently.

Here is a little memory puzzle for your readers:

public class JavaMemoryPuzzle {
  private final int dataSize =
      (int) (Runtime.getRuntime().maxMemory() * 0.6);

  public void f() {
      byte[] data = new byte[dataSize];
    byte[] data2 = new byte[dataSize];

  public static void main(String[] args) {
    JavaMemoryPuzzle jmp = new JavaMemoryPuzzle();

When you run this you will always get an OutOfMemoryError, even though the local variable data is no longer visible outside of the code block.

So here comes the puzzle, that I'd like you to ponder a bit. If you very politely ask the VM to release memory, then you don't get an OutOfMemoryError:

public class JavaMemoryPuzzlePolite {
  private final int dataSize =
      (int) (Runtime.getRuntime().maxMemory() * 0.6);

  public void f() {
      byte[] data = new byte[dataSize];

    for(int i=0; i<10; i++) {
      System.out.println("Please be so kind and release memory");
    byte[] data2 = new byte[dataSize];

  public static void main(String[] args) {
    JavaMemoryPuzzlePolite jmp = new JavaMemoryPuzzlePolite();
    System.out.println("No OutOfMemoryError");

Why does this work? When I published this in my newsletter, I received over 400 emails from excited readers around the world, most of whom sent me the wrong explanation. After the 300th wrong answer, my replies became unfortunately a bit curt. Have a look at Issue 174 for a detailed explanation, but before you do, put on your thinking caps and try to figure it out yourself.

Q: What do you think Java developers should know that they currently do not know?

A: They should definitely get to know more about concurrency. It is a tough subject that most programmers try to avoid. Unfortunately we do come in contact with it. And when we do, we need to know how to protect ourselves and how to solve tricky system errors.

Knowing your IDE is also useful. Most IDEs have a ton of shortcuts, which can make you a lot more productive in moving code around. Another thing that is useful is being able to read GC logs. Kirk Pepperdine has a great talk at JavaOne that I can recommend if you want to learn more. It's this: CON5405 – “Are Your Garbage Collection Logs Speaking to You?”

Q: What are you looking forward to in Java 8?

A: I'm quite excited about lambdas, though I must confess that I have not studied them in detail yet. Maurice Naftalin's Lambda FAQ is quite a good start to document what you can do with them. I'm looking forward to finding all the interesting bugs that we will now get due to lambdas obscuring what is really going on underneath, just like we had with generics.

I am quite impressed with what the team at Oracle did with OpenJDK's performance. A lot of the benchmarks now run faster.

Hopefully Java 8 will come with JSR 310, the Date and Time API. It still boggles my mind that such an important API has been left out in the cold for so long.

What I am not looking forward to is losing perm space. Even though some systems run out of perm space, at least the problem is contained and they usually manage to work around it. In most cases, this is due to a memory leak in that region of memory. Once they bundle perm space with the old generation, I predict that memory leaks in perm space will be harder to find. More contracts for us, but also more pain for our customers.

Originally published on

Thursday Jan 19, 2012

A File I/O Tutorial Featuring NIO.2

A tutorial on the front page of otn/java titled “A File I/O Tutorial Featuring NIO.2” explains the new file I/O mechanism introduced in the Java 7 release. The java.nio.file package and its related package, java.nio.file.attribute, provide comprehensive support for file I/O and for accessing the default file system. Though the API has many classes, developers need only focus on a few key entry points. The tutorial makes it clear that the API is intuitive and easy to use.

The tutorial begins by asking, “What is a path?” and then introduces the Path class, which is the primary entry point for the package. It explains Methods in the Path class related to syntactic operations and moves on to the other primary class in the package, the Files class, which contains methods related to file operations. It then introduces some concepts common to many file operations and explains methods for checking, deleting, copying, and moving files.

The tutorial offers a concise summary of the API with suggestions for further learning.

“The java.nio.file package provides extensive support for file and file system I/O. This is a very comprehensive API, but the key entry points are as follows:
•    The Path class has methods for manipulating a path.
•    The Files class has methods for file operations, such as moving, copy, deleting, and also methods for retrieving and  setting file attributes.
•    The FileSystem class has a variety of methods for obtaining information about the file system.”

More information on NIO.2 can be found on the OpenJDK: NIO project website on This site includes resources for features provided by NIO.2 that are beyond the scope of this tutorial, such as multicasting, asynchronous I/O, and creating your own file system implementation.

Read the complete article here.

Tuesday Oct 18, 2011

"Looking Back on JavaOne 2011" feature article

A JavaOne “afterglow” article, “Looking Back on JavaOne 2011” is up on otn/java. The article reviews the spirit, highlights, and feel of the 2011 JavaOne Conference.

From the article itself:

“It was at times difficult to take in all that has been achieved in the last year. The announcements at this year’s JavaOne came fast and furious -- the summer release of JDK 7 (including preview release for Mac OS X), the debut of JavaFX 2.0 (Oracle’s premier development environment for rich client applications), and ongoing progress on Java EE 7 (including taking Java EE into the Cloud). Meanwhile, at Monday’s Technical Keynote, it was pointed out that there are now 5 billion Java Cards in the world --contrasted with a global population of 6.5 billion. And then Tuesday’s Strategy Keynote brought Oracle’s announcement that it will open source JavaFX -- first the components, and then the rest of the framework -- as soon as there is approval from the OpenJDK community. And all the while, the OpenJDK community continues to grow, with recent members including IBM, Apple, SAP, and Twitter.”

Read the complete article.

Monday Oct 17, 2011

Java Community Keynote: Enabling Collaboration, Enabling Innovation

IBM, Java, and the Cloud

The morning JavaOne 2011 Community Keynote began with IBM, presented by Jason McGee, IBM Distinguished Engineer, Chief Architect, Cloud Computing. McGee focused on Java and Cloud computing-the challenges in the language and the JVM for running in the Cloud, how to make your applications elastic and scale well in the Cloud, and the latest innovations (driven by IBM and others) for deploying applications to the Cloud.

McGee explored several recent IBM offerings for the Cloud-including WebSphere eXtreme Scale, a Java based, in-memory data grid product for elastic scalability in Cloud environments; and IBM Workload Deployer, a Cloud deployment and management system for existing virtualized hardware. McGee ended by reiterating IBM's commitment to the Java community, noting their membership in OpenJDK as of 2010.

Community: Best Practices, Innovation, and Learning Resources

Sharat Chander, Principle Product Director, JavaOne Program Committee Chairperson, Oracle began his portion of the keynote by offering a moment of silence in respect for the passing of Apple's Steve Jobs, noting his passion and innovation in the world of technology. The Apple logo briefly appeared on the large screen.

Chander emphasized that Java isn't just about technology, it's also about community. Within this context, he first recognized Mike DeNicola, John Rose, and Patrick Curran, for their outstanding participation and leadership within the JCP this past year. And as part of ever-broadening the Java community, Chander next paid tribute to the Java Dutchess program-with over 400 groups around the world, globally connecting women in Java technology.

From there, Donald Smith, Director of Product Management, Java Platform Group, Oracle invited onstage a panel of representatives from the global Java community: Martijn Verburg, London Java Community; John Duimovich, OpenJDK; Deepak Bhole, OpenJDK; Stephen Chin, SvJugFx; and Bruno Souza, SouJava. The group noted that this was the first JavaOne conference with a community-themed keynote. In true connected community fashion, the group invited those watching the presentation to informally vote (via text message) on Java technologies and initiatives of current and future interest.

The panel members all urged active participation in Java User Groups, from both a technical and professional advancement perspective. Such community involvement not only drives open standards, they declared, but also drives innovation among vendors. The OpenJDK representatives then explored the challenges and promises of the initiative, agreeing that participants should have high expectations for openness, and to push on that. They strongly urged developers to download OpenJDK, and to use it.

Community: Moving Java Forward

Smith explored with the panel how the Java community can best take part in moving Java forward. The consensus was that the process ideally involves vision, innovation, and execution, and that the community can participate at all of these levels-getting involved via JUGs, as well as testing and submitting bug reports, and thereby helping Oracle and other Java vendors build the best and most innovative technologies. One technique being explored at some JUGs, to better facilitate participation, is to both stream them live and offer audio archives via Within the context of making community content as available as possible, Oracle announced their agreement with to host many of the JavaOne sessions on the learning site-including video, demos, and synchronized audio/slides.

Duke's Choice Award Winners

What JavaOne would be complete without acknowledging the Duke's Choice Award Winners (this year with community input in the selection and review process). Featured onstage were representatives of Rockwell Automation, for their Java Embedded factory floor automation solutions; Sodbeans Project, for their NetBeans-based accessibility suite to aid blind software developers; and JHome, a Glassfish/Java EE-based home automation system for the control of almost any device in the home, including lamps, gates, coffee machines, and more.
Java Posse Comes to Town

To the tune of Spaghetti Western soundtrack music, representatives of the fabled Java Posse next took the stage (to Sharat Chander's mock amazement). The Java Posse site has long been known for its podcasts offering news, discussions, interviews, and "general mayhem" surrounding the world of Java. The Java Posse members emphasized what they see as the three elements of Java-the language, the platform, and (most importantly), the Java community. "We have a development community that other development platforms dream of having," they said. They promised in-depth appearances from many of the Duke's Choice Award winners. And in parting the stage, they deputized Chander as an official honorary member of the Java Posse, presenting him with a 10-gallon hat.

In closing, JavaOne participants were urged to get involved and make their voices heard-to participate in the JavaOne Community Steering Committee, to participate in the JavaOne Program Committee, to submit speaker papers, to participate in the OpenJDK project, and to join a local JUG. Chander parted by noting that JavaOne 2012 would feature a community member as one of the keynote speakers.

Learn More:

WebSphere eXtreme Scale
IBM Workload Deployer
Java Dutchess
2011 Duke's Choice Award Winners
The Java Posse

OpenJDK Development Best Practices

At JavaOne 2011, Oracle Principal Member of Technical Staff, Kelly O’Hair, had a session on “OpenJDK Development Best Practices” that offered a lot of useful practical advice. He discussed current OpenJDK development procedures such as building, testing, code review, and creating a changeset, and integrating that changeset into a team repository.  In addition he covered "OpenJDK Developers' Guide" topics and looked at the challenges of integrating a change.

So what are the best practices when working on the JDK?
● When in doubt, ask
● When something does not work, report it
● Always be careful, rushing in changes is dangerous
● Do no harm, have a backup or backout plan
● Stay calm, nervous people make mistakes
● Be prepared for anything, because it will happen

When editing sources:
● Never edit the legal notices
● Respect the existing formatting
● Small surgical changes are best, easiest to review
● Well written comments are critical
● Do not assume anything about the compilers

Testcases are critical and not optional:
● Create a new one or modify an existing testcase
● Must be solid and work on all supported systems
● Must not be a resource hog (open 20,000 files)
● Must work in a shared VM mode (like a JUnit test)
● Assume someone else might be running the same test at the same time, and that someone might be you
● Continuous Build & Test
● Test gates or baseline testing
● But before you even get started making changes you must be able to completely build it and test it on your own system, this is a fundamental
● Linux builds are the easiest, so let's see what needs to happen

He suggested best practices short cuts for building:
● Always use local disk space
● Use /tmp if it has the space
● Use export NO_DOCS=true to avoid running javadoc
● Use ALT_JDK_IMPORT_PATH=${HOME}/jdk1.8.0

Kelly offered detailed principles related to testing, testing prep, editing, code review, changeset creation, why a push fails, and the team repository model.

His core ideas:
● Pick your environment, Linux is easiest
● Pick a stable state of repos, promoted build, oldest best
● Learn to build and test it, over and over, know what to expect, create a jdk to use as your import
● Editing working set files, read the Mercurial book
● Problemlist, changeset creation

Tuesday Aug 09, 2011

A Bug's Life: Java 7 Updates

by Dalibor Topic,  Java F/OSS Ambassador, Oracle Java Platform Group

The JDK 7 Updates Project in OpenJDK is now up and running. We've spent some time in the past couple of weeks discussing processes, finalized them, and started accepting changes destined for JDK 7 Update releases.

Changes going into a JDK 7 Update are typically bug fixes, coming to JDK 7 Updates through JDK 8. Bugs get reported through several channels - for example through Oracle's QA engineers running tests on early access builds, an OpenJDK developer working on some piece of code, or through the web bug report form.

When a Java developer or end user reports a bug through the web bug report form, a process kicks off. All bugs coming in through the web bug report form start with the initial priority 4, i.e. 'Low'. Priorities can go from 5, i.e. 'Very Low' all the way up to 1, i.e. 'Very High'. When you're starting to hack on OpenJDK, it can be easier to do so by picking out a couple of P4, or P5 bugs from the bug database in order to learn how the processes work with some success before you go on to tackle harder tasks.

There is a WebBugs team at Oracle that reviews the incoming bug reports, in order to weed out duplicates, or misfiled issues, and if necessary request additional information from the submitter. Not all bugs are created equal, so the low priority automatically assigned by the system to the incoming bugs sometimes needs to be adjusted, as well.

When adjusting the priority of a bug, we look at three aspects: Impact, Likelihood & Workaround. Impact is determined by taking a look at how severe an issue is: A VM crash would have a high impact, for example. On the other hand, the likelihood of the crash occurring could be very low. And finally, the existence of a workaround, in particular an easily applicable one, would also impact the priority of the bug. A high impact bug that strikes often and has no workaround would accordingly get a higher priority then a 'benign' bug that occurs rarely and has an easily applicable workaround.

The priority is not set in stone - as OpenJDK developers start investigating an issue in order to produce a fix for JDK 8, new information regarding impact, likelihood or workaround can emerge, resulting in an update of the bug's priority. For example, if a bug turns out to have a much higher likelihood to occur then initially thought, that could be a good reason to raise its priority. On the other hand, if e.g. an easily applicable workaround is found, that could be a good reason to lower it.

Another important dimension of a bug, along with its priority, is its state. For bugs in process of being addressed, there are three important states to be familiar with: 'Fix In Progress', 'Fix Available', and 'Fix Delivered'. The first one (obviously) means that a fix is in progress. 'Fix Available' means that a fix has been delivered into an OpenJDK Mercurial forest. Typically, the bug's evaluation in the bug database is updated to include a URL to the commit in OpenJDK, as well - look for the line starting with "" if you want to see the source code for a specific bug fix. The fix then progresses through a sequence of integrations into the respective Project's master. For JDK 7 Updates that sequence is fairly short, since we only have one integration forest (jdk7u-dev) in OpenJDK. Finally, once a fix appears in a build, its state is set to 'Fix Delivered'.

With these two bits of information, you can follow along your (and other people's) issues progress in JDK 8 and JDK 7 Updates. For some code, like HotSpot fixes, the path can be a bit longer, since the HotSpot team uses the HotSpot Express model to develop stable versions of HotSpot into multiple JDK releases, so the fix first needs to make it into a HotSpot build, before it can get into JDK 7 Updates through a bulk change. As fixes progress through integration stages, our testing machinery is hammering on them to make sure they work well, work well together, and hold up under pressure.

So, thanks for testing JDK 7, and letting us know about the bugs that bug you. With JDK 7 Updates now up and running, you can help us weed regressions out by testing early access builds, and of course by following along on the jdk7u-dev mailing list as fixes are proposed, reviewed and approved for JDK 7 Updates, and reporting issues you find to our bug tracker.

On a side note, we're working on updating our bug tracking infrastructure used in OpenJDK, which should further increase the transparency of both JDK 8 and JDK 7 Update development in the future.

(originally published on Dalibor Topic's blog.)

Thursday Jun 09, 2011

Moving to OpenJDK as the Official Java SE 7 Reference Implementation

Some interesting news from Henrik Stahl: Oracle will provide a Java SE 7 Reference Implementation based entirely on OpenJDK and make it available under GPLv2 (with Classpath exception) for open-source implementors (and BCL for commercial implementors).

Henrik also says that the existing TCK license for OpenJDK will be updated to cover Java SE 7.

Read the post in its entirety here.

Thursday May 19, 2011

JVM Language Summit Set for July 18-20

The 2011 JVM Language Summit -- an open technical collaboration among language designers, compiler writers, tool builders, runtime engineers, and VM architects -- is set for July 18-20 on Oracle's Santa Clara campus.

The agenda includes:

  • Three days of technical presentations and conversations about programming languages and the JVM
  • Prepared talks by numerous visiting language experts, OpenJDK engineers, and other Java luminaries
  • Many opportunities to visit and network with your peers
  • Da Vinci Machine Project memorabilia. (Useful for proving, to your grandchildren, that you were there.)
  • Dinner at a local restaurant, such as last year’s Faultline Brewing Company
  • A chance to help shape the future of programming languages on the JVM

For a taste, view the technical session video that we captured last year. Sessions will be recorded and published this year, as well.

For more information and to register, visit We hope to see you there!


Insider News from the Java Team at Oracle!



« November 2015