Hero Image
- Mihai Surdeanu

Modernizer Maven Plugin

Today, I'm going to talk about a nice Maven plugin that you can use in your legacy project. It's called Modernizer.

What is doing this plugin? The answer is quite simple: basically, it detects uses of legacy APIs from Java. Sometimes, maybe we don't have the opportunity to work at our daily job to new applications, developed from scratch. Some of us, will have also to maintain some old application which started maybe with Java 1 and during time had to migrate to newer versions of Java. By the way, can you answer to a simple question: do you know what's the latest LTS version of Java?

In this kind of application, when we are doing a migration to a newer version of Java, we don't migrate also different Java collections or the API to newer ones. This behavior can have an impact from performance point of view and usually, translates into higher costs of having that application up and running. In addition, sometimes, our developer maybe doesn't know all the new stuff added and what can bring all those things to his application.

This is exactly where is Maven plugin comes. It helps you to detect uses of legacy APIs based on current Java versions that you are running. I can give you a simple example: StringBuffer vs StringBuilder. StringBuffer is present in Java since the beginning. Not the same case for StringBuilder, which was added in Java later on, in Java 5. Usually, we are using StringBuffer to concatenate strings. But, if you are using already Java 5, if you don't care about thread safety when you concatenate your strings (99% of all usecases), you should not use StringBuffer, you have to use StringBuilder because is faster. If you concatenate lots of strings, can have a significant impact in production. I encourage you to spend 5 minutes to look over this article.

Modernizer is available for you completely free and helps you to detect over 200 legacy APIs. You just have to use Maven as build system for your Java project. Integration is straightforward:


Happy modernizing!

Other Related Posts:

Multiple test executions with maven-surefire-plugin

Multiple test executions with maven-surefire-plugin

Hello boys & girls,

After a long period without no technical article, today, the time comes for a new one. It’s time to talk about how it’s possible to have multiple test executions using maven-surefire-plugin. First question is why we would like to multiple executions? Why one execution is not enough?

11th Oct 2020 - Mihai Surdeanu