Change type
org.openrewrite.java.ChangeType
Change a given type to another.
Recipe source
GitHub, Issue Tracker, Maven Central
This recipe is available under the Apache License Version 2.0.
Options
| Type | Name | Description | Example |
|---|---|---|---|
String | oldFullyQualifiedTypeName | Fully-qualified class name of the original type. | org.junit.Assume |
String | newFullyQualifiedTypeName | Fully-qualified class name of the replacement type, or the name of a primitive such as "int". The OuterClassName$NestedClassName naming convention should be used for nested classes. | org.junit.jupiter.api.Assumptions |
Boolean | ignoreDefinition | Optional. When set to true the definition of the old type will be left untouched. This is useful when you're replacing usage of a class but don't want to rename it. |
Used by
This recipe is used as part of the following composite recipes:
- AssertJ best practices
- Change SDK Exception types from v1 to v2
- Change SDK S3EventNotification types from v1 to v2
- Change SDK TransferManager types from v1 to v2
- Change auth related classes from v1 to v2
- Change config related classes from v1 to v2
- Change region related classes
- Changed types of camel AI nested headers classes
- Clean up various issues with the code.
- Each camel-debezium module has its own subpackage corresponding to the database type
- JUnit Jupiter migration from JUnit 4.x
- Maps deprecated classes from Apache HttpClient 4.5.x to suggested replacements
- MemoryStateRepository and FileStateRepository were moved to another package and library
- Migrate Apache Commons Logging 1.x to SLF4J 1.x
- Migrate Apache HttpCore Nio Input Buffer classes to Apache HttpCore 5.x
- Migrate Apache HttpCore Nio Output Buffer classes to Apache HttpCore 5.x
- Migrate Fest 2.x to AssertJ
- Migrate Google Truth to AssertJ
- Migrate JBoss Logging to SLF4J
- Migrate JCL to Log4j 2.x API
- Migrate JUL to Log4j 2.x API
- Migrate Jackson from javax to jakarta namespace
- Migrate Jackson from javax to jakarta namespace
- Migrate JavaEE Code to Quarkus 2
- Migrate Log4j 1.x to Log4j 2.x
- Migrate Log4j 1.x to SLF4J 1.x
- Migrate Log4j 2.x to SLF4J 1.x
- Migrate Lombok to a Java 11 compatible version
- Migrate OpenSymphony classes to Struts 6.0
- Migrate Resource Classes
- Migrate SLF4J to Log4j 2.x API
- Migrate Spring Boot 3.5 deprecated classes and methods
- Migrate Spring Cloud Sleuth 3.1 to Micrometer Tracing 1.0
- Migrate Struts 2.0 interceptors to action "aware" interfaces
- Migrate TaskMetadata and ThreadMetadata
- Migrate
Admin.listConsumerGroups()tolistGroups() - Migrate
ConsumerGroupStatetoGroupState - Migrate
WordUtilsto Apache Commons Text - Migrate
clearto ApacheHttpClient 5.xCredentialsStore - Migrate
javax.annotationsto SpotBugs annotations - Migrate
setCredentialsto ApacheHttpClient 5.xCredentialsStore - Migrate classes from Jackson Codehaus (legacy) to Jackson FasterXML
- Migrate deprecated
javax.annotation.securitypackages tojakarta.annotation.security - Migrate deprecated
javax.annotation.sqlpackages tojakarta.annotation.sql - Migrate deprecated
javax.annotationpackages tojakarta.annotation - Migrate deprecated
javax.annotationtojakarta.annotation - Migrate from EasyMock to Mockito
- Migrate from Elasticsearch 8 to 9
- Migrate from JMockit to Mockito
- Migrate from Jakarta annotation API to JSpecify
- Migrate from Java Faker to Datafaker
- Migrate from JetBrains annotations to JSpecify
- Migrate from Micrometer annotations to JSpecify
- Migrate from Micronaut 2.x to 3.x
- Migrate from OpenRewrite annotations to JSpecify
- Migrate from OptaPlanner to Timefold Solver
- Migrate from Spring Framework annotations to JSpecify
- Migrate from Swagger to OpenAPI
- Migrate from
@ApiImplicitParamsto@Parameters - Migrate from
@ApiModelPropertyto@Schema - Migrate from
@ApiOperationto@Operation - Migrate from
@ApiParamto@Parameter - Migrate from
@ApiResponsesto@ApiResponses - Migrate from javax annotation API to JSpecify
- Migrate from springdoc-openapi-common to springdoc-openapi-starter-common
- Migrate moved types between Camel 3.x and Camel 4.x
- Migrate to Apache HttpCore Nio Classes to Apache HttpCore 5.x
- Migrate to ApacheHttpClient 5.x Classes Namespace from 4.x
- Migrate to Hibernate 6.6.x
- Migrate to Hibernate 7 JFR APIs
- Migrate to Hibernate 7.0.x
- Migrate to Kafka 2.5
- Migrate to Micrometer 1.13
- Migrate to Spring Batch 5.0 from 4.3
- Migrate to Spring Boot 2.2
- Migrate to Spring Boot 2.7
- Migrate to Spring Boot 3.2
- Migrate to Spring Data 2.3
- Migrate to Spring Framework 5.1
- Migrate to Spring Framework 6.2
- Migrate to Spring Kafka 3.0
- Migrate to Wicket 10.x
- Migrate to testcontainers-java 2.x
- Migrates from Netty 4.1.x to Netty 4.2.x
- Migrates to Apache Commons Collections 4.x
- Migrates to Apache Commons Lang 3.x
- Mockito 3.x migration from 1.x
- Prefer
java.nio.charset.StandardCharsets - Prefer
java.util.Optional - Prefer
java.util.function.Function - Prefer
java.util.function.Predicate - Prefer
java.util.function.Supplier - Quarkus 2.x migration from Quarkus 1.x
- Recommended Fit API becomes Assignment Recommendation API
- Rename
JavaTypeDescriptorandSqlTypeDescriptortoJavaTypeandSqlType - Renamed BasicAuthenticationHttpClientConfigurer to DefaultAuthenticationHttpClientConfigurer
- Renamed BasicAuthenticationHttpClientConfigurer to DefaultAuthenticationHttpClientConfigurer
- Renamed classes for API
- Renamed classes for elasticsearch,opensearch and spring regis
- Renamed classes for elasticsearch,opensearch and spring regis
- Renamed constants in camel-azure-files
- Replace deprecated Jakarta Servlet methods and classes
- Replace Removed WebLogicJtaTransactionManager from Spring Framework 5.3.x to 6.2.x
- Replace Removed WebLogicLoadTimeWeaver from Spring Framework 5.3.x to 6.2.x
- Replace
@MockBeanand@SpyBean - Replace
@SpringBootApplicationwith Quarkus equivalent - Replace
@Timed(Dropwizard) with@Timed(Micrometer) - Replace
ResourceResolverwithResourceHandler - Replace
ResourceResolverwithResourceHandler - Replace
doUpgrade(..)withServerContainer.upgradeHttpToWebSocket(..) - Replace
javax.security.auth.Policywithjava.security.Policy - Replace any Lombok log annotations with target logging framework annotation
- Replace deprecated DefaultJsonSchemaLoader with DefaultJsonUriSchemaLoader
- Replace deprecated Jakarta Servlet methods and classes
- Substitute deprecated Faces Managed Beans
- Substitute removed Faces Managed Beans
- Tag Enum has been deprecated
- Testcontainers 2 container classes
- The package scan classes has moved from camel-base-engine to camel-support - java
- Update Apache Commons Email to Email2 for Jakarta
- Update Jackson 2.x types to 3.x
- Update the Micronaut Data library
- Update the Micronaut Security library
- Upgrade to Axonframework 4.x Jakarta
- Upgrade to Axonframework 4.x Javax
- Upgrade to JUnit 5.14
- Upgrade to Spring Boot 2.5
- Upgrade to SpringDoc 2.1
- Upgrade to the latest Timefold Solver
- Use JUnit Jupiter
@Disabled - Use JUnit Jupiter
Executable - Use PlatformHttpHeaderFilterStrategy instead of HttpHeaderFilterStrategy
- Use
Assertions#assume*(..)and Hamcrest'sMatcherAssume#assume*(..) - Use
PingHealthIndicator - Use
RestClientBuilderCustomizer - Use
StateManagementStrategy - Use
StateManagementStrategy - Use
WebServerFactoryCustomizer - Use
WebTestClientBuilderCustomizer - Use
ZipExceptioninstead ofZipError - Use
com.ibm.jsse2instead ofcom.sun.net.ssl.internal.ssl - Use
com.ibm.net.ssl.www2.protocol.https.Handlerinstead ofcom.sun.net.ssl.internal.www.protocol.https.Handler - Use
com.sun.security.auth.module.Krb5LoginModuleinstead ofcom.ibm.security.auth.module.Krb5LoginModule - Use
getSSOCookieFromSSOTokenandlogout - Use
jakarta.elinstead ofjakarta.faces.elandjavax.faces.el - Use
jakarta.elinstead ofjakarta.faces.elandjavax.faces.el - Use
jakarta.xml.soap.SOAPFactoryto createSOAPElements - Use
java.lang.management.PlatformLoggingMXBean - Use
javax.lang.model.util.AbstractAnnotationValueVisitor9 - Use
javax.lang.model.util.AbstractElementVisitor9 - Use
javax.lang.model.util.AbstractTypeVisitor9 - Use
javax.lang.model.util.ElementKindVisitor9 - Use
javax.lang.model.util.ElementScanner9 - Use
javax.lang.model.util.SimpleAnnotationValueVisitor9 - Use
javax.lang.model.util.SimpleElementVisitor9 - Use
javax.lang.model.util.SimpleTypeVisitor9 - Use
javax.lang.model.util.TypeKindVisitor9 - Use
javax.validation.constraints - Use
org.springframework.boot.autoconfigure.http.HttpMessageConverters - Use
org.springframework.boot.web.servlet.error.ErrorController - Use
org.springframework.boot.web.servlet.support.SpringBootServletInitializer - io.quarkus.updates.core.quarkus30.AdditionalChanges
- io.quarkus.updates.core.quarkus319.MoveAccessTokenAnnotationToNewPackage
- io.quarkus.updates.core.quarkus32.InjectMock
- io.quarkus.updates.core.quarkus321.TlsRegistrySplitPackagesFix
Usage
This recipe has required configuration parameters. Recipes with required configuration parameters cannot be activated directly (unless you are running them via the Moderne CLI). To activate this recipe you must create a new recipe which fills in the required parameters. In your rewrite.yml create a new recipe with a unique name. For example: com.yourorg.ChangeTypeExample.
Here's how you can define and customize such a recipe within your rewrite.yml:
---
type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.ChangeTypeExample
displayName: Change type example
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.junit.Assume
newFullyQualifiedTypeName: org.junit.jupiter.api.Assumptions
Now that com.yourorg.ChangeTypeExample has been defined, activate it in your build file:
- Gradle
- Maven
- Moderne CLI
- Add the following to your
build.gradlefile:
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("com.yourorg.ChangeTypeExample")
setExportDatatables(true)
}
repositories {
mavenCentral()
}
- Run
gradle rewriteRunto run the recipe.
- Add the following to your
pom.xmlfile:
<project>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.22.1</version>
<configuration>
<exportDatatables>true</exportDatatables>
<activeRecipes>
<recipe>com.yourorg.ChangeTypeExample</recipe>
</activeRecipes>
</configuration>
</plugin>
</plugins>
</build>
</project>
- Run
mvn rewrite:runto run the recipe.
You will need to have configured the Moderne CLI on your machine before you can run the following command.
mod run . --recipe ChangeType --recipe-option "oldFullyQualifiedTypeName=org.junit.Assume" --recipe-option "newFullyQualifiedTypeName=org.junit.jupiter.api.Assumptions"
If the recipe is not available locally, then you can install it using:
mod config recipes jar install org.openrewrite:rewrite-java:8.64.0
See how this recipe works across multiple open-source repositories
Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.
Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.
Data Tables
- SourcesFileResults
- SourcesFileErrors
- RecipeRunStats
Source files that had results
org.openrewrite.table.SourcesFileResults
Source files that were modified by the recipe run.
| Column Name | Description |
|---|---|
| Source path before the run | The source path of the file before the run. null when a source file was created during the run. |
| Source path after the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
| Parent of the recipe that made changes | In a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all. |
| Recipe that made changes | The specific recipe that made a change. |
| Estimated time saving | An estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds. |
| Cycle | The recipe cycle in which the change was made. |
Source files that errored on a recipe
org.openrewrite.table.SourcesFileErrors
The details of all errors produced by a recipe run.
| Column Name | Description |
|---|---|
| Source path | The file that failed to parse. |
| Recipe that made changes | The specific recipe that made a change. |
| Stack trace | The stack trace of the failure. |
Recipe performance
org.openrewrite.table.RecipeRunStats
Statistics used in analyzing the performance of recipes.
| Column Name | Description |
|---|---|
| The recipe | The recipe whose stats are being measured both individually and cumulatively. |
| Source file count | The number of source files the recipe ran over. |
| Source file changed count | The number of source files which were changed in the recipe run. Includes files created, deleted, and edited. |
| Cumulative scanning time (ns) | The total time spent across the scanning phase of this recipe. |
| Max scanning time (ns) | The max time scanning any one source file. |
| Cumulative edit time (ns) | The total time spent across the editing phase of this recipe. |
| Max edit time (ns) | The max time editing any one source file. |