Modernizer alternatives and similar libraries
Based on the "Miscellaneous" category.
Alternatively, view Modernizer alternatives based on common mentions on social networks and blogs.
-
OpenRefine
OpenRefine is a free, open source power tool for working with messy data and improving it -
javaslang-circuitbreaker
Resilience4j is a fault tolerance library designed for Java8 and functional programming -
Codename One
Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web. -
Smooks
Extensible data integration Java framework for building XML and non-XML fragment-based applications
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Modernizer or a related project?
README
Modernizer Maven Plugin
Modernizer Maven Plugin detects uses of legacy APIs which modern Java versions
supersede.
These modern APIs are often more performant, safer, and idiomatic than the
legacy equivalents.
For example, Modernizer can detect uses of Vector
instead of ArrayList
,
String.getBytes(String)
instead of String.getBytes(Charset)
, and
Guava Objects.equal
instead of Java 7 Objects.equals
.
The default configuration detects
over 200 legacy APIs,
including third-party libraries like
Apache Commons,
Guava,
and Joda-Time.
Configuration
To run Modernizer, add the following to the <plugins>
stanza in your pom.xml
then invoke mvn modernizer:modernizer
:
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<javaVersion>8</javaVersion>
</configuration>
</plugin>
The <configuration>
stanza can contain several elements:
<javaVersion>
enables violations based on target Java version, e.g., 8. For example, Modernizer will detect uses ofVector
as violations when targeting Java 1.2 but not when targeting Java 1.1. Required parameter.<failOnViolations>
fail phase if Modernizer detects any violations. Defaults to true.<includeTestClasses>
run Modernizer on test classes. Defaults to true.<violationsFile>
user-specified violation file. Also disables standard violation checks. Can point to classpath using absolute paths, e.g.classpath:/your/file.xml
.<violationsFiles>
user-specified violations file. The latter files override violations from the former ones, includingviolationsFile
and the default violations. Can point to classpath using absolute paths, e.g.classpath:/your/file.xml
.<exclusionsFile>
disables user-specified violations. This is a text file with one exclusion per line in the javap format:java/lang/String.getBytes:(Ljava/lang/String;)[B
. Empty lines and lines starting with#
are ignored.<exclusions>
violations to disable. Each exclusion should be in the javap format:java/lang/String.getBytes:(Ljava/lang/String;)[B
.<exclusionPatterns>
violation patterns to disable, specified using<exclusionPattern>
child elements. Each exclusion should be a regular expression that matches the javap format:java/lang/.*
of a violation.<ignorePackages>
package prefixes to ignore, specified using<ignorePackage>
child elements. Specifyingfoo.bar
subsequently ignoresfoo.bar.*
,foo.bar.baz.*
and so on.<ignoreClassNamePatterns>
full qualified class names (incl. package) to ignore, specified using<ignoreClassNamePattern>
child elements. Each exclusion should be a regular expression that matches a package and/or class; the package will be / not . separated (ASM's format).<ignoreGeneratedClasses>
classes annotated with an annotation whose retention policy is runtime or class and whose simple name contain "Generated" will be ignored. (Note: both javax.annotation.Generated and javax.annotation.processing.Generated have retention policy SOURCE (aka discarded by compiler).)
To run Modernizer during the verify phase of your build, add the following to
the modernizer <plugin>
stanza in your pom.xml:
<executions>
<execution>
<id>modernizer</id>
<phase>verify</phase>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
Command-line flags can override Modernizer configuration and ModernizerMojo documents all of these. The most commonly used flags:
-Dmodernizer.failOnViolations
- fail phase if violations detected, defaults to true-Dmodernizer.skip
- skip plugin execution, defaults to false
Ignoring elements
Code can suppress violations within a class or method via an annotation. First
add the following dependency to your pom.xml
:
<dependencies>
<dependency>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-annotations</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
Then add @SuppressModernizer
to the element to ignore:
import org.gaul.modernizer_maven_annotations.SuppressModernizer;
public class Example {
@SuppressModernizer
public static void method() { ... }
}
References
- ASM provides Java bytecode introspection which enables Modernizer's checks
- Checkstyle IllegalInstantiation and Regexp checks can mimic some of Modernizer's functionality
- Google Error Prone JdkObsolete can mimic some of Modernizer's functionality
- Gradle Modernizer Plugin provides a Gradle interface to Modernizer
javac -Xlint:deprecated
detects uses of interfaces with @Deprecated annotations- Overstock.com library-detectors detects uses of interfaces with @Beta annotations
- Policeman's Forbidden API Checker provides similar functionality to Modernizer
License
Copyright (C) 2014-2022 Andrew Gaul
Licensed under the Apache License, Version 2.0
*Note that all licence references and agreements mentioned in the Modernizer README section above
are relevant to that project's source code only.