Wednesday Dec 04, 2013

Global Day of Coderetreat 2013

The Global Day of Code Retreat is Saturday, Dec. 14th. It is a day-long, intensive practice event, focusing on the fundamentals of software development and design. By providing developers the opportunity to take part in focused practice, away from the pressures of "getting things done," the code-retreat format has proven itself to be a highly effective means of skill improvement. 

Events are happening around the world, and following JUGs are hosting retreats (add your JUG-sponsored event to the comments):

To learn more, visit

Tuesday Dec 03, 2013

Hackergarten at Conferences

In this video interview, senior architects Andres Almiray and Swen Reimers discussed hackagarten event taking place during the conferences. "A hackergarten is group of people coming together for a couple of hours. We decide the open source projects we want to code on. It can be fixing a bug, adding a new feature, creating a screencast, testing features and giving feedback to the project. The goal is to contribute to an open source project" explained Andres.

Devoxx Hackergarten focused on Java EE Lambda projects this year. Swen was the project lead and mentor for the Lambda projects. Some of them worked on JavaFX and Lambda event threads. "We discussed why things would not fit in an API, the lambda syntax, and what is available or not" Swen mentioned. They are running hackergarten around the world. The next ones will be at JFokus, JavaLand and the monthly events in Basel, Switzerland.

Monday Sep 23, 2013

The JavaOne 2013 Technical Keynote

by Timothy Beneke

Mark Reinhold, Oracle’s Chief Architect, the Java Platform Group, took the stage to kick off Sunday’s technical keynote at the Moscone Center. He began by quoting “father of Java” James Gosling. For Java to thrive, it must maintain what Gosling called the “feel of Java”. In other words, it must retain the key values of readability, simplicity, and universality.

“If we keep those,” said Reinhold, “then Java will remain not just productive but fun. It is not enough to simply add popular features each year.”

Lambda Expressions – The Single Largest Upgrade Ever
He turned to lambda expressions, which he described as the single largest upgrade to the programming model ever -- larger even than generics. “This is the first time we have done a carefully coordinated co-evolution of the JVM, the language, and the libraries all together – and the results still feel like Java,” said Reinhold.

He then welcomed Oracle Java Language Architect, Brian Goetz, to share the stage and began by remarking that while most developers understand that lambda offers a simple way to express code as data, some are not sure how it helps Java. Goetz responded that lambda expressions would more than help Java. “It’s going to change the way we all program in Java every day,” he explained. “Programming well is about finding the right abstractions. We want the code we write to look like the problem statements it’s trying to solve, so we can look at it and immediately know it’s correct. Java has always given us good tools for abstracting over data types. I wanted to do better in abstracting over patterns of behavior – that’s where lambda comes in.”

He illustrated this with some simple code that was, strictly speaking, “good” code, but weighed down with boilerplate and did not read like the problem statement it was trying to solve. It could be improved by using an inner class tool, but that too generated a lot of boilerplate. Reinhardt pointed out that improving the code made it less pleasant to work with, as if the developer was being punished for doing the right thing. This often causes developers to give up and do it the “dumb and ugly way”.

Lambdas can replace inner classes with a lambda expression which is simply an anonymous method that captures a behavior without a lot of syntactic boilerplate. “Lambdas are a nicer syntax,” said Goetz. “But they are also something deeper. It’s not just a compiler generating inner classes for you – it uses the invokedynamic feature to get more compact and higher performance code. It will make a qualitative difference in the way we program.”

If the right way to write a program is unpleasant, then people are less likely to do it according to Goetz. They are more tolerant of doing it the wrong way. He gave an example of how lambda expressions address this with the collections API involving a new abstraction to the JDK called stream and showed how to represent a simple query through applying a filter and mapping transformation, followed by an aggregation, in a way that is fused into one path without creating any intermediate weapons.

Reinhold summarized the key points: “So lambda brings 3 weapons to Java – syntax, performance and abstraction.”

“Plus parallelism,” Goetz added. He explained that Java 7 has the fork/join framework for parallel decomposition that is powerful, flexible, and highly efficient – but not the easiest thing to use. Goetz showed how lambdas enable better parallelism without needing to write fork join code: by asking the collection for a parallel stream it uses fork/join under the hood.

