GitHub Copilot Instructions for Java Upgrades
This repository contains comprehensive GitHub Copilot instruction sets for upgrading Java projects across multiple JDK versions, focusing on language features, API changes, and migration patterns.
All content is based on official JEP (Java Enhancement Proposal) documentation scraped directly from OpenJDK.org, ensuring accuracy and completeness for each upgrade path.
๐ก Also Available: These Java upgrade instructions are featured in the Awesome Copilot repository - GitHub's curated collection of the best Copilot resources for developers.
๐ Recommended: Try GitHub Copilot App Modernization Extension First
Before using these manual instruction files, I strongly recommend you trying the GitHub Copilot App Modernization for Java VS Code extension.
๐ How It Works
The extension uses a hybrid approach that combines proven tools with AI intelligence:
-
Code Assessment with AppCAT: Uses AppCAT (Azure Application and Code Assessment Tool), built on the open-source Konveyor project, to perform deep code analysis. This is a deterministic, rule-based assessment (not AI-driven) that:
- Scans your codebase for deprecated APIs, incompatible patterns, and migration blockers
- Identifies all dependencies and their compatibility with target Java versions
- Generates a comprehensive assessment report based on proven migration patterns
-
AI-Powered Planning: Once AppCAT completes the assessment, AI analyzes the findings to create an optimal migration strategy, considering:
- Your specific codebase patterns and dependencies
- Risk assessment and prioritization of changes
- Sequencing of transformations to minimize breaking changes
-
Deterministic Code Transformation: The actual code changes are performed using OpenRewrite recipes - scripts that provide deterministic, highly scalable, non-AI code refactoring:
- Battle-tested transformation rules used by thousands of enterprise projects
- Consistent, predictable results across large codebases
- Version-controlled, reviewable transformation logic
Key Point for AI-Cautious Developers: While AI helps with planning and strategy, the actual code transformations use proven, deterministic tools (AppCAT + OpenRewrite) that have been successfully used in enterprise environments for years.
โ
Production-Ready Automation
- Guided Agent Mode: Interactive, step-by-step upgrade process with human oversight
- OpenRewrite Integration: Battle-tested refactoring recipes used by thousands of projects
- Automated Build Fixes: Intelligent resolution of compilation errors and dependency conflicts
- CVE Scanning: Comprehensive security vulnerability detection and remediation
โ
Comprehensive Workflow
- Project Analysis: AppCAT scans JDK version, build configuration, and deprecated APIs
- Custom Upgrade Plan: AI generates editable migration strategy based on AppCAT findings
- Automated Transformation: Applies code changes using proven OpenRewrite recipes (deterministic)
- Validation Loop: Fixes build errors iteratively until compilation succeeds
- Test Execution: Validates changes through your existing test suite
- Security Audit: Identifies and suggests fixes for vulnerable dependencies
โ
Beyond Runtime Upgrades
- Cloud Migration: Assess and migrate to Azure with guided steps
- Authentication Modernization: Migrate from on-premises auth to Microsoft Entra ID
- Deployment Automation: One-click deployment to Azure with infrastructure provisioning
๐ง Getting Started with the Extension
# Install the extension in VS Code
# Search for "GitHub Copilot App Modernization" in the Extensions marketplace
# In VS Code, open Copilot Chat and select the Java upgrade tool
# Then paste: "Using Java upgrade tools, upgrade this project to Java 21.
# Analyze deprecated APIs, update dependencies, and propose a safe migration plan."
When to use these manual instructions instead:
- The extension doesn't support your specific upgrade scenario
- You need detailed understanding of individual JEPs
- You prefer manual control over each transformation step
- You want to learn about Java language evolution in depth
Upgrade Paths
Java 8 โ Java 11 (LTS to LTS)
- Instruction File:
java-8-to-11.instructions.md
- Major Changes: Module System (JPMS), removed Java EE modules (JAXB, JAX-WS, CORBA), internal API encapsulation
- Major Features: Local-Variable Type Inference (
var), HTTP Client, Collection Factory Methods, Stream/Optional enhancements, Flight Recorder (now free)
- Key Benefits: Modern API replacements, improved security, better performance (G1 default, Compact Strings, CDS)
Java 11 โ Java 17 (LTS to LTS)
- 47 JEPs covering Records, Sealed Classes, Pattern Matching, Text Blocks, Switch Expressions
- Instruction File:
java-11-to-17.instructions.md
- Major Features: Records, Pattern Matching for instanceof, Switch Expressions, Sealed Classes, Text Blocks
- Key Benefits: Significant boilerplate reduction, improved type safety, better domain modeling
Java 17 โ Java 21 (LTS to LTS)
- 22 JEPs covering Virtual Threads, Pattern Matching for switch, Record Patterns
- Instruction File:
java-17-to-21.instructions.md
- Major Features: Virtual Threads, Pattern Matching for switch, Record Patterns, Sequenced Collections
- Key Benefits: Massive concurrency improvements, enhanced pattern matching, simplified data extraction
Java 21 โ Java 25
- 39 JEPs covering Flexible Constructor Bodies, Primitive Types in Patterns, Module Import Declarations
- Instruction File:
java-21-to-25.instructions.md
- Major Features: Flexible Constructor Bodies, Primitive Types in Patterns, Module Import Declarations, Stream Gatherers
- Key Benefits: Enhanced language expressiveness, improved modularity, advanced stream processing
Files Overview
๐ GitHub Copilot Instructions
Choose the appropriate instruction file for your upgrade path:
java-8-to-11.instructions.md - Complete GitHub Copilot instructions for Java 8 โ 11 upgrade
java-11-to-17.instructions.md - Complete GitHub Copilot instructions for Java 11 โ 17 upgrade (47 JEPs)
java-17-to-21.instructions.md - Complete GitHub Copilot instructions for Java 17 โ 21 upgrade (22 JEPs)
java-21-to-25.instructions.md - Complete GitHub Copilot instructions for Java 21 โ 25 upgrade (39 JEPs)
Usage: Copy your selected file to .github/copilot-instructions.md in your project root. The .instructions.md extension helps identify these as GitHub Copilot instruction files.
๐ Source Data (from OpenJDK.org)
jep-documentation-21-25.json - Java 21โ25 JEPs scraped from OpenJDK JDK 25 JEPs (39 JEPs: 455, 466, 467, 468, 469, 471, 472, 473, 474, 475, etc.)
jep-documentation-17-21.json - Java 17โ21 JEPs scraped from OpenJDK JDK 21 JEPs (22 JEPs: 441, 444, 440, 439, etc.)
jep-documentation-11-17.json - Java 11โ17 JEPs scraped from OpenJDK JDK 17 JEPs (47 JEPs: 395, 409, 394, 361, 378, etc.)
scraper-21-25.js - Primary scraper for Java 21โ25
scraper-17-21.js - Scraper for Java 17โ21
scraper-11-17.js - Scraper for Java 11โ17
Key Features by Upgrade Path
Java 8 โ 11: The Module System Era
Breaking Changes
- Module System (JPMS) (JEP 261) - Internal API encapsulation
- Removed Java EE Modules (JEP 320) - JAXB, JAX-WS, CORBA, JTA, JAF
- Removed JavaFX - Now a separate OpenJFX project
- G1 Default GC - Replaces Parallel GC as default
Language Features
- Local-Variable Type Inference (JEP 286) -
var keyword
- Private Interface Methods (JEP 213) - Shared default method logic
- Local-Variable Syntax for Lambda (JEP 323) -
var in lambda parameters
API Improvements
- HTTP Client (JEP 321) - Modern HTTP/2 client replacing HttpURLConnection
- Collection Factory Methods (JEP 269) -
List.of(), Set.of(), Map.of()
- Stream Enhancements -
takeWhile, dropWhile, ofNullable
- Optional Enhancements -
ifPresentOrElse, or, stream, isEmpty
- String Methods -
isBlank, lines, strip, repeat
Runtime Improvements
- Flight Recorder (JEP 328) - Free production profiling (was commercial)
- Compact Strings (JEP 254) - Reduced memory for Latin-1 strings
- Application CDS (JEP 310) - Faster startup
- TLS 1.3 (JEP 332) - Modern transport security
Java 11 โ 17: Foundation of Modern Java
Language Features
- Records (JEP 395) - Immutable data classes with automatic methods
- Sealed Classes (JEP 409) - Restricted inheritance hierarchies
- Pattern Matching for instanceof (JEP 394) - Type-safe casting
- Switch Expressions (JEP 361) - Modern control flow with arrow syntax
- Text Blocks (JEP 378) - Multi-line string literals
Runtime Improvements
- Helpful NullPointerExceptions (JEP 358) - Better error messages
- ZGC (JEP 377) - Low-latency garbage collector
- Shenandoah (JEP 379) - Low-pause garbage collector
- Enhanced Random Generators (JEP 356) - Better random number generation
Java 17 โ 21: Concurrency Revolution
Language Features
- Virtual Threads (JEP 444) - Lightweight threads for massive concurrency
- Pattern Matching for switch (JEP 441) - Enhanced switch with patterns
- Record Patterns (JEP 440) - Destructuring records in patterns
- Sequenced Collections (JEP 431) - First/last element access
- UTF-8 by Default (JEP 400) - Simplified charset handling
Java 21 โ 25: Language Expressiveness
Language Features
- Primitive Types in Patterns (JEP 455) - Pattern matching for primitives
- Flexible Constructor Bodies (JEP 482) - Statements before super()
- Module Import Declarations (JEP 476) - Simplified module imports
- Stream Gatherers (JEP 473) - Custom intermediate stream operations
Language Features
- Pattern Matching Enhancement (JEP 455/488) - Primitive types in patterns, instanceof, and switch
- Derived Record Creation (JEP 468) -
with expressions for records
- Stream Gatherers (JEP 473) - Custom intermediate stream operations
API Changes
- Class-File API (JEP 466/484) - Standard replacement for ASM library
- Markdown JavaDoc (JEP 467) - Modern documentation syntax
Deprecations & Warnings
- sun.misc.Unsafe (JEP 471) - Memory access methods deprecated
- JNI Restrictions (JEP 472) - Warnings for native code usage
Runtime Improvements
- ZGC Generational (JEP 474) - Now default mode
- G1 Optimization (JEP 475) - Late barrier expansion
How to Use
๐ฅ Option 1: GitHub Copilot App Modernization Extension (Recommended)
Use the GitHub Copilot App Modernization for Java extension for automated, production-ready upgrades. This extension uses AppCAT (Microsoft's deterministic code assessment tool based on Konveyor) for analysis, AI for planning, and OpenRewrite recipes for deterministic code transformation - addressing concerns about AI-driven code changes by using proven, non-AI tools for the actual transformations.
๐ฅ Option 2: Manual Instructions with GitHub Copilot
If you prefer manual control or need to understand specific language changes in detail: