java-expert
Expert knowledge of Java 25 features including virtual threads, pattern matching, records, sealed classes, value types, and Project Loom/Valhalla features. Use when the user asks about Java programming, Java 25 features, concurrency, performance optimization, or modern Java idioms.
- License 许可
- Unlicense
- 最近更新
- 2026-11-15
- Stars
- ★ 21
- Forks
- 9
01 前言 Front Matter
- name
- java-expert
- description
- Expert knowledge of Java 25 features including virtual threads, pattern matching, records, sealed classes, value types, and Project Loom/Valhalla features. Use when the user asks about Java programming, Java 25 features, concurrency, performance optimization, or modern Java idioms.
- allowed-tools
- Read, Grep
03 SKILL.md 正文
Java 25 Expert Skill
Overview
Provides expert guidance on Java 25 language features and best practices.
Key Java 25 Features
Virtual Threads (Project Loom)
- Use
Thread.ofVirtual().start(runnable)for lightweight concurrency - Virtual threads are ideal for I/O-bound workloads
- Use
Executors.newVirtualThreadPerTaskExecutor()for thread pools
Pattern Matching
- Switch expressions with pattern matching
- Deconstruction patterns for records
- Guarded patterns with
whenclauses
Records
- Immutable data carriers with auto-generated constructors, equals, hashCode, toString
- Custom compact constructors for validation
Sealed Classes
- Restrict class hierarchies with
sealed,permits - Enable exhaustive pattern matching
String Templates (Preview)
- Template processors like
STR."\{value}" - Custom template processors
Best Practices
- Prefer records over plain POJOs for data transfer
- Use sealed interfaces for algebraic data types
- Leverage virtual threads for high-throughput servers
- Use pattern matching to eliminate instanceof casts
Examples
record Point(int x, int y) {}
sealed interface Shape permits Circle, Rectangle {}
record Circle(Point center, double radius) implements Shape {}
record Rectangle(Point topLeft, Point bottomRight) implements Shape {}
String describe(Shape shape) {
return switch (shape) {
case Circle c when c.radius() > 10 -> "Large circle";
case Circle c -> "Small circle";
case Rectangle r -> "Rectangle";
};
}
04 同仓库更多 Skills
word-count
Counts the words, lines and characters of a text or a file.
slugify
Turns a title or a sentence into a URL slug, lowercase words joined by hyphens with accents removed.
json-format
Validates a JSON file and pretty prints it with two space indentation, or reports where the JSON is invalid.
commit-message
Writes a conventional commit message for the staged git changes.
skills-gateway
Gateway and router to a catalog of skills that are not registered directly. Use it before any task a specialized skill could handle, such as text, JSON or git chores. It finds the right skill and loads its instructions.
decision-log
Record, list, show and supersede architecture decisions that persist across sessions in the shared agent infra state store. Use when the user says "record this decision", "log an ADR", "what did we decide about", "list decisions", or "supersede decision".