Lambda also helps with normal sequential code by making code clearer, less noisy, and easier to read. “When you have code that is hard to read, that’s where bugs come from. You are trying to maintain some code, you look at the code and think you know what it does, but don’t actually know what it does, and boom! – you’ve introduced a bug.”

All in all, the message was clear: Lambda expressions make Java code easier to read and easier to write.

Working with Lambda and the Collections Framework
For lambdas to be successful, they must work with the Java Collections Framework, which is now 15 years old. So an evolution of the interface was in order. Goetz’s team had to grow an interface over time without breaking implementations of the interface. They added a concept that allows developers to compatibly add a method to an interface, as long as a default implementation is provided.

Reinhold remarked that he has now written a couple of thousand lines of code with lambda features and really enjoyed it. “I can be more productive, and the end result still feels like Java,” he said.

To get started learning lambda expressions, Java developers can go to the OpenJDK Project Lambda page and download the developer preview builds there.

Reinhold reminded attendees that there is a great deal more in Java SE 8 besides lambda expressions. Developer preview builds can be downloaded at “Now is a great time to download JDK 8 and take it for a spin. Every planned feature is in there. It’s reasonably stable and it passes almost all of the tests. If you have any feedback, please send it in!” said Reinhold. 

Playing Chess
In the rest of the technical keynote, Oracle’s John Ceccarelli, head of engineering for Oracle’s NetBeans team and Oracle’s JavaFX architect Jasper Potts, arrived on stage to demonstrate a Duke pad running real Java via a chess program that was connected to a server. The iPad operated through an HTML5 client talking to a Java EE 7 back end with an EE server in charge of  messaging, communication, game state, and so on, with clients hook into it – all built with NetBeans. Jasper Potts further showed off the chess demo with an HTML5 client using a front end to a chess server that was managing the chess games. Then a robot, powered by Java ME 8, took over the game.

Oracle Software Engineer, Santiago Pericas Geertsen, who built the chess server, also described how it was built with 5 distinct functional modules.

In sum, attendees witnessed a server running Java EE 7 hooked up with a variety of clients, some written in HTML5, one written in JavaFX on a Duke pad, one using JavaFX 3D on a powerful laptop, plus a Java ME 8-powered robot contributing to the ongoing chess game. In the process, the powers of the Raspberry Pi were demonstrated.

Developers were encouraged to jump in the water, go for a swim, and have fun with NetBeans and Java embedded.

Java SE 9 and Beyond
Wrapping it up, Reinhold peered a bit into the future and suggested some possible directions for Java, some of which are already in development:

One is Java on GPUs, graphic processing units. As GPUs are being used more and more widely to process big data he suggested that it would be good to make Java work directly with the GPU rather than having to call out to some primitive interface. An OpenJDK called Sumatra has people working on this.

Reinhold spoke of the need for reification. Java’s generics, added in 2004, are based on the notion of erasure for good technical reasons as a sound way to create a type system that supports migration compatibility. But this creates programming problems in which the erasure approach severely limits what can be expressed. Reinhold suggested that introducing some reification and eliminating the “annoying dichotomy between primitive and reference types” would be of value.

He mentioned JNI 2.0 and said, “It just shouldn’t be so hard to integrate Java with native code after all these years.”

He called for memory efficient data structures: “As we get into big data – all this boxing and pointer chasing makes it hard to do big data well. We could have less boxing and pointer chasing and load a lot more data into memory.”

Finally, he talked about the notion of a truly modular platform. “The compact profile in Java 8 is a start but it is not flexible enough. We need to continue to unify the Java SE and Java ME platforms.”


OpenJDK Project Lambda

Watch Keynote and Session Highlights on Demand

Thursday Jan 24, 2013

Coding on Crete with Java Specialist Heinz Kabutz

In a new article, now up on otn/java by yours truly, titled “Coding on Crete: An Interview with Java Specialist Heinz Kabutz,” noted Java commentator and consultant Dr. Heinz Kabutz shares insights about the Java platform and talks about his exotic life working as a developer on the island of Crete. Kabutz is well known as the author of the Java Specialists’ Newsletter which reaches some 70,000 developers worldwide.

