Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on
Updated: 3 hours 18 min ago

Understanding G1 GC Log Format

Thu, 2016-07-07 09:01

In Java 9, G1 GC will become the default garbage collector. One of the key features of G1 Garbage collector is its ability to limit the GC pause time (i.e. you can set the desired maximum pause time) without compromising on throughput.

As G1 GC is becoming the default Garbage Collector, its visibility and usage are going to increase dramatically. Thus to tune and troubleshoot G1 GC enabled JVMs, one must have a proper understanding of G1 GC log format. This article walks through key things that one should know about the G1 GC log format. Note: G1 GC log has lot of gory details of all the subtasks that are involved in the GC. To understand and make use of all those gory details, I would recommend using GC log analysis tool -

Categories: Java

Leaving Unhandled Errors Behind

Thu, 2016-07-07 08:01

The number of organizations investing in Scala is exploding, and for good reason. Scala combines Object Oriented and Functional capabilities as well as immutability, which makes it an extremely powerful foundation for applications that need to run at massive scale. This series of blog posts on Scala aims to bridge the gap between theory and practice by focusing on something that is not easily found on the open internet: Actual examples of functional concepts being used in production, at scale. We’ll even give you code samples! Part 1 of the series dives into something that’s near and dear to all of us: how to incorporate error handling as a primary concern with a minimal level of effort.

Disclaimer: This series assumes that you have a basic knowledge of Scala. You’ll still be able to read most of the examples if you don’t know Scala, but you might miss some nuances.

Categories: Java

JBoss EAP 7 Brings Red Hat Commercial Support for Java EE 7

Thu, 2016-07-07 07:01

JBoss EAP 7 has recently been fully Java EE 7 certified. For most developers this essentially represents serious commitment from Red Hat towards commercial support for Java EE 7. As many of us know, WildFly (the upstream community project for JBoss EAP) was one of the earliest Java EE application servers to get certified against Java EE 7. There are already numerous publicly known adoption stories for Java EE 7 on WildFly. However, a lack of Red Hat commercial support for WildFly had been a show-stopper for many - particularly very large enterprises. JBoss EAP removes this hurdle and is bound to be a further boost to Java EE 7 adoption. In my view JBoss has ranked for many years as one of the best Java EE implementations and with significant adoption. That said, one of the most valuable characteristics of Java EE is the rich implementation choices it offers (and hence the freedom from vendor lock-in).

JBoss EAP 7 joins the Java EE 7 compatible ranks of GlassFish 4, WildFly, WebSphere Liberty Profile 8.5, WebLogic 12.2.1, Hitachi Cosminexus and TmaxSoft JEUS. All of the Java EE certified offerings are always listed on the official Java EE compatibility page. For some perspective, few other open standards such as SQL have as many available implementations as Java EE 7 already has (and this is bound to only just keep getting better).

Categories: Java

Avoid These Naming Anti-Patterns...

Thu, 2016-07-07 06:01

Truism: source code is for people, not machines. So... minds with a rather different (and legit-globally state-dependent) cognitive architecture than a von Neumann machine. That includes all your current and future colleagues, your future self, anyone who might conceivably use your library in the future... and if your code is open-source, everyone from now until the heat/cold death of the universe.

So naming things in a human-readable ("self-documenting") way is important. And it's not easy (1, 2, 345, 6...). Getting it right can feel like a semi-unpleasant responsibility, like anything else that takes you out of that creative coding flow; but we've all scratched our heads (or gritted our teeth, or glared viciously) at someone else's opaque, idiosyncratic, or just confusing naming conventions ("Is this the same as that except that this has an underscore and that doesn't?? But the code looks different!... I think?")

Categories: Java

Creating PDF Documents With Apache PDFBox 2

Wed, 2016-07-06 10:01

Apache PDFBox 2 was released earlier this year and since then, Apache PDFBox 2.0.1 and Apache PDFBox 2.0.2 have since been released. Apache PDFBox is open source and Java-based, so it is easy to use with wide variety of programming language including Java, Groovy, Scala, Clojure, Kotlin, and Ceylon. Apache PDFBox can be used by any of these or other JVM-based languages to read, write, and work with PDF documents.

