Accelerate Java Version Upgrade with Amazon Q Developer

Debadatta Panda
4 min readSep 5, 2024

--

In this blog , I will explain how you can setup Amazon Q Developer in Visual Studio Code IDE and use Amazon Q Code Transformation to accelerate Java version upgrade from Java 8 or 11 to 17 , a Java Long-Term Support (LTS) release .I will highlight the points need to be taken during this process so we can workaround these for an effective version upgrade.

Prerequisite:

Amazon Q Setup in Visual Studio Code:

The supported IDE : Visual Studio Code and in JetBrains ( IntelliJ )

Amazon Q Plugin for the Visual Studio Code

Amazon Q Developer Pro Tier to access the code transformation

Authentication through AWS IAM Identity Centre / profile role for admin or developer

To set up the user in Amazon Q Developer you can go the Amazon Q Developer console and add the user with the required permission

User Set Up in Amazon Q Developer

Once you’ve set up Amazon Q Developer in your IDE and authenticated.

In the Visual Studio Code, Open Amazon Q from the left Activity Bar. You will be presented with following screen:

Use the option with Pro license for authentication. Once authenticated , you can enter these quick commands in the chat panel. Here are the key ones to know:

/clear: This command clears your current conversation by removing all previous text and stored content. Use it when you’re ready to start a new chat session.

/dev : Initiate a conversation about Amazon Q’s feature development capabilities. This command starts the process of creating an implementation plan for adding new features to your project.

/transform : Upgrade your code by using this command to start a conversation about transforming your codebase from one language version, we will use this command for the Java version upgrade.

/help: Get an overview of what Amazon Q can do, example questions, and available quick commands by entering /help in the chat.

Amazon Q Code Transformation Process:

Amazon Q Transformation Flow

The above diagram shows how the Amazon Q Code transformation works to produce the Java 17 Code from Java 8 or 11.

Before we initiate the upgrade process , there are few points to be considered , The Project need to be built with Apache Maven ( version 3.9.5 recommended).Project source JDK need to be installed locally.Project build time should be less than 55 minutes. The Artifact size need to be less than 1GB.

Upgrade Process has 3 steps:

Application Analysis — The code is copied to a managed environment in the cloud where the build process is set up based on the instructions in the repository. At this stage, the components to be upgraded are identified.

Initiate the Transformation Process /transform

Transformation Plan — The code is analyzed to create a transformation plan that lists the steps that Amazon Q Code Transformation will take to upgrade the code, that includes the dependency and upgrading the code . It iteratively fix any build errors encountered during the upgrade.

Java 17 Code & Testing — The transformation plan is followed iteratively to update existing code and configuration files, create new files where needed, perform build validation using the tests provided with the code, and fix issues identified in failed builds.

Conclusion:

We can see above how Amazon Q Code transformation is very effective to migrate the java version from 8 or 11 to 17. Code transformation is trained on opensource libraries but your organization might have internal developed libraries you need to make the these libraries are updated with the organization standard.

--

--

Debadatta Panda
Debadatta Panda

No responses yet