Module 2: AI-assisted code modernization

Armed with MTA’s analysis results, you return to your desk at ACME Corp. Your manager stops by: "Great work on the analysis. Now I need to see if we can actually modernize this code faster than our traditional approach. We can’t afford weeks per application."

ACME needs proof that AI-assisted development can accelerate the actual code transformation work. You’ve heard about Red Hat Developer Lightspeed’s AI capabilities, but you need hands-on experience to understand how it accelerates modernization.

In this module, you’ll experience how Developer Lightspeed uses AI to generate modernized code, validate changes, and scale migration work through Agent Mode.

Learning objectives

By the end of this module, you’ll be able to:

  • Set up Red Hat Developer Lightspeed extension in Dev Spaces

  • Run a static code analysis to identify modernization opportunities

  • Generate modernized code using AI assistance

  • Review and validate AI-generated code changes

  • Expand migration work across entire projects using Agent Mode

Exercise 1: Access DevSpaces and configure Developer Lightspeed for MTA

The next 2 modules make use of the Developer Lightspeed MTA extension running in a DevSpaces environment that provides a VSCode based GUI env.

You may notice that the Developer Lightspeed MTA extension is sometimes referred to as just Developer Lightspeed, Migration Toolkit for Applications extension, or just the MTA extension  — In all cases it is referring to the same thing.

You need to set up your development environment with AI capabilities to start modernizing ACME’s applications.

You prepare to launch DevSpaces and configure the Developer Lightspeed extension.

  1. Switch to Red Hat OpenShift DevSpaces by clicking the OpenShift DevSpaces tab in the workshop interface.

  2. Log in to Dev Spaces using your OpenShift credentials:

    You will be initially taken to the Keycloak SSO login page
    • Username: {user}

    • Password: {password}

  3. After logging in, if prompted to Authorize Access

    • Click Allow selected permissions button

      DevSpaces Login
      Figure 1. Logging In
      If you see a message that says you need to authenticate again, just Click on the OpenShift DevSpaces tab and it should let you into the workspace listing.
  4. Open the user-{user}-workspace

    • After logging in he workspace listing will open up and show the user-{user}-workspace entry

    • Click on the Open link on the right side of workspace listing

      Open Workspace
      Figure 2. Open Workspace
  5. Wait for the workspace to initialize and open:

    Your kai-coolstore gitea repository will load in DevSpaces and your development environment will be setup.

    The workspace will open in a new tab in your browser. The workspace tab is a VSCode GUI environment served up by DevSpaces

    • If asked if you trust the content and providers, acknowledge yes, you do.

    • If shown a layout introductory panel, choose Light theme for best contrast later in the exercise and Mark Done.

      VSCode Tab
      Figure 3. VSCode Tab
  6. Once the workspace loads, verify the Developer Lightspeed extension, which is named Migration toolkit for applications, is installed:

    • Look for the Developer Lightspeed MTA icon in the left sidebar (it is the bottom icon)

    • If not visible, check Extensions view and search for "Migration toolkit for applications"

  7. Configure the Developer Lightspeed MTA extension Profile

    • Click on the MTA Extension icon on the left side of the screen

    • If you see an Install Extension Pack message just reload the page

    • Click Open Analysis Panel

      Open Analysis Panel
      Figure 4. Open Analysis Panel
      If you ever accidently close the MTA Analysis View panel, just click on the MTA Extension icon and click on the book icon in the pane just to the right, at the top. Open Analysis Pane Icon
    • Click Manage Profiles on the screen

      Open Manage Profiles
      Figure 5. Open Manage Profiles
    • This will open the MTA Manage Profiles panel

    • Click New Profile

      Create New Profile
      Figure 6. Create a New Profile
    • Enter Profile Name: {user} coolstore

    • For Target Technologies:

      • Click dropdown arrow and type or scroll to quarkus3 and click it to select it

      • Click dropdown arrow and type or scroll to quarkus and click it to select it

    • Source Technologies:

      • Click dropdown arrow and type or scroll to java-ee and openjdk8 , clicking each one to set them.

    • Leave Use Default Rules selected

      Profile Settings
      Figure 7. Profile Settings
  8. Configure the AI model connection for MTA Developer Lightspeed:

    • Click on the MTA Analysis View tab

      You will notice a yellow warning about a connection issue, we will resolve this in the next step, and you will see a message about Generative AI being enabled, which indicates this exetension has AI capabilities.
    • Click on the gear icon, on the right side of the screen.

    • The Get Ready to Analyze pane will open on the right hand side of the screen

    • Notice most of the settings are already established

    • The Hub Configuration is configured and used in the next module.

    • Click on the Configure GenAI Settings link in the bottom message box

      Configure Generative AI Settings
      Figure 8. Configure Generative AI Settings
    • The provider-settings.yaml file will open on a separate pane

      AI Model Settings
      Figure 9. AI Model Settings
    • Replace/Update from the word models: down through the first entry with the following

      This is yaml syntax so ensure to keep the indentions - just copy and paste over existing source
      models:
        OpenAI: &active
          environment:
            OPENAI_API_KEY: "{litellm_virtual_key}" # Required
          provider: ChatOpenAI
          args:
            model: llama-scout-17b # Required
            configuration:
              baseURL: "{litellm_api_base_url}"
    • Close the provider-settings.yaml file

    • Click on the MTA Analysis View tab

    • Close the Get Ready to Analyze pane