In a previous 2007 interview, Kabutz lamented the large number of developers who do not engage in unit testing. He offered an update on this:

“The one place where unit testing is sorely lacking is with concurrent code. There are some tools that help find race conditions and deadlocks, but they typically find about a dozen faults per line of code. With such an amount of false positives, discovering a real problem is impossible.

Did you know that there is not a single—not even one—unit test for the Java Memory Model (JMM)? We have to just accept that it works on the Java Virtual Machine (JVM) we are running on. The theory is that if we write our Java code according to the JMM, the code will run correctly on any certified JVM. Unfortunately, the certification does not test the JMM thoroughly. Apparently, there are some tests for the java.util.concurrent classes, and so they assume that if these work, then the JMM must also be correct for that JVM.”

When asked about the greatest performance issues he remarked:

“The biggest performance issue today is still that we often cannot pinpoint the bottlenecks. Customers usually approach us with problems that they have not been able to solve, no matter how many man-months they've thrown at them. The most recent issue I looked at boiled down to a simple race condition. If two threads insert an entry into a shared HashMap at the same time, and the key's hash code points to the same entry in the table, then the HashMap can be corrupted and you might get two entries pointing to each other. This means that whenever you try to call contains() on the map, you risk getting an infinite loop.”

Check out the article.

Thursday Nov 10, 2011

Wanted: Java Code Brainteasers

code sampleThe Jan/Feb Java Magazine will go out next week. It's full of great Java stories, interviews and technical articles. It also includes a Fix This section; the idea of this section is challenging a Java developer's coding skills. It's a multiple-choice brainteaser that includes code and possible answers. The answer is provided in the next issue. For an example, check out Fix This in the Java Magazine premier issue.

We are looking for community submissions to Fix This. Do you have a good code brain teaser? Remember, you want tease your fellow devs, not stump them completely! If you have a submission, here's what you do: 

1. State the problem, including a short summary of the tool/technique, in about 75 words.

2. Send us the code snippet, with a short set-up so readers know what they are looking at (such as, "Consider the following piece of code to have database access within a Servlet.")

3. Provide four multiple-choice answers to the question, "What's the fix?"

4. Give us the answer, along with a brief explanation of why.

5. Tell us who you are (name, occupation, etc.)

6. Email the above to JAVAMAG_US at ORACLE.COM with "Fix This Submission" in the title.

Deadlines for Fix This for next two issues of Java Magazine are Dec. 12th and Jan. 15th. Bring It!

Tuesday Oct 25, 2011

Perspectives on Garbage Collection

In a new article, part of the Developer Insight series, and titled “The Developer Insight Series, Part 6: Perspectives on Garbage Collection,” now up on otn/java, three leading Java developers offer insight into garbage collection.

Oracle Lab’s Ron Goldman notes, that, “Although automatic memory management has existed for more than 50 years, a lot of people still don't want it in their systems because it seems inelegant. It just strikes people as wrong – ‘It's my memory. I should be releasing it when I know it's no longer being used.’ Theoretically, that might be true, but in practice, programmers continue to forget to free up memory when they are done with it, or, even worse, try to free it up while it's still in use. The results? Buggy code that is apt to crash unexpectedly.”

Java Champion Kirk Pepperdine observes that, “Even though collection of very short-lived objects is almost free, high rates of object churn can still result in very inefficient GC numbers. Sometimes, the problem is simply that the Java Virtual Machine (JVM) doesn't have enough heap space. Monitoring GC activity will give you the hints you need for a successful heap-sizing exercise…”

And Oracle’s GC expert Tony Printesiz takes on eight myths about garbage collection, four of which are:

1. Reference counting GC will solve all my latency problems.
2. malloc and free will always perform better than GC.
3. Finalizers should be called promptly, as soon as objects become unreachable.
4. GC will eliminate all memory leaks.

The article provides a good context for developers to collect their thoughts about garbage. ;)

Read the complete article here.


Insider News from the Java Team at Oracle!

javeone logo


« April 2014