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:
- 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
- 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 Fest 2.x to AssertJ
- 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 Cloud Sleuth 3.1 to Micrometer Tracing 1.0
- Migrate Struts 2.0 interceptors to action "aware" interfaces
- Migrate
clear
to ApacheHttpClient 5.xCredentialsStore
- Migrate
javax.annotations
to SpotBugs annotations - Migrate
setCredentials
to ApacheHttpClient 5.xCredentialsStore
- Migrate classes from Jackson Codehaus (legacy) to Jackson FasterXML
- Migrate deprecated
javax.annotation.security
packages tojakarta.annotation.security
- Migrate deprecated
javax.annotation.sql
packages tojakarta.annotation.sql
- Migrate deprecated
javax.annotation
packages tojakarta.annotation
- Migrate deprecated
javax.annotation
tojakarta.annotation
- Migrate from EasyMock to Mockito
- 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 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
@ApiImplicitParams
to@Parameters
- Migrate from
@ApiModelProperty
to@Schema
- Migrate from
@ApiOperation
to@Operation
- Migrate from
@ApiParam
to@Parameter
- Migrate from
@ApiResponses
to@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.0.x
- 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
- Migrates Jackson 2.x base exceptions to Jackson 3.x base exceptions
- Migrates from Jackson 2.x to Jackson 3.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
JavaTypeDescriptor
andSqlTypeDescriptor
toJavaType
andSqlType
- 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
@MockBean
and@SpyBean
- Replace
@Timed
(Dropwizard) with@Timed
(Micrometer) - Replace
ResourceResolver
withResourceHandler
- Replace
ResourceResolver
withResourceHandler
- Replace
doUpgrade(..)
withServerContainer.upgradeHttpToWebSocket(..)
- Replace
javax.security.auth.Policy
withjava.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
- The package scan classes has moved from camel-base-engine to camel-support - java
- Update Apache Commons Email to Email2 for Jakarta
- Update Jakarta EE annotation Dependencies to 2.1.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 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
com.ibm.jsse2
instead ofcom.sun.net.ssl.internal.ssl
- Use
com.ibm.net.ssl.www2.protocol.https.Handler
instead ofcom.sun.net.ssl.internal.www.protocol.https.Handler
- Use
com.sun.security.auth.module.Krb5LoginModule
instead ofcom.ibm.security.auth.module.Krb5LoginModule
- Use
getSSOCookieFromSSOToken
andlogout
- Use
jakarta.el
instead ofjakarta.faces.el
andjavax.faces.el
- Use
jakarta.el
instead ofjakarta.faces.el
andjavax.faces.el
- Use
jakarta.xml.soap.SOAPFactory
to 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.gradle
file:
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("com.yourorg.ChangeTypeExample")
setExportDatatables(true)
}
repositories {
mavenCentral()
}
- Run
gradle rewriteRun
to run the recipe.
- Add the following to your
pom.xml
file:
<project>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.15.0</version>
<configuration>
<exportDatatables>true</exportDatatables>
<activeRecipes>
<recipe>com.yourorg.ChangeTypeExample</recipe>
</activeRecipes>
</configuration>
</plugin>
</plugins>
</build>
</project>
- Run
mvn rewrite:run
to 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.59.1
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. |
99th percentile scanning time (ns) | 99 out of 100 scans completed in this amount of time. |
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. |
99th percentile edit time (ns) | 99 out of 100 edits completed in this amount of time. |
Max edit time (ns) | The max time editing any one source file. |
Contributors
Tracey Yoshima, Jonathan Schneider, Laurens Westerlaken, Knut Wannheden, Tim te Beek, Sam Snyder, Nassim Jahnke, Kun Li, Greg Adams, Tyler Van Gorder, Joan Viladrosa, zac.kim, Michał Kosmulski, Jacob van Lingen, Ralph Sanders, Josh Soref, Adriano Machado, Patrick