Apache PDFBox 2 introduces numerous bug fixes in addition to completed tasks and some new features. Apache PDFBox 2 now requires Java SE 6 (J2SE 5 was minimum for Apache PDFBox 1.x). There is a migration guide that details many differences between PDFBox 1.8 and PDFBox 2.0, including updated dependencies (Bouncy Castle 1.53 and Apache Commons Logging 1.2) and "breaking changes to the library" in PDFBox 2.

Categories: Java

JSON-B Public Review Draft Now Available

Wed, 2016-07-06 09:01

The JSON-B (Java API for JSON Binding) specification has recently released a public review draft. For those unaware, JSON-B is one of the key APIs slated to be included in Java EE 8. It is a very high level declarative, annotation-based API for processing JSON. Java EE 8 is also scoped to include an important revision of the lower level JSON-P (Java API for JSON Processing) specification.

These two APIs together are extremely important in making JSON a first class citizen of the standard Java platform, just like JAXP (Java API for XML Processing) and JAXB (Java API for XML Binding) did many years ago for XML. With these two APIs in place, Java developers can simply think of JSON as yet another Java serialization format. No more third party libraries and no more configuration - things will simply work out of the box when it comes to processing JSON. In my view these APIs are so critical they should indeed be moved to a modular Java SE release, much like JAXB and JAXP are already a part of Java SE.

Categories: Java

Modularity Changes in Ceylon

Wed, 2016-07-06 08:01

Ceylon has featured a modular architecture from the start. Not just for Ceylon users who write modules, but also within the Ceylon distribution. Historically we used to have very few modules, that were directly related to separate Git projects. Adding a new module meant a new repository and lots of changes in the build. Naturally, as the project grew, each of those modules also grew, and got new third-party dependencies, and occasionally adding a feature in one module was made tremendously easier by just adding that "one more" dependency between distribution modules, resulting in a big spaghetti graph of distribution modules that is common in older/evolved systems.

As we initially expected most Ceylon users to run their code using the ceylon run command, we figured that since they have the Ceylon distribution installed, it does not matter if they depend on more modules from that distribution than strictly necessary. Those modules had to be there anyway, so it would not save any bandwidth to reduce those dependencies.

Categories: Java

Magic-less Dependency Injection with JayWire

Wed, 2016-07-06 08:01

JayWire is a small, easy to use magic-less Dependency Injection library for Java 8. This article is a short tutorial on how to get started using it in projects of any size from small single- to large multi-module ones.

Why Another Dependency Injection Library?

Interestingly enough, the key feature of JayWire is not that it can supply objects as dependencies to other objects, nor that objects may be defined to have a scope (such as singleton scope, request scope, etc.). These are all supported by every other DI framework out there.

Categories: Java

AutoValue: Generated Immutable Value Classes

Wed, 2016-07-06 07:01

The Google GitHub-hosted project AutoValue is interesting for multiple reasons. Not only does the project make it easy to write less Java code for "value objects," but it also provides a conceptually simple demonstration of a practical application of Java annotation processing. The auto/value project is provided by Google employees Kevin Bourrillion and Éamonn McManus and is licensed with an Apache Version 2 license.

The AutoValue User Guide is short and to the point and this conciseness and simplicity are reflective of the project itself. The User Guide provides simple examples of employing AutoValue, discusses why AutoValue is desirable, short answers to common questions in the How Do I... section, and outlines some best practices related to using AutoValue.

Categories: Java

Fixing the Constructor Anti-Pattern

Wed, 2016-07-06 06:16
/** * This post is intended to be a 101 quickie for the less experienced. * It does not provide new or innovative ways of solving a certain problem, * just summarizes a topic the way I see it. * **/

This is a topic many have already talked about (a lot), but it still pops up from time to time. Strangely enough, not only in case of junior developers.

The Situation

You are given a constructor full of business logic; it opens files, sockets, creates message queues etc. Usually it looks something similar to the snipped below:

Categories: Java

Java 8 Optional—Replace Your Get() Calls

Tue, 2016-07-05 10:01

Optional class were introduced in order to prevent NullPointerException, but method get() used to retrieve the value inside the Optional might still throw a NoSuchElementException.

Different name, same issue?

Categories: Java

How Functional Programming Will (Finally) Do Away With the GoF Patterns

Tue, 2016-07-05 08:01

A recent article about various ways to implement structural pattern matching in Java has triggered my interest:

Categories: Java

OCI and DZone Present Grails Quickcast #4: Angular Scaffolding

Tue, 2016-07-05 07:01

Today we bring you a new Grails Quickcast, where Grails Core Team Member James Kleeh brings together Grails and Angular. In less than ten minutes, you’ll learn how to use Grails to build a simple reactive site in Angular.js. The Grails Quickcast is brought to you from OCI and DZone. You can get more Grails info at

This Quickcast walks you through using the Angular Scaffolding for Grails to build a fully functional web app, using a simple blog format for demonstration. The tutorial explains how to have Grails set up a REST endpoint and all the Angular modules needed to get the web app running.

Categories: Java

Some Thoughts on the Single Responsibility Principle

Tue, 2016-07-05 07:01

SOLID (single responsibility, open-closed, Liskov substitution, interface segregation and dependency inversion) is a set of principles popularised by ‘Uncle’ Bob Martin that aim to guide developers in implementing good software design. The principles define how Object Oriented classes should relate to each other in order to create a codebase that is flexible and able to accommodate ongoing change.

The first of these, the Single Responsibility Principle (SRP) states that -

Categories: Java

Turn Around. Don’t Use JPA’s loadgraph and fetchgraph Hints. Use SQL​ Instead.

Mon, 2016-07-04 10:01

Thorben Janssen (also known from our jOOQ Tuesdays series) recently published an interesting wrap-up of what’s possible with Hibernate / JPA query hints. The full article can be seen here:

Categories: Java

Geek Reading: Functional Java and What Docker Really Is

Mon, 2016-07-04 09:01

Amazon AWS starts our day with the availability of their Elastic Network Adapter. This is more infrastructure from Amazon in their quest to have you own no IT hardware. On Ayende @ Rahien, we have another database internals post, this one about managing records. This post really starts to show how complex database systems are for the simplest use cases. Johanna Rothman continues her Product Owners and Learning series. This installment, as much of her content, is something everyone should read.

As always, enjoy today’s items, and please participate in the discussions on these sites.

Categories: Java

Get Your Java Package Structures Right

Mon, 2016-07-04 08:01

Packaging is one of the underrated features of Java. We use common sense to put things here and there, after some time everybody knows where certain things go and nobody cares anymore. Well, as long as it doesn't slow you down, it doesn't shock newcomers, and everybody on the team is fine with it, you should be just fine. Nothing wrong will happen. In the end, IDEs are so smart that it only takes a few clicks to reorganize the whole project. But we can do better! We can really benefit from a good package structure.

Naming Consistency

You don't have to start with a reversed domain. You should, but you don't have to. You can use camelCase, you can even use underscores and numbers! Only one thing is important: CONSISTENCY. Decide on a certain convention for the project and stick to it. Everybody_hatesInconsistencies_or_atleastIdo.

Categories: Java

Making Code Readable With Optional

Mon, 2016-07-04 07:06

Working with the ZAP API recently I found myself writing code like this:


The API was constructed around the idea of key/value pairs, and often returned objects that had to be cast to more specific types, which forces you to add a lot of boilerplate code for simple tasks like getting the ID of the last scan. Still, code like this was getting out of hand.

Categories: Java

Fixing Floating-Point Arithmetics With Kotlin

Mon, 2016-07-04 07:01

This week saw me finally taking time to analyze our code base with Sonar. In particular, I was made aware of plenty of issues regarding floating-point arithmetics.

Fun With Java’s Floating-Point Arithmetics

Those of you who learned Java in an academic context probably remember something fishy around FP arithmetics. Then if you never used them, you probably forgot about them. Here’s a very quick example of interesting it turns out to be:

Categories: Java

Generating a JAX-WS Webservice Client JAR From a WSDL

Sun, 2016-07-03 07:01

It seems generating a JAR file to consume a JAX-WS Webservice is fairly easy. But if you don't pay attention to the following points, it may suddenly become a nightmare for you.

So in this article, I will try to highlight some hidden and important configuration steps for creating a WS client JAR file.

Categories: Java