java-expert
SKILL.md
java-expert
Keyword: java | Platforms: gemini,claude,codex
High-Performance Modern Java Expert Skill - Specialized in Java 21+ and cloud-native architecture.
Core Mandates
- Java 21+ First: Mandate
var(LVTI) where readable, Records for DTOs, and Pattern Matching forinstanceofandswitch. - Concurrency: Prefer Virtual Threads (
@RunOnVirtualThreadin Quarkus orExecutors.newVirtualThreadPerTaskExecutor()) over traditional Thread Pools for I/O-bound tasks. - Immutability: Use
record,finalfields, andunmodifiablecollections (List.of,Map.of). - Functional Style: Leverage Streams,
Optional, and Functional Interfaces to reduce boilerplate and side effects. - Visibility: Default to
package-privateorprivate. Onlypublicwhat must be exposed (API/SPI).
Architectural Patterns
Hexagonal / Clean Architecture
- Domain: Pure Java, zero external dependencies (no Quarkus/Spring in domain classes).
- Ports (Interfaces): Define input (Use Cases) and output (Repositories, Gateways) interfaces.
- Adapters: Infrastructure implementations (Quarkus/Hibernate/REST) reside outside the domain.
Performance & Memory
- Garbage Collection: Favor G1GC for typical workloads or ZGC for ultra-low latency (<1ms).
- Memory Management: Minimize object allocation in hot loops. Use
StringBuilderinstead of+in loops. - Profiling: Use JFR (Java Flight Recorder) for production-safe profiling and bottleneck analysis.
Testing Strategy
- JUnit 5 & AssertJ: The industry standard for fluent, readable assertions.
- Mockito: Deep stubbing and spying for complex dependencies.
- ArchUnit: Enforce architectural rules (e.g., "Domain must not depend on Infrastructure").
- Testcontainers: Real-world integration testing for databases (PostgreSQL, MySQL) and brokers (Kafka, Redis).
Bytecode & Classloading
- Jandex: Understand Jandex indexing for Quarkus's fast annotation scanning.
- Bytecode Manipulation: Familiarity with ASM or ByteBuddy for runtime/build-time enhancement.
- ClassLoader Isolation: Debugging issues related to "parent-first" vs "child-first" delegation.
Expert Tips
- Avoid
System.out.println(); always use a logger (SLF4J/Logback). - Prefer
Interface-baseddesign for testability. - Use
Sealed Classesto define closed hierarchy types for better exhaustiveness checking inswitch.
References
- Java 21 Documentation
- Effective Java (Joshua Bloch)
- Java Flight Recorder (JFR) Guide
- JUnit 5 User Guide
Skill Interoperability
The java-expert ☕ skill provides the foundational language expertise (JDK 21+, Virtual Threads) required by:
- vertx-expert 🌀: Uses modern Java for high-performance reactive programming.
- quarkus-expert ⚡: Leverages the JVM features for the Quarkus framework.
Weekly Installs
3
Repository
kinhluan/rules-…s-skillsFirst Seen
1 day ago
Security Audits
Installed on
amp3
cline3
opencode3
cursor3
kimi-cli3
codex3