Getting Started with Amazon Q Developer agent for code transformation
This blog will guide you step-by-step to start upgrading your Java 8 or 11 projects to Java 17 code easily using Amazon Q Developer agent for code transformation.
Vinicius Senger
Amazon Employee
Published May 15, 2024
Last Modified May 17, 2024
Upgrade language versions with Amazon Q Developer agent for code transformation
Amazon Q Developer agent for code transformation helps developers save hours (days, and weeks) of time by upgrading Java applications to newer versions easily and quickly. It enables developers to remove much of the undifferentiated work out of tedious tasks of maintaining, upgrading and migrating existing application workloads. It can intelligently upgrade your current language version, starting with Java. Amazon Q Developer agent for code transformation analyzes the entire source code of the application to be transformed, identifies mandatory package dependencies and frameworks and replaces deprecated code with working code. It also incorporates security best practices and executes tests to validate the new upgraded application. This enables you to safely upgrade apps to gain performance improvements while reducing security risks with older, unsupported Java versions. Currently, it can upgrade Java 8 and Java 11 code to Java 17 code.
You can find information on setting up Amazon Q in your IDE, prerequisites, and configuring your project in Q Developer agent for code transformation’s documentation here.
To set up Amazon Q Developer in your integrated development environment (IDE), complete the following steps. After installing the Amazon Q plugin, authenticate through AWS Identity and Access Management or AWS Builder ID. You can use Amazon Q for free, without an AWS account, by authenticating with Builder ID.
To get started, download the Amazon Q plugin for your IDE:
To sign in and authenticate, complete the steps in this section.
To quickly demonstrate Amazon Q Developer agent for code transformation capabilities, we are using a Spring sample application we developed with the following dependencies / pom.xml:
Before trying Q Developer agent for code transformation, you will need to make sure that you are being able to build, compile and package your project with Maven. We highly recommend you to build and verify the project before starting the transformation process, with maven you can type: mvn clean verify
Now you have the opportunity to review the source and target Java versions for your project transformation:
Visual Studio Code requires you to inform the local path to you JDK 1.8, if you need to discover it open a terminal and type: /usr/libexec/java_home -v 1.8, or you can type which java. Copy and paste in VS Code the path in the output:
Amazon Q Code Transformation will perform the following sequence of tasks:
- Build the project locally
- Upload the project
- Build the project in a secure environment
- Analyze the code and create a transformation plan
- Update code to new JDK version, dependencies and related code
- Build the project with new JDK version
- Upgrade deprecated code
- Finalize code changes and the transformation summary
- Make it available for you to download
To execute it can take up to 30 minutes, you can see this sequence of tasks in this accelerated video:
Amazon Q Developer agent for code transformation will generate a summary.md file with transformation details, in our Spring Java 8 application we had Java code and dependencies updated as follow:
Spring, jUnit and MySQL dependencies were updated in our pom.xml beside the Java 17 version:
The following information can help you troubleshoot common issues with Q Developer agent for code transformation:
We found that upgrading applications using Q Developer agent for code transformation leads to meaningfully large time savings for service teams tasked with upgrading their applications to the latest versions. In this tutorial, you saw an application that was successfully upgraded and built in Java17 after the transformation. For some applications that span multiple modules and with a more complex dependency structure, Q might not be able to complete the build in Java17 after the upgrade and return partially completed code. But, it will still complete major framework upgrades, such as Spring Boot, and replace deprecated APIs. In these scenarios Q will return the partially upgraded code and build log for you to verify and complete the remaining steps to successful build. One situation where builds would fail is if your code uses internal library versions that are incompatible after the upgrade. You can update to the right versions and complete the build from the partially upgraded coded. We see customers benefiting from the transformation output to troubleshoot any missing gaps using the build log summary.
We are continually making improvements to the workflow so we would strongly recommend you test it for your unique workloads and share any feedback for us to feed it back into further improving the product.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.