Verify

Confirm your DevSpaces and MTA (Developer Lightspeed for MTA) Extension is setup correctly

  1. Confirm MTA Extension is setup correctly

    • When you clicked on the MTA extension icon, and are on the MTA Analysis View Tab:

    • Click on the gear icon on the right side of the screen

    • The Get Ready to Analyze pane will open on the right hand side of the screen

    • There should be green check marks in all four of the message boxes and each should be listed as completed

  2. Confirm the DevSpaces workspace is pointing to the correct gitea repository

    • Click on the file icon on the left side of the DevSpaces environment

    • You should see in the File EXPLORER the kai-coolstore directory listing

    • You may have to click on the file explorer arrows to open the directories.

Exercise 2: Run an initial static code analysis

Before making changes, you’ll use Developer Lightspeed MTA extension to analyze the legacy code and identify specific modernization opportunities.

In this exercise the Developer Lightspeed for MTA extension will run a static code analysis against all the source code in the cloned repository. The static code rules are provided by Red Hat to help focus on rapid identification of issues, and customer rules can also be written and included.In this case we are including the custom ACME specific company policy code rules. This provides an efficient starting point focused on identifying migration issues that were highlighted during the risk analysis in the last module.

Later on the analysis results will be used to prompt the LLM for generating code fixes.

Prerequisites

  • Dev Spaces workspace running with Developer Lightspeed extension configured

  • Repository kai-coolstore successfully cloned

Steps

  1. Start the Analysis Server

    • Navigate to the MTA Analysis View pane

      If you ever accidently close the MTA Analysis View panel, just click on the MTA Extension icon and click on the book icon in the pane just to the right, at the top. Reopen View Panel
    • In the center of the screen make sure the profile selected is the {user} coolstore

    • At the top right of the screen, ensure the Server Status is Running

      • Click the Start button if it isn’t and wait till the Server Status is Running

  2. Invoke Developer Lightspeed analysis:

    • In the right side of the screen click on the Run Analysis button.

      In this scenario the lead developer is migrating a legacy JavaEE monlithic application into a cloud native Quarkus application to run on OpenShift.
      They want to understand the level of effort needed to migrate a representative application for a "wave" of JavaEE apps to be migrated.

      Run Initial Static Code Analysis
      Figure 10. Run Initial Static Code Analysis
  3. Review the AI analysis results:

    You will see the Analysis Results as a listing grouped by Issues

    Developer Lightspeed will identify:

    • Required changes to migrate to new frameworks and standards

    • Deprecated APIs that need updating

    • Configuration patterns that should be modernized

    • Container-readiness issues

    • OpenShift-specific optimizations

  4. Examine a specific recommendation:

    Let’s review the result: @MessageDriven - EJBs are not supported in Quarkus

    EJB Issue - Not Supported
    Figure 11. EJB Issue - Not Supported
    • If this is NOT the first result in the listing do the following:

      • Type OrderServiceMDB in the Search box at the top of the Analysis Results listing

    • Click on the > arrow on the left of the result and view the details

    • You will see a short statement giving more context as to what the issue is and some basic guidance

    • You will also see a link to the file itself that has the issue.

    • In the next exercise we will use AI capabilities as Developer Lightspeed has an interactive conversation with an LLM to generate code fixes, prompting it with information from rules. This is a RAG style approach, as it is creating enriched prompts

For the Lead Developer this is a major issue, newer Java frameworks like Quarkus don’t support legacy JavaEE EJB (Enterprise Java Bean) approaches. Especially when working with messaging solutions legacy EJB approaches need to be removed and modern MicroProfile approaches need to injected into the code. This also directly reflects the risk assessment reviewed in the first module, where legacy monolithic applications using JavaEE frameworks were a major concern.

Verify

Confirm the analysis provides actionable insights:

