← Prompts
Task / Understand Copilot Instructions Collection
Comprehensive best practices for adopting new Java 25 features since the release of Java 21
Comprehensive best practices for adopting new Java 25 features since the release of Java 21.
# Java 21 to Java 25 Upgrade Guide
These instructions help GitHub Copilot assist developers in upgrading Java projects from JDK 21 to JDK 25, focusing on new language features, API changes, and best practices.
## Language Features and API Changes in JDK 22-25
### Pattern Matching Enhancements (JEP 455/488 - Preview in 23)
**Primitive Types in Patterns, instanceof, and switch**
When working with pattern matching:
- Suggest using primitive type patterns in switch expressions and instanceof checks
- Example upgrade from traditional switch:
```java
// Old approach (Java 21)
switch (x.getStatus()) {
case 0 -> "okay";
case 1 -> "warning";
case 2 -> "error";
default -> "unknown status: " + x.getStatus();
}
// New approach (Java 25 Preview)
switch (x.getStatus()) {
case 0 -> "okay";Sign in to view the full prompt.
Sign InTags
Classification
Task Immediate work request to complete
Task Understand
Explain or analyzeScope Project
This codebase Manual Manually placed / Persistent