Saturday, October 27, 2012

Design Patterns: Mogwai or Gremlins?

The 1994 book Design Patterns: Elements of Reusable Object-Oriented Software introduced many software developers to the concept of "a catalog of simple and succinct solutions to commonly occurring design problems" that nearly every object-oriented software developer knows of today as "design patterns." Like most technical concepts (whether real or hype or somewhere in between), "design patterns" seemed to go through the normal stages of acceptance, rising rapidly from new idea to the prevalent way of thinking. As is always the case, this rapid rise in popularity led to backlash as design patterns were overused, abused, and otherwise used inappropriately. Today, design patterns seem to have become accepted as a useful tool when used correctly, but are generally recognized as dangerous in the wrong hands.

I have generally avoided devoting an entire blog post to a discussion of the good, the bad, and the ugly of use of design patterns, but a fellow software developer recently made up an analogy related to his observations of the use and misuse of design patterns that motivated me to write this post. Andy pointed out that there seems to be a tendency among some software developers to take an innocent and well-intentioned design pattern and turn it to evil, like turning a Mogwai like Gizmo into a Gremlin. In this post, I look in more detail at why this is a particularly fitting movie-themed analogy for turning effective use of design patterns into misuse and abuse of design patterns.

The 1984 movie Gremlins begins with an inventor and father in Chinatown purchasing a Mogwai. Mr. Wing, the owner of the store, does not want to sell the Mogwai to the inventor/father because "with Mogwai comes much responsibility." However, Mr. Wing's grandson sneakily sells the Mogwai to the inventor/father while warning him of three important things to be aware of related to care of the Mogwai. These three things are:

  1. "Keep him out of the light. He hates bright light, especially sunlight. It will kill him."
  2. "Keep him away from water. Don't get him wet."
  3. "But the most important rule, the one you can never forget, no matter how much he cries or how much he begs never, never feed him after midnight."

The appropriate use of design patterns is not affected by bright light, water, or eating after midnight, but the effects of not taking care when applying design patterns can have effects similar to not taking care of Mogwai properly.

Rapidly Spawning Design Patterns

When Mogwai or Gremlins get wet, spontaneous reproduction of more Mogwai or Gremlins occurs. The effect can be very similar for developers with design patterns. It is easy for a developer new to design patterns (or a developer who is excited about a new design pattern that he or she has recently learned) to apply too many design patterns to the same problem. If design patterns are good, more of them must be better. It is similarly easily for developers to fall into the trap of applying the same favorite design pattern to too many different, diverse, and unrelated problems (Maslow's Hammer).

Design Patterns Turned Evil

The Mogwai turned into mischievous Gremlins if they ate after midnight. Similarly, design patterns can be more evil than good if used inappropriately. A misapplied design pattern can obfuscate the intention of the code. Several design patterns used together can obscure the intent as well. Design patterns that are meant to facilitate better design can and often do lead to worse design when not used carefully. What is a design pattern in one situation might be an anti-pattern in a different situation.

One of the benefits of cataloging the common design principles as patterns is the ability to aid communication among developers and designers. However, design patterns can have the exact opposite effect (hindering understanding and communication) when misapplied or overused. I have also seen the case when a developer insists he or she is using a particular design pattern when he or she is really using a totally different design pattern or even an anti-pattern. In such cases, use of "design pattern" terminology also confuses rather than clarifying.

Well-Intentioned But Ill-Conceived

These problems most commonly arise when developers apply the design patterns because they believe they should rather than because they truly understand their value in a particular situation. Rather than applying the same design pattern to every problem or shoe-horning a design pattern into a situation in which it does not fit well, the developer needs to understand the advantages and objectives of different design patterns, along with trade-offs associated with the design patterns, to make an informed decision about application of design patterns.

Effective Use of Design Patterns

It seems to me that the best use of design patterns occurs when a developer applies them naturally based on experience when need is observed rather than forcing their use. After all, when the Gang of Four compiled their book on design patterns, they were cataloging existing design patterns that developers had been using already. Indeed, some of the patterns covered in their book became so popular that they were incorporated into Java language syntax and into other newer languages. For example, Java provided the interface (which aids many of the design patterns covered in the original design patterns book) and newer languages such as Scala and Groovy have added their own pattern implementations.

Use of Design Patterns: Gizmo or Gremlin?

When used properly, design patterns are attractive and desirable just as Gizmo the Mogwai is a desirable pet. However, when used inappropriately or applied without appropriate care and consideration, design patterns can turn into Gremlins, wreaking havoc on one's code base and hindering the ability to understand and maintain one's design. Note that the design patterns themselves are not necessarily the problem, but rather the people entrusted with proper use of design patterns determine whether they maintain desirable like Gizmo or undesirable like the Gremlins.

Wednesday, October 24, 2012

Java/NetBeans: Overridable Method Call in Constructor

I wrote about the NetBeans hint "Overridable Method Call in Constructor" in the blog post Seven Indispensable NetBeans Java Hints. In this post, I look at why having an overridable method called from a parent class's constructor is not a good idea.

The next class, Employee, is a contrived example of a class in which the extensible class's constructor calls an overridable method (setSalaryRange()).
package dustin.examples.overridable;

 * Simple employee class that is intended to be a parent of a specific type of
 * employee class. The main purpose of this class is to demonstrate the
 * insidious dangers associated with a constructor calling an overridable method.
 * @author Dustin
public class Employee
   private String lastName;
   private String firstName;
   private JobTitle jobTitle;
   protected int minWeeklySalary;
   protected int maxWeeklySalary;

   public enum JobTitle
      COMPUTER_SCIENTIST("Computer Scientist");

      private String displayableTitle;

      JobTitle(final String newDisplayableTitle)
         this.displayableTitle = newDisplayableTitle;

      public String getDisplayableTitle()
         return this.displayableTitle;

   public Employee(
      final String newLastName, final String newFirstName, final JobTitle newJobTitle)
      this.lastName = newLastName;
      this.firstName = newFirstName;
      this.jobTitle = newJobTitle;

   public void setSalaryRange()
      this.minWeeklySalary = 5;
      this.maxWeeklySalary = 10;

   public String toString()
      return  this.firstName + " " + this.lastName + " with title '"
            + this.jobTitle.getDisplayableTitle()
            + "' and with a salary range of $" + this.minWeeklySalary + " to $"
            + this.maxWeeklySalary + ".";

NetBeans flags the existence of an overridable method called from a constructor as shown in the next screen snapshot (NetBeans 7.3 in this case):

To demonstrate a common problem associated with overridable methods called in a constructor, a child class is needed. That is shown next with the code listing for ComputerScientist, which extends Employee.
package dustin.examples.overridable;

 * Class representing a specific type of employee (computer scientist), but its
 * real purpose is to demonstrate how overriding a method called in the parent
 * class's constructor leads to undesired behavior.
 * @author Dustin
public class ComputerScientist extends Employee
   private final int MIN_CS_WEEKLY_SALARY_IN_DOLLARS = 1000;
   private static final int MAX_CS_WEEKLY_SALARY_IN_DOLLARS = 60000;

   private int marketFactor = 1;

   public ComputerScientist(
      final String newLastName, final String newFirstName, final int newMarketFactor)
      super(newLastName, newFirstName, JobTitle.COMPUTER_SCIENTIST);
      this.marketFactor = newMarketFactor;

   public void setSalaryRange()
      this.minWeeklySalary = MIN_CS_WEEKLY_SALARY_IN_DOLLARS * this.marketFactor;
      this.maxWeeklySalary = MAX_CS_WEEKLY_SALARY_IN_DOLLARS * this.marketFactor;

Finally, a simple test driving application is required to run this example. That is shown in the next simple executable class (
package dustin.examples.overridable;

import dustin.examples.overridable.Employee.JobTitle;
import static java.lang.System.out;

 * Simple driver of the demonstration of why calling an overridable method in
 * the constructor of an extendible class is a bad idea.
 * @author Dustin
public class Main
   public static void main(final String[] arguments)
      final ComputerScientist cs = new ComputerScientist("Flintstone", "Fred", 5);
      final Employee emp = new Employee("Rubble", "Barney", JobTitle.CHIEF_EXECUTIVE_OFFICER);


One might expect the Computer Scientist, Fred Flintstone, to earn a weekly salary in the range of $1,000 to $60,000. However, that is not what is shown when the simple main application is executed (command line output and NetBeans output shown).

The reason the Computer Scientist's salary range is not correct is that the parent class's (Employee's) constructor must first be run before the extending class (ComputerScientist) is completely instantiated. The child class does override the setSalaryRange() method, but this overridden implementation depends on an instance variable (marketFactor) that is not yet initialized in the child instance when the parent's constructor calls this child class's overridden method.

There are multiple ways to avoid this problem. Perhaps the best and easiest approaches are those recommended by the NetBeans hint that flagged this issue.

As the screen snapshot above shows, NetBeans provides four easy and effective ways to deal with the issue of an overridable method called from the constructor of a class. Because the issue involves an "overridable" method and a child class that is not fully instantiated when that overridable method is invoked during parent's constructor, an obvious tactic is to make the parent class final so that it cannot be extended. This obviously will only work for new classes that don't have classes extending them. I have found that Java developers often don't put a lot of consideration into making a class final or planning for it to be extensible, but this is an example of where such consideration is worthwhile.

When it is not practical to make the parent class final, NetBeans offers three other approaches for addressing the problem of an overridable method called from the parent class constructor. Even if the class cannot be final, that method can have the final modifier applied to it so that the constructor is no longer calling an "overridable" method. This allows a child class to still extend the parent class, but it cannot override that method and so won't have an implementation that depends on instance level variables that have not yet been initialized.

The other two ways shown that NetBeans uses to handle the issue of an overridable method being called from a constructor likewise focus on making that invoked method not overridable. In these other two cases, this is accomplished by making the invoked method static (class level rather than instance level) or by making the method private (but then not accessible at all to the child class).

In my particular example above, another way to fix the specific issue would have been to convert the instance-level marketFactor variable into a class-level (static) variable because that would move its initialization forward enough to be used in the invocation of the overridden method. The problem with this method is that there is still an overridable method invoked from the parent constructor and that method can have more than one state issue to worry about.

In general, I try to be very careful about a constructor calling methods as part of an instance's instantiation. I prefer to use a static factory that constructs an object and calls static methods to set that instance appropriately. It is always wise to be cautious with implementation inheritance and this issue of overridable methods called from a constructor is just another in the list of reasons why caution is warranted.

My example shown in this post is relatively simple and it is easy to figure out why the results were not as expected. In a much larger and more complicated example, it might be more difficult to find this and it can lead to pernicious bugs. NetBeans helps tremendously by warning about overridable methods called from constructors so that appropriate action can be taken. If a class is not extended and there are no plans to extend it, then making the class final is easy and appropriate. Otherwise, NetBeans presents other options for ensuring that all methods called from a constructor are not overridable.

Thursday, October 18, 2012

The Checker Framework

One of the interesting tools I learned about at JavaOne 2012 is The Checker Framework. One of the Checker Framework's web pages states that the Checker Framework "enhances Java’s type system to make it more powerful and useful," allowing software developers "to detect and prevent errors in their Java programs." One way to look at the Checker Framework is as an implementation of what JSR 305 ("Annotations for Software Defect Detection") might have been had it not fallen into the Dormant stage.

The intention of JSR 308 ("Annotations on Java Types") is to "extend the Java annotation syntax to permit annotations on any occurrence of a type." Once JSR 308 is approved and becomes part of the Java programming language, annotations will be allowed in places they are not currently allowed. Although JSR 308 is still in Early Draft Review 2 stage, Checker Framework allows a developer to include commented-out annotation code in places not currently allowed until made available by JSR 308. It is important to note here that JSR 308 only makes annotations more generally available (specifies more types of source code against which they can be applied) and does not specify any new annotations.

The Checker Framework requires Java SE 6 or later. The Checker Framework can be downloaded as a single ZIP file at The downloaded file can be unzipped to the directory checker-framework and then an environmental variable called CHECKERS can be set to point to that expanded directory's subdirectory "checkers." For example, if the is unzipped to C:\checker-framework, then the environmental variable CHECKERS should be set to C:\checker-framework\checkers.

One the Checker Framework has been downloaded, expanded, and pointed to by the CHECKERS environmental variable, it is time to try the Checker Framework out. The "long way" of running the Checker Framework is shown next and is used with the -version tag to verify that Checker Framework is applied:

java -Xbootclasspath/p:%CHECKERS%/binary/jsr308-all.jar -jar %CHECKERS%/binary/jsr308-all.jar -version 
java -Xbootclasspath/p:$CHECKERS/binary/jsr308-all.jar -jar $CHECKERS/binary/jsr308-all.jar -version 

The above should lead to output that looks something like that shown in the next screen snapshot.

The installed Checker Framework can now be applied to compiling code. The next code listing shows a simple class that specifies that a method argument should not be null via the checkers.nullness.quals.NonNull (@NonNull) annotation.

Example of Using Checker Framework's @NonNull
package dustin.examples;

import checkers.nullness.quals.NonNull;
import static java.lang.System.out;

public class CheckersDemo
   public void printNonNullToString(@NonNull final Object object)

   public static void main(final String[] arguments)
      final CheckersDemo me = new CheckersDemo();
      final String nullStr = null;

The above code listing shows a null being passed to a method with the argument annotated with @NonNull. NetBeans 7.3 flags this with the yellow squiggles and warning if hovered over. This is shown in the next screen snapshots.

Although NetBeans flags the null setting of a parameter marked with the @NonNull annotation, the compiler builds that code without complaint. This is where the Checker Framework comes in. Because it's a pain to type in the long command I showed previously, I either run the command shown above with a script or set up an alias as described in the Checker Framework Installation Instructions. In this case, I'll use an alias like this:

Setting Windows Command Line Alias for Java Checker
doskey javachecker=java -Xbootclasspath/p:%CHECKERS%\binary\jsr308-all.jar -jar %CHECKERS%\binary\jsr308-all.jar $*

The setting of this alias and running it with the -version flag is demonstrated in the next screen snapshot.

It is far easier to apply this approach with the alias set. This can be used to compile the class in question as shown next (command using my 'javachecker' alias and image showing result).

javachecker -d classes src\dustin\examples\*.java

The above command demonstrates that I am able to use normal javac options such as -d to specify the destination directory for compiled .class files and pass along the Java source files to be compiled as normal. The example also demonstrates that without specifying the checker processor to run as part of the compilation, the @NotNull additional typing is not enforced during compilation.

Before showing how to specify a processor to force the @NonNull to be be enforced during compilation, I want to quickly demonstrate that this compilation approach will still report standard compiler errors. Just for this example, I have renamed the "nullStr" variable passed to the method of interest on line 17 to "nullStry" so that it is a compiler error. The next two screen snapshots show this change (and NetBeans's reported compilation error) and how the Checker Framework compilation approach also reports the javac error.

Having shown that this approach to compilation compiles compilable code normally, reports compiler errors normally, and shows version appropriately, it is time to apply it to stronger type enforcement. I fix the compiler error in my code by removing the extra "y" that I had added. Then, I need to pass -processor checkers.nullness.NullnessChecker as an additional flag and argument to the compilation process. Note that there are other processors besides NullnessChecker, but I am using NullnessChecker here to enforce the @NonNull at compile time.

The following shows the command along with the output window demonstrating that command in action. Note that the compilation process is not allowed to complete and an error based on violation of the @NonNull typing is reported.

javachecker -processor checkers.nullness.NullnessChecker -d classes src\dustin\examples\*.java 

This blog post has introduced the Checker Framework and shown how to quickly apply it to stronger type enforcement in Java source code. I only focused on one type of stronger typing here, but the Checker Framework supplies other built-in type checks and supports the option of writing custom type enforcement checks.

Tuesday, October 9, 2012

NetBeans 7.3 Beta is More Than Easel: Hints and FXML Code Completion

NetBeans 7.3, which is now available in Beta, is already probably best known for its Project Easel features. However, in this post I look at some new features outside of Project Easel that I am happy to see now available in NetBeans.

New Hint: null Dereference

I'm a big fan of NetBeans's hints supports as proven by my blog posts on Seven Indispensable NetBeans Java Hints, Seven NetBeans Hints for Modernizing Java Code, Creating a NetBeans 7.1 Custom Hint, NetBeans 7.2 beta: Faster and More Helpful, and NetBeans 7.1's Unused Assignment and Dead Branch Hints. NetBeans 7.3 introduces another useful hint with the "null Dereference" hint.

The "null dereference" hint warns the developer when variables that might be null in certain cases are being dereferenced. This is shown in the next screen snapshot.

Before looking at another example of this hint in action, I want to first point out the new code editor Breadcrumbs feature. On the bottom of the above image, there are three greater-than inequality signs (> following the three respective labels "SevenThree", "processNullValue", and "if (valueStr != null). These correspond to places in the code where the highlighted variable is used (class it is used in, method it is used in, and conditional within method it is used in). Clicking on any of the greater-than signs expands possibilities of where that variable is next used. This is a handy feature for following code flow for a certain variable within static code.

Returning to the NetBeans "null deference hint," another way to demonstrate that new hint in code is via use of the NetBeans @org.netbeans.api.annotations.common.NullAllowed annotation. Applying this annotation to a parameter of the example method shown earlier leads to the hint being displayed. As a side note, this NetBeans annotation has the feel of the annotations discussed in relation to the Checker Framework in the JavaOne 2012 presentation "Build Your Own Type System for Fun and Profit."

New Suggestion: Invert If Hint

There are times when it is helpful to invert a conditional, such as to improve readability of the code. NetBeans 7.3 provides this with the "Invert If" suggestion. This is demonstrated in the folowing three screen snapshots.

JavaFX FXML Code Completion

One of the features I missed most when working with JavaFX in NetBeans was the inability to enjoy code completion when using FXML. FXML does not have a defined grammar that facilitates any generic XML parser helping with code completion, but fortunately NetBeans 7.3 adds FXML completion to its repertoire (addressing NetBeans Bug 204741).

The next screen snapshot shows the FXML raw editor code completion in action. In this case, an "import" tag is recommended. Note that because I have SceneBuilder installed with my installation of NetBeans, simply clicking on an FXML file always brings that file up in SceneBuilder. To edit this file in XML directly as shown in the next screen snapshot, I right-clicked on the file's name in the Project browser and then selected the "Edit" option.

This version of NetBeans is still in beta and this FXML code completion seems a little buggy. I kept seeing the following exception message when trying to edit an existing FXML file:

The following is a portion of the stack trace logged in the reference log file:

WARNING [org.netbeans.modules.editor.bracesmatching.MasterMatcher]: Origin offsets out of range, origin = [366, 371], caretOffset = 382, lookahead = 2, searching forward. Offending BracesMatcher: org.netbeans.modules.xml.text.bracematch.XMLBraceMatcher@1e084dc
SEVERE [org.openide.util.Exceptions]
 at org.netbeans.modules.javafx2.editor.completion.impl.PropertyCompleter.complete(
 at org.netbeans.modules.javafx2.editor.FXMLCompletion2$Q$
 at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(
 at org.netbeans.modules.parsing.api.ParserManager$
 at org.netbeans.modules.parsing.api.ParserManager$
 at org.netbeans.modules.parsing.impl.TaskProcessor$
 at org.netbeans.modules.parsing.impl.TaskProcessor$
 at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(
 at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(
 at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(
 at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(
Caused: org.netbeans.modules.parsing.spi.ParseException
 at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(
 at org.netbeans.modules.parsing.api.ParserManager.parse(
 at org.netbeans.modules.javafx2.editor.FXMLCompletion2$Q$
 at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(
 at org.netbeans.modules.parsing.api.ParserManager$
 at org.netbeans.modules.parsing.api.ParserManager$
 at org.netbeans.modules.parsing.impl.TaskProcessor$
 at org.netbeans.modules.parsing.impl.TaskProcessor$
 at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(
 at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(
 at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(
 at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(
Caused: org.netbeans.modules.parsing.spi.ParseException
 at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(
 at org.netbeans.modules.parsing.api.ParserManager.parse(
[catch] at org.netbeans.modules.javafx2.editor.FXMLCompletion2$Q.query(
 at org.openide.util.RequestProcessor$
 at org.openide.util.RequestProcessor$
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor
java.lang.AssertionError: AsyncCompletionTask: query=org.netbeans.modules.javafx2.editor.FXMLCompletion2$Q@163ab6b: query.query(): Result set not finished by resultSet.finish()
 at org.openide.util.RequestProcessor$
 at org.openide.util.RequestProcessor$
Caused: org.openide.util.RequestProcessor$FastItem: task failed due to

Although NetBeans 7.3 is still in beta, I am enjoying using it and finding most things to work as I'd expect. A downside of using beta versions is the inevitable problems, but these have not been too big of a deal so far. I look forward to the production release of NetBeans 7.3.

Saturday, October 6, 2012

JavaOne 2012: Observations and Impressions

I am starting this particular blog post as I sit the the San Francisco International Airport waiting to board an airplane to head home after another satisfying but tiring JavaOne (2012) experience. It is difficult to write another blog post after having frantically written ~30 blog posts on the conference since the keynotes on last Sunday, but I want to record some of my observations and impressions of the conference while they're still relatively fresh. More than in previous years, I did embed some general observations (usually complaints) within posts on individual sessions.

This post is broken up into "the good," "the bad," and "the ugly" of JavaOne 2012. I want to emphasize that the conference overall was outstanding and I am appreciative of the opportunity to have attended. I hope the overall tone of my post reflects my overall highly positive feelings about this conference, but also presents a realistic portrait of the not-so-great aspects of the conference.

The Good

Overall Technical Content

There is a wide variety of things conference attendees look forward to in a conference. Many of us look forward to many of the same things in a conference. For me, the single most important attribute of a technical conference is its content. In that category, JavaOne 2012 was a success. There was actually too much good content to take it all in, but that's a welcome dilemma.

High Attention to Low-Level Details

I think Adam Bien made an important observation: even though it's nice to have community involvement in the conference, JavaOne presents a special opportunity to hear from the folks (mostly Oracle employees) working "in the trenches" on the latest Java APIs, specifications, and SDKs. Bien put it this way, "I mainly attended sessions delivered by Oracle engineers. 90% of this sessions were great with unique, deep technical content probably only deliverable by someone implementing the low level stuff. This is my personal motivation for attending JavaOne."

I've been to database-oriented conferences where many of the Oracle employees' presentations are heavy on marketing and slideware and low on technical detail. That's not the case at JavaOne where Oracle employees present the low-level details that Java developers want to hear.

Breadth and Scope of Technical Content

No matter in which dimension it is measured, JavaOne 2012 featured breadth and depth of content. Subjects in Java SE, Java EE, Java ME/embedded, web, JVM (alternate languages), and even some non-Java topics were available in nearly every session block. The keynotes (especially the Strategy Keynote and Technical Keynote) and select presentations that I attended provided roadmaps and vision for what lies ahead.

I enjoyed the breadth of "temporal usefulness" available in the presentations. I learned about things I like won't use anytime soon but are interesting and mind-expanding (Ceylon, JavaFX Embedded, Play Framework, Akka, Tiggzi), things that I'll definitely use in the intermediate future (Project Lambda, JSR 310 Date/Time API), things I'll use in the near future (Scala), and things I'll use almost as soon as I get home (JDK 7's jcmd, NetBeans Project Easel, Checker Framework). I was even able to learn several new tips and/or tricks for things for which I already had significant familiarity (Groovy, JavaFX, NetBeans's custom declarative language for refactoring/hints).

Attention to Community

I stated above that I agree with Adam Bien's assertion that one of the most valuable aspects of JavaOne is the access to people working directly on the future of Java. That being stated, I do appreciate Oracle making a real effort to reach out to the community. I posted during several presentations in which the speakers solicited feedback and ideas from the community and the audience. This was a nearly universal theme of any of the presentations related to anything open source. The JavaOne Community Keynote is the most obvious manifestation of JavaOne's commitment to community, but that theme was reiterated in numerous presentations.

The Host City

San Francisco is a great city to visit and offers lots to do for downtime and for people traveling with JavaOne participants who are not themselves attending JavaOne. Although I look forward to any opportunity I get to attend JavaOne, I think I look forward to the visit to San Francisco as much as the conference. It's definitely an interesting city to visit with great dining and other activities. The weather was pleasant and clear most of the time, though fog rolled in occasionally to remind us it is San Francisco and it was unusually hot in the early portion of the conference.

Oracle makes the presence of Oracle OpenWorld and JavaOne well-known throughout the city. Taxicabs feature signs for the respective conferences on their advertisements, there are signs all over the place, and some sections of the downtown near the conference venues (Moscone for Oracle OpenWorld and three Union Square hotels for JavaOne) for activities.

Extracurricular Activities

JavaOne provides numerous extracurricular activities beyond the technical content of the conference and beyond what the city provides. I didn't participate in many of these this year due to other commitments and activities, but the offerings are fairly impressive. The Oracle Appreciation Night, which featured Pearl Jam and Kings of Leon this year, is especially impressive. Although there are numerous disadvantages to JavaOne being the "little brother" held simultaneously with Oracle OpenWorld, some of these activities are available because of the bigger and better attended big brother conference being held simultaneously.

The Return of James Gosling

There was no denying that the "surprise" return of James Gosling to JavaOne (Community Keynote) left a big and very positive impression. The nostalgic factor (reminder of JavaOne's most glorious days) seemed to be as big as Gosling's presentation itself. I monitored a lot of the Twitter traffic during the week on "javaone" and no single Tweet or set of Tweets came anywhere close to being tweeted and re-treeted as often as mention of Gosling's return to JavaOne.

Increased Exposure to Tools

Master craftsmen in any industry are more successful with the correct tools. At JavaOne 2012, I became familiar with tools that I either had not been aware of previously or had not fully appreciated previously. These were either the subject of the presentations I saw or were used "incidentally" during projects and hallways discussions. These projects included JaCoCo Java Code Coverage Library (first read about in a Tweet), Checker Framework, the Oracle JDK 7 jcmd command-line tool, and NetBeans 7.3 Project Easel. I was also reminded that JDeveloper provides one of the better free UML tools, an important reminder now that NetBeans no longer supports UML (UML last supported in NetBeans 6.7).

Online JavaOne 2012 Coverage

Modern technology continues to make JavaOne more accessible to developer worldwide each year. Oracle made a lot of content available online early in the conference and individual members of the community also contributed significantly to the JavaOne coverage. Even some of the individual contributions were in part due to Oracle; I, for example, attended JavaOne 2012 on a blogger pass and was able to write posts like this one thanks to that complimentary pass. Between attending sessions, visiting some San Francisco sites, and writing my own blog posts, I've only been able to read a fraction of the other posts written about JavaOne 2012. I hope to catch up on those in coming weeks. I did try to watch Tweeted messages about the conference as it went along and was impressed with the quick coverage of important aspects of the conference.

Oracle has made "featured keynotes and highlights" available online (video). There have been several Oracle-originated blogs of interest including Oracle Outlines Roadmap for Java SE and JavaFX at JavaOne 2012, Virtual Collateral Rack (PDFs of sessions), Thursday Community Keynote: 'By the Community, For the Community', JavaOne 2012 Sunday Strategy Keynote, and The JavaOne 2012 Sunday Technical Keynote.

Individual JavaOne 2012 summaries include Jim Gough's Highlights From Java One 2012, Mark Stephens's 5 key things I learnt at Javaone2012, Yakov Fain's My Three Days at JavaOne 2012, and Trisha Gee's JavaOne: The Summary.

A Dose of Reality

The blogosphere tends to distort the reality of software development for a variety of reasons (dominated by "new" and "interesting" developments, for one). Attending conferences can be a good way to talk to others to get a better perspective on the reality of general software development. For example, at JavaOne 2012, there were several reminders that there is still significant software development that occurs on the desktop (it's not all web/mobile) and that the demise of UML has been overstated.

The Bad

These "bad" things are mostly accepted parts of the JavaOne experience. They are certainly outweighed by the good both in terms of number of "bad" or "good" things and in terms of importance of the things. In other words, there were more good things about JavaOne and the good things were more important to me than the bad things.

The Hotels Venue

The spreading of JavaOne over three Union Square hotels (Hilton, Parc 55, and Nikko) and the Masonic Auditorium would probably not be as big of a negative if JavaOne attendees were not aware of the presentations-friendly Moscone Center in the same city just blocks away. I am getting used to this venue and can navigate it better now than previously. I actually often enjoy the opportunity of going outside to move between buildings. However, I also found myself changing a couple selected presentations in the last couple of days because my original choice was in a particularly poor conference room area.

Poor Wifi

The Wifi at JavaOne simply cannot scale to the number of people wanting to use it via laptops, iPads, iPod Touch devices, Android tablets, and other personal devices. The Wifi was pretty good in the mornings before things got going and was outstanding on Thursday afternoon when a lot of people had already left.

The Food

Like the venues, the food is not completely awful; it's just not very good. It is sufficient for what is needed (providing nutrients and energy), but its lack of flavor stands in stark contrast to the excellent breakfasts and dinners I enjoyed again this year while in San Francisco.

Getting To and Leaving San Francisco

My flights into and out of San Francisco were both delayed due to fog in San Francisco and/or due to metering of traffic in the airport. In addition to this, we were told that the U.S. Navy's use on SFO for some of their Fleet Week exercises was the reason we sat on the runway for an extra twenty minutes. This is an example of where the good (being in San Francisco for the conference) outweighed the bad.

The Ugly

Inconsiderate and Intentionally Rude Misbehavior

Perhaps the ugliest part of JavaOne 2012 had little to do with the conference itself or its organizers, but was instead caused by a small portion of its attendees. It seemed that I repeatedly got behind the person trying to text and walk at the same time. These individuals slowed down traffic in the already congested halls as they walked more slowly and wandered in unpredictable directions and caused people to try to walk around them, causing additional issues. People tend not to drive and text as well as they might think and walking and texting is no different. The walking while texting may be less dangerous than driving while texting, but it's not without its dangers. There was one guy I was behind who was stopping intermittently while trying to eat and walk down the stairs because he was losing his lunch or snack. Continuing to try to do both made it so that neither was done well.

Other misbehavior that I observed were observed by others as well. These included unnecessary presentation hijacking, mobile phones ringing in sessions and some people even taking the call without leaving, people cutting in lines, and excessive entering and exiting of presentations at mid-point (most noticeably a problem when someone who sat in the first few rows made a show of his or her exit). The majority of attendees were well-behaved, but the small fraction of inconsiderate and even intentionally rude attendees was probably the ugliest part of JavaOne 2012. In defense of JavaOne, this "ugliness" seems to be more reflective of human behavior than of the conference.

Additional / Miscellaneous Observations

Trendy Topics

Some of the topics that seemed particular popular at this year's JavaOne included REST, HTML5, Project Nashorn, JDK8/Lambda, NetBeans, and Embedded/Raspberry Pi.


A major theme of JavaOne 2012 was "convergence." This theme was explicitly identified in the keynotes and several presentations such as "Looking into the JVM Crystal Ball" (convergence of Oracle's JRockit and HotSpot JVMs), "Mastering Java Deployment" (convergence of Java SE and JavaFX), "JavaFX on Smart Embedded Devices" (convergence of JavaFX and JavaFX Embedded, representing convergence of editions of Java [EE, SE, ME]), "NetBeans.Next - The Roadmap Ahead" (sharing of features between NetBeans and JDeveloper), and "Diagnosing Your Application on the JVM" (convergence of VM tools between JRockit and HotSpot and converge of command-line tools into single new jcmd tool).

One of the manifestations of this convergence of versions of Java is the renaming of versions. It was interesting to hear multiple speakers refer to current JavaFX as JavaFX 2.2 and the "next" major version of JavaFX as JavaFX 8 (version that was to be called JavaFX 3). This version naming change is documented in the post JavaFX 2.2 is here, and JavaFX 8.0 is on its way! Similarly, Java ME is seeing a version naming change as well: Java ME 3.2 is the current version and Java ME 8 is the "next" major version.

JDK 7 Update 10: The Next 'Big' Minor Release?

I heard multiple Oracle presenters mention features that they are already using in JDK 7 Update 10. Given that most of us who are using JDK 7 are using JDK 7 Update 6 (and JDK 7 Update 7 is the current regular download), it sounds to me like JDK 7 Update 10 may be the next "minor" release of JDK 7 with significant new tools for things such as application diagnosis and application deployment.

The naming of JDK minor releases with odd numbers for Critical Patch Updates (CPUs) and even numbers for "limited update releases" was announced previously. JDK 7u10 Build b10 is available in Developer Preview.

"Java" Becoming Bigger Than Ever

One thing that is clearer to me than ever before after attending JavaOne 2012 is that "Java" has become big for any one person to get his or her hands around the whole thing. Even some of the most knowledgeable experts I know in the Java community were heard to say that they would need to ask someone else to answer a specific question out of their area of expertise. It's becoming increasingly difficult for any one person to thoroughly understand all aspects of Java (JVM, EE, SE, ME, etc.). When you throw in alternate languages and new frameworks and tools, one person simply cannot learn or understand all of it. It's great that we have so many choices, but it can be frustrating to see entire areas of "Java" that would be interesting to delve into, but simply require too much time and effort to give it those areas the desired degree of attention.


Overall, I think JavaOne 2012 was a success by most peoples' measures. It certainly was by mine. I'm not the only one who was sorry to see it end.

JavaOne 2013 will be held September 22–26, 2013, in San Francisco.

Thursday, October 4, 2012

JavaOne 2012: Introduction to Ceylon

For my last session of JavaOne 2012, I elected to attend Emmanuel Bernard's and Stephane Epardaud's (both of RedHat) "Introduction to Ceylon" presentation held in Hilton Golden Gate 6/7/8.

It has become noticeably quieter in the Hilton since the ending of the morning's Community Keynote and especially since lunch. The Wiki is working great now (no more need to use my Verizon Broadband) and the Hilton's halls seem vacuous with so few people in them. This is typical of such conferences and I have mixed feelings about it: I like being able to more easily navigate the halls and enjoy the speedy Wifi, but there is an almost tangible drop in the energy level as well. It is also with some sadness that I think about this being the last session of the conference. On the other hand, I look forward to having some time to try out some of the things I've learned here and I look forward to seeing some of the presentations I missed here (the "opportunity cost" for attending other presentations).

The speakers stated that "Ceylon is not just vaporware" and said that they created it with the idea of creating a language that Java would be today if built from scratch but with the experience and lessons learned from using Java for many years. Ceylon was "initiated and led by Gavin King" with the intent to "improve upon frustrations of Java." They described Ceylon as a "powerful, readable, predictable" language which has a "platform, modularity, and tooling."

It was stated that Ceylon design highly prizes readability and may, if necessary, require a little more verbosity, rather than rely on tricks, to preserve readability. One of the goals is to make Ceylon very readable to Java and C-style language developers.

Slides with embedded color syntax highlighted code were shown to illustrate Ceylon code. Instead of private, public, and protected, Ceylon allows for either accessibility of shared ("public-ish") or else the default scope is scope-private. Another illustrated difference is that the Ceylon class did not need an explicit constructor. Ceylon provides "immutability by default." The assignment operator is reminiscent of Pascal with :=.

The illustrated example of inheritance looks similar to Java, but with more compact syntax. It was also pointed out that Ceylon has "very few keywords" and many of the items that appear to be keywords are really annotations. The string method is the Ceylon equivalent of Java's toString().

Ceylon does not allow method overloading because support of method overloading makes the compiler and other things more challenging. One common case for overloaded methods is optional parameters and Ceylon supports this via default parameters and named parameters. The second common use case for method overloading is to handle different (sub)types of parameters and Ceylon deals with that case via union types.

Ceylon allows a default implementation to be provided for an interface method with satisfies. This is not a "multiple inheritance mess" because there are no state initialization issues and an implementation must be provided if otherwise ambiguous. It was noted in the audience that this looks very similar to what Java 8 is bringing with interface default methods (brought in for Lambda to be merged into the SDK collections and other libraries).

Like languages such as Groovy and Scala, there are no primitive types in Ceylon (everything is an object, though Ceylon optimizes to primitives underneath the covers when appropriate) and so methods can be called directly on literal numbers. Ceylon also provides type inference. Although it appears to be dynamic, it is actually highly static.

Ceylon aims to avoid NullPointerExceptions encountered at the wrong time (is there a good time for NPEs?). Ceylon helps with this by forcing a question mark (?) the be appended on the end of the type of something that can be null. Once this is done, the Ceylon compiler enforces the variable of that type with the ? to be checked before accessed. Ceylon also has a Groovy-like null safety operator (?.).

Ceylon also supports functional programming. The speakers referenced JavaScript as the "biggest, most successful functional programming language." They showed code snippets using both FP-style closures and imperative-style comprehensions.

Ceylon supports a union type and an intersection type. A good reference on Ceylon types is available in Tour of Ceylon: Types.

Modularity is an important concept built into Ceylon. Packages belong to modules. In a dig on Jigsaw being moved to Java 9, it was noted that modularity was built into Ceylon from the start rather than "in 7, then in 8, then in 9."

The speakers introduced Ceylon Herd (Ceylon modules repository) and talked about the Ceylon Eclipse plugin.

The speakers addressed the Ceylon community. RedHat contributes and the community is encouraged to contribute. They use the "best tools" (github, ant, Eclipse, HTML5, Awestruct, Java, JavaScript, OpenShift, Play!) for contributing to the language. Their "To infinity..." slide stated that there are "five milestones to reach 1.0" with "some features targeted to 1.1." M1 is "done" (minimum all Java-style features and tools/IDE) as are M2 and M3. They expect M4 within weeks and M5 (Ceylon 1.1) is anticipated sometime after that. This is another presentation to add to the long list of presentations in which the speaker(s) requested the community to help them with their project.

One audience member was concerned about the theoretical formality of the Ceylon language. There is a Ceylon 1.0 Specification.

Ceylon supports extending Java classes and even depending on Java artifacts. Ceylon is a JVM-based language, but there is also effort to compile Ceylon to JavaScript.

The presenters stated that one should not use Ceylon for production yet (M5/Ceylon 1.0 has not been reached). However, now's a good time to play with Ceylon and report back any errors or negative features and help influence the language.

I liked a lot of what I saw about Ceylon, but it's still not clear to me why an entirely new language was necessary when many of Ceylon's advantages are common to other newer languages such as Groovy and Scala. There are some neat features to the language, but not enough "that's completely new" moments for me to leave more familiar languages. On the other hand, if I find myself with time on my hands and nothing interesting related to the languages I am already familiar with, playing with Ceylon could be an interesting hobby. However, if I have to choose between playing with and learning Scala and playing with and learning Ceylon, I'd have to favor Scala at this point.

I'd like to see a reason to use Ceylon compelling enough to justify using a language with a smaller community and less maturity rather than using another strongly typed language such as Scala or even rather than using an improving Java. A nerdy part of me really enjoys learning about new languages (hence my attendance last year at the presentation on Fantom and Gosu) and thinking about their assumptions, strengths, and weaknesses, but the more practical side of me likes to know the justification for learning a new language and ecosystem before investing much in that. This presentation allowed me to do the former (learn about a language new to me and give me some things to think about) while only costing me an hour of my time. It was an interesting well-spent hour that met my desire to be exposed to a new programming language.

JavaOne 2012: Getting Started with the NetBeans Platform

I stayed in the Hilton (Continental Ballroom 7/8/9) to see Geertjan Wielenga's (Oracle Development Tools Principal Project Manager) presentation "Getting Started with the NetBeans Platform." Geertjan's bio on his blog summarizes his involvement with NetBeans:

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Wielenga began his presentation by talking about how desktop-based graphical tools are underrepresented at conferences and pointed out that it's unlikely that flight controller software will be run out of a browser anytime soon. With this as a backdrop, Wielenga proceeded to write a desktop application on the fly using the NetBeans Platform (NetBeans 7.2).

Wielenga demonstrated building a new application from existing NetBeans constructs. He stated something that I wasn't aware of: there's not necessarily any requirement to use NetBeans IDE if using NetBeans Platform. He said the one connection is that you might think of the NetBeans IDE as the "reference implementation" of the NetBeans Platform.

There are "six quite small" JARs that are the minimum JARs needed for the modular-oriented NetBeans Platform.

Wielenga introduced the NetBeans Platform Showcase. He pointed out that one can get ideas for what can be done with the NetBeans Platform by looking at these examples and that many of them are even open source.

Wielenga talked about the NetBeans Platform supporting annotations so that Java developers can reduce their exposure to XML. The NetBeans Platform has an annotations processor that processes the in-code annotations and generates the appropriate XML.

One of the significant differences between NetBeans Platform and the Eclipse Rich Client Platform mentioned in this presentation is the NetBeans Platform's use of Swing (and JavaFX) versus Eclipse Rich Client Platform's use of SWT. An interesting observation made at JavaOne 2012 is the availability of eFX (NetBeans Platform meets JavaFX). JavaFX 2 allows for integration of JavaFX with Swing. This allows for an evolutionary path.

In a "slight diversion" (but one I thought was interesting), Wielenga mentioned that JDeveloper's best features can be more readily evolved into NetBeans. In this case, he used the specific example of JDeveloper's XML support. Earlier this week, the idea of using JDeveloper's UML support in NetBeans was mentioned.

An advantage of using the NetBeans Platform is that a decade's worth of lessons learned from practical experience building graphical user interfaces are incorporated into NetBeans Platform. Wielenga talked about the NetBeans Plugins Portal. An advantage of this is the ability to use pieces of software that have already been written and tested without needing to roll it out on one's own.

"The worst thing about Java Help" is the challenge of setting up the necessary XML content. NetBeans provides a wizard that handles this and makes it easy to generate an HTML representation of the help system.

Wielenga talked about one of the benefits of NetBeans Platform being that because it underlies NetBeans IDE, testing toolkits built for NetBeans IDE can often be applied to the applications based on the NetBeans Platform.

As a side note, NetBeans 7.3 is now available for download in beta form.

JavaOne 2012: Mastering Java Deployment

After grabbing an Italian Classic Combo for another JavaOne 2012 lunch, I headed to Hilton Imperial Ballroom B to see the presentation "Mastering Java Deployment." The speakers, both from Oracle, were Mark Howe and Igor Nekrestyanov.

Howe stated that a goal of the deployment team is to help Java developers deploy their applications to platforms of choice. He started by discussing "feature deprecation." In some cases, there are multiple ways to do the same thing. An example of this is jarjar and pack200. By deprecating redundant (especially older) approaches, they don't have to spend as much time supporting and fixing bugs on these seldom used things.

Howe showed a table of features being deprecated and removed in JDK 7, JDK 8, and JDK 9. In general, anything being deprecated and/or removed has alternatives and folks using the deprecated/removed features should start looking at which alternative works best for them.

As of JRE 7 Update 6, a totally Oracle-supported JRE will be issued for Mac OS X. Oracle's intention is to fix bugs and add features across JVMs for all deployment environments at the same time. The JRE 7 is "mostly compatible" with Apple's JRE 6. One change is to be more aligned with Oracle's JVM support for other platforms and have Oracle's updated update the JRE on Mac OS X rather than using the Mac "Software Update." One caveat is that "Chrome on Mac is currently unsupported (32-bit only)."

In continuing the theme of platform JVM feature polarity, JavaFX is now delivered with JRE for Linux. Howe's "Convergence of Java and JavaFX" slide showed a table indicating the progress of converging Java and JavaFX versions. The goal is for JavaFX to be one of the core libraries in the Java specification. Plans for JDK 8 include "Java launcher able to run JavaFX applications" and "jfxrt.jar on boot classpath for java and javac."

Howe introduced the Java Deployment Toolkit and described it as a "tool to simplify deployment of Java content in the browser." He contrasted deployJava.js ("original version") with dtjava.js ("better JavaFX support and portability"). The dtjava.js version "supports all deployment scenarios on all platforms" though there is no autostart on Mac or Linux.

Howe talked about WebStart and explained that "user experience is not quite as nice as you'd like it to be." He contrasted this with use of dtjava.js that allows developer to set parameters for control of launching from JavaScript. It makes for more control and better user experience. This also removes need for fixed code base. The code shown in a slide for using dtjava.launch requires JRE 7 Update 6 or later.

The goal of packaging tools is to "simplify deployment for application developers." The command-line tool bin/javfxpackager (or set of Ant tasks lib/ant-javafx.jar) can be used with JDK 7 Update 6. The "latest release of NetBeans" supports these.

Howe covered several motivations for completely self-contained applications. A self-contained applications contains "all the artifacts necessary to run your application." It has a private copy of the Java runtime and removes the dependency on the external JRE. Many of the motivations for self-contained applications revolved around issues of acquiring a current JRE to run the application.

Benefits of self-contained applications include the feeling of a native application, improved compatibility, easier deployment on a fresh system, optional administrative privileges, and support of newer distribution channels such as the Apple Apps Store. The caveats of self-contained applications include larger size (JRE included), "download and run" instead of WebStart's "click and launch," need to build package per platform, and other current limitations such as package needing to be built on the target platform and application updates being the responsibility of the developer."

To create a self-contained application, one needs JDK 7 Update 6 as well as optional third party tools such as WiX to build MSI on Windows. Howe showed a slide with Ant code for generating the self-contained application. The Developer Preview will allow a developer to select target version of JVM (current choices are JRE 7 Update 6 or JRE Update 10). The Developer Preview is expected to be available with JRE 7 Update 10. JDK 7 Update 10 is also anticipated to support Mac App Store support.

Like so many other presentations at JavaOne 2012, community feedback was solicited. In this case, the deployment team would like to know what people want and need for more effective web deployment of Java applications. Howe had a nice slide comparing executable JAR to WebStart to self-contained application.

Mac App Store does not allow applications to "rely on optionally-installed technology." Other requirements include need for application to "run in a sandbox" and "follow UI guidelines." Certain APIs (FileChooser) should be avoided. See JavaOne 2012 slides for "Deploy Your Application with OpenJDK 7 on Mac OS X" and future version of JavaFX Deployment Guide for more details.

Howe's "key points to remember" include merging of Java with JavaFX, new platforms for Java, new deployment options (self-contained application bundle and deployment to Mac App Store), and deprecation of old deployment features.

One of the attendees asked if there is a way to share a single JRE among multiple shared self-contained applications. The answer is that there currently is not a way to do this, but that a JRE can optionally not be included in the otherwise self-contained application.

In responses to another question, the speakers stated they are not aware of any plans to deprecate Swing. They also responded to yet another question that there is currently no Maven support for building self-contained applications (use Ant or NetBeans).

There were several good slides shown in this presentation that I'd like to look at more closely in the future. Fortunately, Howe stated that these will be made available. Much of what was covered in this session will be open source and audience members were encouraged to contribute to the open source projects.

JavaOne 2012: Up, Up, and Out: Scaling Software with Akka

After the late-ending Community Keynote, I headed to Hilton Golden Gate 3/4/5 to see Viktor Klang's (Typesafe) "Up, Up and Out: Akka" presentation. Klang is the technical lead on Akka. Akka is a "beautiful mountain in northern Sweden," is a Goddess, and is a Scala-based "toolkit and runtime for building highly concurrent, distributed, and fault tolerant event-driven applications on the JVM." Akka is not exclusive to Scala only and can be used "from Java today." Using Akka with Scala does allow you to do some things you cannot do with Akka when used with Java.

Akka is used by many large companies to solve real problems. Akka is built to scare in many directions and to provide extreme flexibility. One of Akka's goals is to "manage system overload."

Akka uses Actors: "Akka's unit of code organization." According to Klang, "Actors help you create concurrent, scalable, and fault-tolerant applications." Actors "keep many 'policy decisions' separate from the business logic." Actors originated in 1970s ("like all cool stuff in computer science") and Erlang has been using actors with "great success" for several years.

Klang warned to avoid "thinking in terms of shared state, a leaky abstraction." He added that threads and locks are "a means of execution" rather than structural. He said this mixes execution with business logic. Concurrent collections are good optimizations for local uses.

Actors are "distributable by design" and Klang had a slide listing several bullets explaining this statement. He stated that an actor can be an alternative to "a thread," "an object instance," "a callback or listener," "a singleton or service," "a router, load-balancer, or pool," "Java EE session bean or Message-Driven Bean," "out of process service," and "finite state machines."

Klang referenced a video of Carl Hewitt on actors. An actor is a "fundamental unit of computation that embodies several key characteristics."

Klang showed code examples in my preferred format in a presentation: embedded in his slides with color syntax highlighting. He showed step 0 ("DEFINE") in which his code defined the Actor's class and the Actor's behavior.

Once defined, the first operation (I - "CREATE") "creates a new instance of an Actor." The created Actor is extremely lightweight and its "state and behavior are indistinguishable from each other." He drove this last point home: "The only way to observe state is by sending an actor a message and seeing how the actor reacts." The Actor is "very strong encapsulation" of state, behavior, and message queue.

Akka provides an ActorSystem for creating Akka Actor instances. An instance of Props is provided to the Actor because actors need props.

Step 2 ("SEND") involves "sending a message to an Actor" and "everything happens reactively" and "everything is asynchronous and lockless." Akka supports a "fire and forget" mode with the actor's tell method. However, Akka provides guaranteed order of delivery. The reply is implemented in Akka with getSender().tell().

Step 3 ("BECOME") "redefines the Actor's behavior" and is "triggered reactively by receipt of message." The reasons one might want to change the behavior of an actor at runtime include supporting highly contended actor transforming to an actor pool or to implement graceful degradation.

Actors can supervise other Actors, leading to Step 4 ("SUPERVISE"). A "supevisor detects and responds to the failures of the Actor(s) it supervises" and Klang stated that this translates to "a clean separation and processing and error handling."

Klang talked about "failure management in Java, C, and C#" where you are "given a single thread of control." He put it this way in a bullet: "If this thread blows up, you are screwed." The implication of this is that all "explicit error handling" is done "within the single thread" and "tangled up" with the business code.

Klang said the way to deal with error handling is to push the error handling out away from the business logic. He then referenced the onion-layer error kernel. Klang talked about callbacks (preRestart and postRestart) provided for Actors to handle failures.

A Router is a special case of Actor. Klang showed a slide with code using a RoundRobinRouter. He also showed being able to define the deployment scenario outside of the code in configuration file and referencing that from the code with a path. He took this example even further to show code for "remote deployment" specifying a URL with the "akka" protocol, a host name, and a port.

Everything that Klang presented to this point is available today as Akka 2.0. Klang said that there will be Akka Cluster in the to-be-released-soon Akka 2.1. He asked for feedback to ensure that the correct APIs and correct functionality are available for clustering in Akka 2.2. More information on Akka clustering is available in the specification, the user guide, and the code itself.

Akka 2.1 will also feature Akka Camel based on Apache Camel. The Typesafe Console is also available to monitor an Akka application and there is a live demo of this available.

JavaOne 2012: Community Keynote

The third and final keynote, the Java Community Keynote, started the final day of JavaOne 2012. Although the first two keynotes were held in the Masonic Center, this one was held in Hilton Continental Ballroom.

Sharat Chander started the Community Keynote at the 17th JavaOne (JavaOne 2012). He stated that sixty percent of JavaOne 2012's content has been presented by the community. He said JavaOne is "by the community and for the community." He had those who participated on the submission committee stand up to receive recognition and applause. Chander's opening was perfect: it recognized the community, it was enthusiastic and was an appropriate duration.

Donald Smith joined Chander on the stage, acknowledged Chander's contributions to JavaOne, and started a wave in the audience in Hilton Continental Ballroom.

Gary Frost joined Donald Smith on stage to talk about Project Sumatra and Aparapi. It sounds like Project Sumatra is currently planned for JDK 9 (giving JDK 8 a change to introduce Lambda expressions).

An expert panel came to the stage to talk about their respective organizations' participation in the Java ecosystem. There were representatives from Eucalyptus, Twitter (Chris Aniszczyk, who stated that Twitter is built on JVM with Scala and Netty), Cloudera, Eclipse Foundation (Mike Milinkovich stated that the majority of Eclipse projects use Java), and Perrone Robotics (Paul Perrone).

One of the panelists stated that "low egos and high ambition level" coupled with desire to be truly innovative are what "smart venture capitalists" look for in startups. Another panelist stated, "Communities are great at innovation because they are open."

Georges Saab came to the stage to introduce one of the Duke's Choice Award winners. He had Martijn Verburg join him to talk about the London Java Community winning an award. Martijn talked about organizing a Java Users Group and the Adopt-A-JSR Program. Although I normally loathe the mixing of politics with technical seminars (my one and only complaint about the Colorado Software Summit), I have to admit that I laughed out loud when Verburg joked "if the presidential elections don't work out...the queen has agreed to take you back as a colony."

In another humorous quote, Bruno Souza explained Brazil's recent World Cup woes, "You cannot be good at everything, so Brazil will be good at Java." I also found another perspective of his interesting concerning spoken language (Portuguese/English) issues related to a programming language: "The important thing that user groups do is translate - to the local language, between technologies, and to bridge culture gaps" (as quoted by Trisha Gee). John K. Waters also captured another related Souza quote: "Java is the lingua franca" that transcends other language differences."

Paul Perrone of Perrone Robotics returned to the stage to discuss how Perrone Robotics uses Java with their Rumbles robotic vehicle. The bot used for the demonstration (Rumbles's "little brother") is built for outdoor use, so it had duct tape on its wheels so that it could have better traction inside (he said think chains on tires).

James Gosling was introduced with a bit of drama to talk about Liquid Robotics (Guillermo Castro called it!). Gosling explained that the robot he was talking about is not like the robots most of us think about with wheels or legs and arms. He talked about use of ARM processors, running Linux, and embedded C code.

One of the challenges Gosling discussed is to use as little power as possible, especially when in the "middle of a storm in the arctic" with no ability to use solar recharge. Due to high "Iridium satellite communication costs" ($1/kb or one million dollars for a terrabyte), they focus on using approach of short texts for communication. Gosling quipped, "We don't have a Big Data problem." Although they don't have a lot of data, what they do have is "precious." Gosling explained some of the hazards their robots face including big waves and even sharks.

Gosling built his own "NoSQL-ish" database and he said this was "either the most exciting thing or stupidest thing" he has done in a while. Gosling said he's been "a real Jelastic fan."

Although Gosling's presentation was interesting in its own right, I think the "effect" of having someone so obviously connected to Java and JavaOne return to speak at a JavaOne keynote (on the "other side" [community]) was probably more significant than the message itself.

As is typically the case with JavaOne keynotes, the Community Keynote went past its scheduled end time of 10:30 am. Gosling was allowed to take more than his allotted time, but this is not a big surprise for the "Father of Java." Gosling showed a demonstration using NASA World Wind (his "favorite Swing application," like "Google Maps with a real API"). Gosling stated to some applause, "It makes my head explode when there are people who think you can do everything in HTML." Gosling pointed out that he does like HTML and especially likes jQuery, but pointed out that some things are simply out of the realm of HTML still.

After throwing out some t-shirts, Chander asked for attendees to fill out the surveys to help make JavaOne more about the community. He also encouraged attendees to share knowledge with students and others wanting to learn Java. It has also been announced that Stephen Chin will be chair of next year's JavaOne.

Community has been a big theme of this edition of JavaOne and the Community Keynote is just one part of that. I have heard pleas for help and feedback from the community in a large percentage of the presentations and keynotes that I have attended this year.