✓ Developer Lightspeed for MTA extension identified migration issues with the codebase ✓ Findings are grouped by default by Issues ✓ Links to code files are included in analysis results ✓ Remediation suggestions are provided

Exercise 3: Generate code fixes using AI

Now you’ll use Developer Lightspeed to automatically generate code changes based on the analysis. This is where AI acceleration becomes real for ACME.

Steps

  1. Ensure the Issue: @MessageDriven - EJBs are not supported in Quarkus is visible in the results listing in the MTA Analysis View tab

    • If necessary, type OrderServiceMDB in the Search box at the top of the Analysis Results listing, with Group by: Issues

    • Click on the > arrow on the left of the result and view the details

  2. Invoke AI solution generation:

    Start AI Code Generation
    Figure 12. Start AI Code Generation
    • Click on one of the wrench icons down arrows to the right of the screen for the issue.

    • Click on Get Solution from the drop down menu.

    • Notice the MTA Resolution Details tab now opens and an interactive conversation occurs between the MTA extension and the LLM.

    • Scroll through the Generative AI Results screen and observe how Developer Lightspeed for MTA extension has an interactive conversation with the LLM, prompting it with information from rules.

    • Note how LLM via the MTA AI respondant provides reasoning, change suggestions, and a fully converted Quarkus code approach to replace the existing approach.

    • Notice that it then pauses and asks if the developer wants to Review Changes or just accept, or reject what the AI powered MTA extension suggested.

      Generative AI Results
      Figure 13. Generative AI Results
  3. Review the proposed changes:

    • Click on Review In Editor

    • A new code editor pane will open to the right and show the OrderServiceMDB.java file

      • Original code that doesn’t need changes will not be highlighted

      • Red highlighted code is what needs to be removed

      • Green highlighted code is what needs to be added

  4. Accept the AI-generated changes:

    Review and Accept All
    Figure 14. Review and Accept All Changes
    • At the top of the file is a small prompt/link to Accept All Changes or Reject All Changes

    • Scrolling through the file shows that each highlighted code block can be accepted or rejected individually

    • Scroll to the top of the file and Click Accept All Changes

    • Developer Lightspeed will now apply all the corrective changes and rerun the analysis to show it has been resolved

    • Save the migrated OrderServiceMDB.java file

      • Go to hamburger icon at the top left of the DevSpaces env Click on the menu File > Save

    • In the MTA Resolution Details tab click the Continue button and this will return focus to the MTA Analysis View

    • Close the MTA Resolution Details and fixed OrderServiceMDB.java panes by clicking X on their tabs

Verify

Confirm that the @MessageDriven - EJBs are not supported in Quarkus is no longer listed in the

✓ AI generated valid, compilable code ✓ Changes maintain application functionality ✓ Code quality meets standards

Exercise 4: Expand migration with Agent Mode

For ACME’s large-scale migration, you need to modernize entire projects, not just individual files. Developer Lightspeed’s Agent Mode enables AI to work autonomously across the codebase.

In our scenario the Developer could one by one go through all the the Analysis Results and invoke AI solution generation for each issue individually.

However, to speed migration and modernization, once they have checked how effective a few AI generated code fixes are, they could run in Developer Lightspeed Agent Mode and have it work with the LLM to generate cascading fixes across the project

