The Problem
Java version upgrades are painful. Deprecated APIs, breaking changes, dependency hell. A Java 8 to 17 migration can take weeks of tedious manual work.
The Solution
Amazon Q’s Code Transformation automates Java upgrades:
- Analyze your codebase
- Identify breaking changes
- Apply fixes automatically
- Generate a detailed transformation report
How to Use It
Prerequisites
- VS Code or JetBrains with Amazon Q extension
- AWS account (free tier works)
- Maven or Gradle project
Start a Transformation
- Open Command Palette (Cmd/Ctrl+Shift+P)
- Select “Amazon Q: Transform”
- Choose source version (e.g., Java 8)
- Choose target version (e.g., Java 17)
- Click “Transform”
What Happens
Amazon Q will:
- Upload your code to a secure sandbox
- Analyze all dependencies
- Identify incompatible APIs
- Apply automated fixes
- Build and test the transformed code
- Generate a diff for your review
Real Transformation Example
Before (Java 8):
// Deprecated in Java 9, removed in Java 11
import javax.xml.bind.JAXBContext;
public class XmlParser {
private static JAXBContext context;
static {
context = JAXBContext.newInstance(MyClass.class);
}
}
After (Java 17):
// Uses Jakarta XML Binding (JAXB replacement)
import jakarta.xml.bind.JAXBContext;
public class XmlParser {
private static JAXBContext context;
static {
context = JAXBContext.newInstance(MyClass.class);
}
}
Amazon Q also updates pom.xml:
<!-- Added automatically -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
Pro Tips
Review Before Accepting
Always review the transformation diff:
- Check behavioral changes (not just syntax)
- Verify dependency versions are compatible
- Run your test suite against transformed code
Incremental Upgrades
For large jumps (Java 8 → 21), consider stepping:
- Java 8 → 11 (LTS to LTS)
- Java 11 → 17 (LTS to LTS)
- Java 17 → 21 (if needed)
Each step is lower risk and easier to review.
Handle Edge Cases
Amazon Q handles ~80% automatically. Manual work for:
- Custom reflection usage
- Undocumented API dependencies
- Complex build configurations
- Native code integrations
Use the Report
The transformation report includes:
- All changes made (with reasoning)
- Manual steps required
- Risk assessment per change
- Rollback instructions
Keep this for compliance/audit trails.
Supported Transformations
| From | To | Status |
|---|---|---|
| Java 8 | Java 11 | ✓ Stable |
| Java 8 | Java 17 | ✓ Stable |
| Java 11 | Java 17 | ✓ Stable |
| Java 8/11/17 | Java 21 | ✓ Preview |
Cost
Code Transformation is included in Amazon Q Developer:
- Free tier: 5 transformations/month
- Pro ($19/month): Unlimited transformations
When to Use
✓ Legacy Java applications stuck on 8 ✓ Security compliance requiring newer JDK ✓ Performance improvements from newer JVM ✓ Accessing modern Java features (records, pattern matching)
What takes a team weeks, Amazon Q does in hours. Review carefully, but let AI do the grunt work.