RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Project Lombok: Put an End to Java Verbosity : Page 3

The introduction of Project Lombok, a combination compile-time and development-time code generator, has made Java POJO verbosity history. Add Lombok to your daily coding practices, and you won't go back.


Additional Lombok Features

Besides the core features you just saw, Lombok comes with a few extras:
  • The @Cleanup annotation provides automatic resource management. For example, in the following snippet, @Cleanup ensures that the close() method will be executed before the method exits:
    @Cleanup InputStream in = new FileInputStream(args[0]);
    @Cleanup OutputStream out = new FileOutputStream(args[1]);
    This feature offers automatic resource management in Java 6 today; you don't have to wait for Java 7.
  • The @Synchronized annotation is an alternative to the synchronized keyword, but with better implementation:
    public static void hello() {
  • The @SneakyThrows annotation disables Java's checked exceptions:
    public void run() {
       throw new Throwable();
    Whether or not you choose to employ this feature (I have mixed feelings about it), it's a useful option to have.

Future Plans: Adding New Java Features

At the time of writing, Project Lombok was in version 0.8.5. The Lombok team's short-term goal was to stabilize Lombok and make it fault-free in Eclipse. Although I've had some minor issues with the early versions (e.g., some unexpected compilation warnings), simply recompiling the project got rid of them quickly. Overall, the benefits of using Lombok far outweigh any occasional Eclipse hiccups (which were quite rare, in my experience).

The long-term Lombok plans are far more grandiose. The two Project Lombok authors (Reinier Zwitserloot and Roel Spilker) want to intercept the Eclipse compilation process to the point where they can actually add new features to Java, particularly real closures. Read more about this ambitious goal at this Google Groups thread.

The Downsides

The main downside of Lombok is obvious: the development-time support works only in Eclipse. If Eclipse is not your IDE, then for now Project Lombok is not an option for you. You'll be able to add NetBeans and IntelliJ support in the future, but it will involve some pretty heavy IDE-specific hacking.

However, all Eclipse shops should look into adding Lombok into their daily tool chains today.

Bye-bye POJO Verbosity

With the introduction of Project Lombok, Reiner and Roel have made Java POJO verbosity history. When you add Lombok to your daily coding practices, there just isn't any going back. It's that simple. In my opinion, it's the most revolutionary addition to the Java ecosystem since the arrival of Eclipse itself.

Jacek Furmankiewicz is a Senior Java EE and Erlang/OTP developer at Radialpoint. He has 15 years of professional IT experience and is a Sun Certified Java Programmer (SCJP).
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date