Steps

  1. Activate Developer Lightspeed Agent Mode:

    • Switch to the MTA Analysis View tab in the Developer Lightspeed for MTA extension

    • Ensure in the uppper right Server Status is Running

    • Click Agent Mode toggle to turn it on

  2. Start another Analyis run

    This Analysis run will use Agent Mode

    • Click the Run Analysis button, which is to the right side partway down the view

    • The Analyis will run again

    • At this point in the exercises one can choose to see how Agent Mode can migrate a cascading fix across a code base by doing the following optional step OR move to the Let the Agent work Step and watch it fix all the issues.

  3. Selectively focus on a specific issue Theme (Optional)

    In ACME’S scenario the lead developer is very concerned about a major Java framework issue Adopt Quarkus Maven plugin and they want to see how Developer Lighspeed can cascade changes across files based on fixing this major issue, using Agent Mode.

    • Scroll down the Analysis Results listing to Adopt Quarkus Maven plugin

    • Open the issue by clicking on the > arrow

    • Observe the pom.xml file will need to be changed and as the Java developer knows this will cause cascading changes across the codebase for imported libraries and code approaches

    • Click the wrench icon to the right of the issue, inorder to initiate the AI solution resolution

    • Developer Lightspeed extension will scroll through the Generative AI Results, which was covered in detail previously

    • Click Accept All suggested changes

    • Developer Lightspeed fixes the issue, and Agent Mode continues to look for all impacted code across the project that are affected by this fix.

    • Agent Mode offers to continue fixing them

    • Choose Yes

    • The screen may appear to lockup but notice that the Generative AI Results title at the top of the pane now has 3 bouncing * balls after it

    • Soon the results stream will report that it fixed all the dependent files and list a summary of the number of fixed files.

    • Click Run Analysis again.

  4. Let the Agent work:

    Developer Lightspeed Agent Mode will now fix all the remaining issues

    • Scroll the screen so you are looking at the beginning of the Analyis Results listing

    • Click the down arrow next the wrench icon directly opposite the Analyis Results title

    • Notice it offers to Get solution for xx incidents  — meaning all the incidents

    • Either click the wrench icon or the either of the Get solution for xx incidents options

    • Agent Mode will now fix all the remaining issues

    • This means it will:

      • Analyze the entire project structure

      • Identify all files needing changes based upon the rule violations identified in the Analysis

      • Generate modernization code across multiple files

      • Apply changes systematically

      • Provide progress updates

  5. Monitor the Agent’s progress:

    Watch as the Agent:

    • Scans project files

    • Makes decisions about changes

    • Applies transformations

    • Validates its own work

  6. Review the Agent’s complete work:

    Once the Agent finishes:

    # See all files modified by Agent Mode
    git status
    
    # Review the comprehensive changes
    git diff --stat
  7. Test the Agent-modernized code:

    # Compile everything
    ./mvnw clean compile
    
    # Run full test suite
    ./mvnw test
    
    # Package the application
    ./mvnw package

Verify

Validate that Agent Mode successfully modernized the project:

# Verify build success
ls -lh target/*.jar

# Check test results
./mvnw test | grep "Tests run"

Expected result:

[INFO] Tests run: XX, Failures: 0, Errors: 0, Skipped: 0

✓ Agent Mode completed project-wide modernization ✓ Multiple files updated systematically ✓ Build succeeds with all changes ✓ Tests pass across entire codebase

Agent Mode Progress
Figure 15. Agent Mode Progress

Troubleshooting

Issue: Developer Lightspeed extension not responding Solution: Verify AI model endpoint is accessible:

curl -k {litellm_api_endpoint}/health

If endpoint is down, check with workshop instructor. If accessible, try restarting the extension or workspace.

Issue: AI generates incorrect code that breaks tests Solution: Review the AI-generated changes carefully. Use git to revert specific changes:

# Revert to previous version
git checkout -- <file-name>

# Try a more specific prompt to the AI
# Be explicit about constraints and requirements

Issue: Agent Mode makes too many changes at once Solution: Provide more specific, constrained instructions:

Focus only on updating Spring Boot dependencies in pom.xml
Do not modify application logic or configuration files yet

Issue: Build fails after AI modifications Solution: Check compiler errors and resolve step-by-step:

# See specific compilation errors
./mvnw compile 2>&1 | grep error

# Fix errors one file at a time
# Ask Developer Lightspeed to fix specific compilation errors

Issue: Cannot push to Gitea repository Solution: Verify Git credentials and remote configuration:

# Check remote URL
git remote -v

# Verify Gitea credentials
# Username: {user}
# Password: {password}

# Push with explicit credentials if needed
git push https://{user}:{password}@<gitea-host>/<repo>.git main

Learning outcomes checkpoint

Before moving forward, confirm you can:

  • Set up and configure Red Hat Developer Lightspeed in Dev Spaces

  • Run AI-powered code analysis on legacy applications

  • Generate modernized code using AI assistance

  • Review and validate AI-generated code changes

  • Use version control to manage AI-assisted modifications

  • Leverage Agent Mode for project-wide modernization

  • Test and verify AI-generated code meets quality standards

If you can check all these boxes, you’re ready to proceed. If not, review the exercises where you need more practice.

Module summary

You’ve successfully demonstrated AI-accelerated code modernization and can now show ACME how to dramatically reduce migration time.

What you accomplished for ACME: * Configured AI-powered development environment * Generated production-quality modernized code using AI assistance * Validated AI changes through proper testing and review * Scaled modernization work using Agent Mode across entire projects

Business impact realized: * Development velocity: Reduced code modernization time from days to hours * Consistency: AI applies patterns uniformly across codebase * Quality: Automated testing validates all changes * Scalability: Agent Mode enables project-level transformations

Your journey progress: You now have hands-on experience with AI-assisted code modernization and understand how Developer Lightspeed accelerates the transformation from legacy to cloud-native applications.

Next steps: Module 3 will show you how to incorporate ACME’s specific coding standards and best practices into the AI’s knowledge using Developer Lightspeed Solution Server, ensuring consistency across all migration waves.