| name | moai-lang-java |
| description | Java 21 LTS development specialist covering Spring Boot 3.3, virtual threads, pattern matching, and enterprise patterns. Use when building enterprise applications, microservices, or Spring projects.
|
| license | Apache-2.0 |
| compatibility | Designed for Claude Code |
| user-invocable | false |
| metadata | {"version":"1.1.0","category":"language","status":"active","updated":"2026-01-11","modularized":"false","tags":"java, spring-boot, jpa, hibernate, virtual-threads, enterprise","context7-libraries":"/spring-projects/spring-boot, /spring-projects/spring-framework, /spring-projects/spring-security","related-skills":"moai-lang-kotlin, moai-domain-backend"} |
| progressive_disclosure | {"enabled":true,"level1_tokens":100,"level2_tokens":5000} |
| triggers | {"keywords":["Java","Spring Boot","Spring Framework","JPA","Hibernate","Maven","Gradle",".java","pom.xml","build.gradle","virtual thread"],"languages":["java"]} |
Quick Reference (30 seconds)
Java 21 LTS Expert - Enterprise development with Spring Boot 3.3, Virtual Threads, and modern Java features.
Auto-Triggers: Java files with .java extension, build files including pom.xml, build.gradle, or build.gradle.kts
Core Capabilities:
- Java 21 LTS: Virtual threads, pattern matching, record patterns, sealed classes
- Spring Boot 3.3: REST controllers, services, repositories, WebFlux reactive
- Spring Security 6: JWT authentication, OAuth2, role-based access control
- JPA/Hibernate 7: Entity mapping, relationships, queries, transactions
- JUnit 5: Unit testing, mocking, TestContainers integration
- Build Tools: Maven 3.9, Gradle 8.5 with Kotlin DSL
Implementation Guide (5 minutes)
Java 21 LTS Features
Virtual Threads with Project Loom:
Use try-with-resources on Executors.newVirtualThreadPerTaskExecutor. Call IntStream.range from 0 to 10000 and forEach to submit tasks that sleep for one second and return the iteration value.
Structured Concurrency Preview Pattern:
Use try-with-resources on new StructuredTaskScope.ShutdownOnFailure. Fork tasks for fetching user and orders by calling scope.fork with lambda expressions. Call scope.join then throwIfFailed. Return new composite object with results from both task suppliers.
Pattern Matching for Switch:
Create describe method taking Object parameter. Use switch expression with cases for Integer i with guard condition i greater than 0 returning positive integer message, Integer i returning non-positive message, String s returning length message, List with wildcard returning size message, null returning null value, and default returning unknown type.
Record Patterns and Sealed Classes:
Define Point record with int x and int y. Define Rectangle record with Point topLeft and Point bottomRight. Create area method that uses switch with Rectangle pattern destructuring both Point components into variables, returning absolute value of width times height. Define sealed Shape interface permitting Circle and Rectangle. Implement Circle record with area method using PI times radius squared.
Spring Boot 3.3
REST Controller Pattern:
Create UserController with RestController annotation, RequestMapping for api/users, and RequiredArgsConstructor. Inject UserService. Create getUser method with GetMapping and PathVariable for id, returning ResponseEntity that maps findById result to ok or returns notFound. Create createUser method with PostMapping, Valid annotation, and RequestBody for CreateUserRequest. Create user, build URI location, return created response with body. Create deleteUser method with DeleteMapping that returns noContent or notFound based on service result.
Service Layer Pattern: