I use the Eclipse IDE as my daily driver for development. For a long time I have ignored the Java Platform Module System (JPMS) which was introduced in Java 9 and I’m still ignoring it today. If you want a proper module system simply use the better one that has existed for many, many years.

One point I’ve always put forward when arguing against the use of JPMS is that there is no way to create a simple project in Eclipse that uses the JPMS and has unit tests as part of the same project - much like the project setup that Maven uses. Only today I found out that this is indeed possible if you know how to configure your project and hack your way with the module system.

Let’s start by creating a plain Java project in Eclipse. Make sure you have a JDK configured that supports JPMS and create separate output folders for sources and class files. Eclipse new project wizard, first step

On the next page of the wizard make sure that “Create module-info.java” is checked.

Eclipse new project wizard, second step

When you hit Finish Eclipse will ask you for the module name of the project. Give your module a friendly name and start hacking away at your sources. Rather sooner than later you’ll get to the point where you want to add tests for your code. Add a new source folder that will contain your tests. Configure the source folder for your tests to generate its class files into a different folder and make sure you trigger Contains tests sources.

Eclipse new project wizard, second step

In the Libraries tab add the JUnit library to Classpath section, not to the Modulepath section. This hack enables the JUnit classes to be found for compiling and running the unit tests. But you’re not required to put the JUnit module into module-info.java, leaking the JUnit dependency out into the module path.


JAAS login module using PAM

23.12.2014 by Dirk Olmes

I recently had a look into JAAS for a customer project. The API is not 100% straightforward due to its design goal of hiding implementation specifics but I guess that’s the price you have to pay when specifying a generic API.

The JAAS guide talks about JAAS’s similarity …

read more

Compiling JDK classes with debug enabled

21.12.2014 by Dirk Olmes

I recently had to poke around with the JAAS classes in the JDK and wanted to step through with a debugger. But the JDK ships with a rt.jar that’s not compiled with debugging symbols enabled. Thus, debugging into the JDK sources is not much of a success.

Some …

read more

Autoboxing? not for me!

16.09.2011 by Dirk Olmes

Autoboxing appeared first with JDK5 and lots of people go crazy about it. At first look it’s a nice feature but the more you play with it the more I’m coming to the conclusion that the autoboxing implementation just sucks.

I will not rant about autoboxing pitfalls that …

read more

Localized ResourceBundle subclasses

14.05.2007 by Dirk Olmes

When working on Mule’s i18n support I stubled over a hidden gem in java. The ResourceBundle’s getResourceBundle method will build a candidate name and look for a class with this name in the runtime before resorting to loading properties files. I’d like to play around with this …

read more