java-upgrade
Upgrade a Java project to a newer JDK (11 to 17, 17 to 21, 21 to 25) and adopt the new language and library features. Detects the current Java version from the build files, then loads only the matching per-version guide. Use when the user asks to upgrade Java, modernize Java code, or adopt records, sealed classes, pattern matching, virtual threads or other new Java features. For automated end-to-end upgrades see the modernize-java plugin.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 4.1w
- Forks
- 5.4k
01 前言 Front Matter
- name
- java-upgrade
- description
- Upgrade a Java project to a newer JDK (11 to 17, 17 to 21, 21 to 25) and adopt the new language and library features. Detects the current Java version from the build files, then loads only the matching per-version guide. Use when the user asks to upgrade Java, modernize Java code, or adopt records, sealed classes, pattern matching, virtual threads or other new Java features. For automated end-to-end upgrades see the modernize-java plugin.
02 资源文件 38
- 参考文档references/java-11-to-17.md21.5 KB
- 参考文档references/java-17-to-21.md13.7 KB
- 参考文档references/java-21-to-25.md9.7 KB
- 参考文档references/upstream-sources.md2.3 KB
- 其他SKILL.md.tmpl9.1 KB
- 脚本src/browseClient.ts14.4 KB
- 脚本src/cli.ts9.7 KB
- 脚本src/commands.ts1.8 KB
- 脚本src/diagram-prepass.ts33.5 KB
- 脚本src/image-policy.ts10.2 KB
- 脚本src/image-size.ts4.4 KB
- 脚本src/orchestrator.ts14.8 KB
- 脚本src/pdftotext.ts11.4 KB
- 脚本src/print-css.ts16.8 KB
- 脚本src/render.ts14.9 KB
- 脚本src/setup.ts3.9 KB
- 脚本src/smartypants.ts3.5 KB
- 脚本src/types.ts3.7 KB
- 脚本test/browseClient.test.ts4.9 KB
- 脚本test/coverage-gaps.test.ts8.8 KB
- 脚本test/diagram-prepass.test.ts16.7 KB
- 脚本test/e2e/combined-gate.test.ts3.3 KB
- 脚本test/e2e/diagram-gate.test.ts7.8 KB
- 脚本test/e2e/emoji-gate.test.ts8.7 KB
- 脚本test/e2e/format-gate.test.ts5.4 KB
- 脚本test/e2e/landscape-gate.test.ts5.8 KB
- 参考文档test/fixtures/combined-gate.expected.txt987 B
- 参考文档test/fixtures/combined-gate.md1.0 KB
- 资产文件test/fixtures/diagram-assets/huge-noise.png295.5 KB
- 资产文件test/fixtures/diagram-assets/red-box.png131 B
- 资产文件test/fixtures/diagram-assets/wide-arch.png9.1 KB
- 资产文件test/fixtures/diagram-assets/wide-screenshot.png9.8 KB
- 参考文档test/fixtures/diagram-gate.md3.9 KB
- 参考文档test/fixtures/emoji-gate.md482 B
- 参考文档test/fixtures/landscape-gate.md1.2 KB
- 脚本test/image-policy.test.ts9.1 KB
- 脚本test/pdftotext.test.ts7.9 KB
- 脚本test/render.test.ts21.1 KB
03 SKILL.md 正文
Java Upgrade
Help upgrade a Java project step by step and adopt new language features safely.
Need a more powerful, automated upgrade?
The Microsoft plugin modernize-java ("GitHub Copilot modernization - Java Upgrade CLI Plugin", also listed in this repository's plugins/external.json) upgrades Java applications from the command line. It can:
- analyze the project, assess dependencies and generate a customizable upgrade plan you can review and edit;
- execute the plan to automatically transform the codebase;
- fix build issues and resolve migration errors during the upgrade, running test validations;
- validate the application against known CVEs after the upgrade;
- output a detailed summary (file changes, updated dependencies, test results, remaining issues) suitable for PRs or CI logs.
This skill provides lightweight, step-by-step guidance and works without the plugin; the plugin is the more powerful option for large or multi-step upgrades. It is a separate Microsoft plugin, not part of this repository's skills. To try it (see the plugin README for the recommended model):
npm install -g @github/copilot
copilot plugin marketplace add microsoft/modernize-java
copilot plugin install modernize-java@modernize-java
copilot --agent modernize-java:modernize-java
Workflow
- Detect the current and target versions. Read
pom.xml(maven.compiler.release,java.version, toolchains),build.gradle*(java.toolchain,sourceCompatibility) and CI files. Never assume a target: ask the user if it is not stated. - Upgrade one LTS at a time (11 → 17 → 21 → 25). Build and run the tests after each step.
- Load only the guide you need from the table below. Do not load all of them.
- Update the build first (compiler release, plugins, dependencies that need newer versions), then adopt language features incrementally in small, reviewable changes.
- Verify:
./mvnw verifyor./gradlew build, and fix deprecation and removal warnings before adopting new features. - Automate and check upstream. Use OpenRewrite when available (for example
org.openrewrite.java.migrate.UpgradeToJava21) and always fetch the version-specific official guide before editing; review the generated diff.
Upstream sources (read before upgrading)
Fetch the page for the target version; prefer it over this skill when they conflict. Full list with build-tool and agent compatibility pages: references/upstream-sources.md.
- OpenJDK release page: https://openjdk.org/projects/jdk/21/ (change the number) and JEP index https://openjdk.org/jeps/0
- Oracle migration guide: https://docs.oracle.com/en/java/javase/21/migrate/getting-started.html
- Oracle release notes: https://www.oracle.com/java/technologies/javase/21-relnote-issues.html
jdeprscan/jdeps: https://docs.oracle.com/en/java/javase/21/docs/specs/man/jdeprscan.html, https://docs.oracle.com/en/java/javase/21/docs/specs/man/jdeps.html- Gradle compatibility matrix: https://docs.gradle.org/current/userguide/compatibility.html
- OpenRewrite: https://docs.openrewrite.org/recipes/java/migrate/upgradetojava21
Per-version guides
| Upgrade | Guide |
|---|---|
| Java 11 → 17 | references/java-11-to-17.md |
| Java 17 → 21 | references/java-17-to-21.md |
| Java 21 → 25 | references/java-21-to-25.md |
Rules
- Prefer behavior-preserving refactorings; do not change public APIs unless asked.
- Detect the project's frameworks (Spring Boot, Quarkus, Jakarta EE) and check their minimum supported Java version before raising the target.
- Do not adopt preview features unless the user opts in and the build enables them explicitly.
- For
javax.*tojakarta.*namespace changes, use thejavax-to-jakarta-migrationskill if it is installed (gh skills install github/awesome-copilot javax-to-jakarta-migration); otherwise do the migration inline: update imports,META-INFservice files and XML descriptors, and bump dependencies to Jakarta EE 9+ equivalents. - If the
modernize-javaplugin is installed and the user wants an automated upgrade, defer to it and use this skill for the per-version guides and thejavaxtojakartasafeguards.
04 同仓库更多 Skills
supabase-rls-policies
Write, review, and test Supabase Row Level Security (RLS) policies so that one user cannot read or change another user's rows. Use when creating or changing tables, policies, views, or security definer functions in a Supabase project, when reviewing a migration that touches RLS, or when asked to prove user isolation with pgTAP tests that sign in as two users.
skill-distribution-audit
Audit a skill collection before release or investigate installer omissions, archived/template leakage, duplicate identities, and manifest drift. Reconcile the intended public source set, distribution manifest, and actual discovery output for a specified consumer version. Includes a deterministic set-comparison helper.
logicapps-custom-code-net10-migration
Migrate Azure Logic Apps Standard local-function custom-code projects from .NET 8 to .NET 10. Use for legacy Logic Apps custom-code workspace upgrades, project/package configuration, custom-worker settings, publication, and integrated VS Code debugging. Not for ordinary .NET applications, standalone Azure Functions, Consumption workflows, or cloud deployment.
winmd-api-search
Find and explore Windows desktop APIs. Use when building features that need platform capabilities — camera, file access, notifications, UI controls, AI/ML, sensors, networking, etc. Discovers the right API for a task and retrieves full type details (methods, properties, events, enumeration values).
resemble-detect
Deepfake detection and media safety — detect AI-generated audio, images, video, and text, trace synthesis sources, apply watermarks, verify speaker identity, and analyze media intelligence using Resemble AI
quality-playbook
Run a complete quality engineering audit on any codebase. Derives behavioral requirements from the code, generates spec-traced functional tests, runs a three-pass code review with regression tests, executes a multi-model spec audit (Council of Three), and produces a consolidated bug report with TDD-verified patches. Finds the 35% of real defects that structural code review alone cannot catch. Works with any language. Trigger on 'quality playbook', 'spec audit', 'Council of Three', 'fitness-to-purpose', or 'coverage theater'.