java-modern
Skill1.4k starsChanged 4 days agoApache-2.0View on GitHub
Java 21+ features for Spring Boot - records, sealed classes, pattern matching, virtual threads, text blocks. Use when user asks about modern Java, Java 21 features, or when modernizing existing code.
1 other project uses a version of this, 1 of them edited.
Adopted by
Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Most recently taken up by
- piomin/claude-ai-quarkusedited, first seen Oct 25, 2026
Who's talking about piomin/claude-ai-spring-boot
- sudosubin/agents.nix“claude-code-marketplaces.github.piomin.claude-ai-spring-boot: 1.2.0 → 1.2.1”GitHub · Nov 8, 2026
- sudosubin/agents.nix“agent-skills.github.piomin.claude-ai-spring-boot: 1.2.0 → 1.2.1”GitHub · Nov 8, 2026
- sudosubin/agents.nix“claude-code-plugins.github.piomin.claude-ai-spring-boot: 0-unstable-2026-10-28 → 1.2.0”GitHub · Oct 30, 2026
- sudosubin/agents.nix“agent-skills.github.piomin.claude-ai-spring-boot: 0-unstable-2026-10-27 → 1.2.0”GitHub · Oct 30, 2026
- sudosubin/agents.nix“claude-code-marketplaces.github.piomin.claude-ai-spring-boot: 0-unstable-2026-10-28 → 1.2.0”GitHub · Oct 30, 2026
The biggest 5 of 17 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 17
Talked about on GitHub (17 times).
On GitHub · 17
- Nov 8, 2026claude-code-marketplaces.github.piomin.claude-ai-spring-boot: 1.2.0 → 1.2.1 — sudosubin/agents.nix0 reactions
- Nov 8, 2026agent-skills.github.piomin.claude-ai-spring-boot: 1.2.0 → 1.2.1 — sudosubin/agents.nix0 reactions
- Oct 30, 2026claude-code-plugins.github.piomin.claude-ai-spring-boot: 0-unstable-2026-10-28 → 1.2.0 — sudosubin/agents.nix0 reactions
- Oct 30, 2026agent-skills.github.piomin.claude-ai-spring-boot: 0-unstable-2026-10-27 → 1.2.0 — sudosubin/agents.nix0 reactions
- Oct 30, 2026claude-code-marketplaces.github.piomin.claude-ai-spring-boot: 0-unstable-2026-10-28 → 1.2.0 — sudosubin/agents.nix0 reactions
12 more on GitHub
- Oct 29, 2026agent-skills.github.piomin.claude-ai-spring-boot: 9f16f8d → 1f0e36f — sudosubin/agents.nix0 reactions
- Oct 28, 2026claude-code-plugins.github.piomin.claude-ai-spring-boot: init at 0-unstable-2026-10-28 — sudosubin/agents.nix0 reactions
- Oct 28, 2026claude-code-marketplaces.github.piomin.claude-ai-spring-boot: 0-unstable-2026-10-27 → 0-unstable-2026-10-28 — sudosubin/agents.nix0 reactions
- Oct 28, 2026claude-code-marketplaces.github.piomin.claude-ai-spring-boot: init at 0-unstable-2026-10-27 — sudosubin/agents.nix0 reactions
- Oct 27, 2026agent-skills.github.piomin.claude-ai-spring-boot: 0-unstable-2026-10-18 → 0-unstable-2026-10-27 — sudosubin/agents.nix0 reactions
- Oct 27, 2026Retrospective: align the plugin with spring-person-api-claude 3.4.3 and crud-ui-blueprint 1.2.3 — mmartofel/claude-ai-spring-boot0 reactions · 3 comments
- Oct 18, 2026agent-skills.github.piomin.claude-ai-spring-boot: 0d23826 → cf876a1 — sudosubin/agents.nix0 reactions
- Oct 18, 2026agent-skills.github.piomin.claude-ai-spring-boot: 0-unstable-2026-10-16 → 0-unstable-2026-10-18 — sudosubin/agents.nix0 reactions
- Oct 16, 2026agent-skills.github.piomin.claude-ai-spring-boot: 0-unstable-2026-04-27 → 0-unstable-2026-10-16 — sudosubin/agents.nix0 reactions
- Oct 1, 2026agent-skills.github.piomin.claude-ai-spring-boot: init at 0-unstable-2026-04-27 — sudosubin/agents.nix0 reactions
- Mar 29, 2026Create workspace-template SKILL.md with wizard flow — riccardomerolla/llm4zio0 reactions · 1 comment
- Mar 21, 2026feat: support GitHub tree URLs in GitInstaller — neovateai/neovate-desktop0 reactions · 1 comment
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- piomin/claude-ai-quarkus★ 766% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository7 other files it gives its agents.
- code-qualitySkill
- conventionsSkill
- design-patternsSkill
- jpa-patternsSkill
- logging-patternsSkill
- spring-bootSkill
- testing-patternsSkill
The file
Files
Java Modern Skill
Java 21+ language features and how to use them in Spring Boot applications.
When to Use
- Building new Spring Boot 4.x applications (default to modern features)
- Modernizing/refactoring existing Java code
- User asks about records, sealed classes, pattern matching, virtual threads
Records (Java 16+)
DTOs
// ✅ Records for request/response DTOs
public record ProductRequest(
@NotBlank String name,
@DecimalMin("0.0") BigDecimal price
) {}
public record ProductResponse(
Long id,
String name,
BigDecimal price,
LocalDateTime createdAt
) {
public static ProductResponse from(Product entity) {
return new ProductResponse(
entity.getId(),
entity.getName(),
entity.getPrice(),
entity.getCreatedAt()
);
}
}Configuration Properties
// ✅ Records for config properties (Spring Boot 4.x)
@ConfigurationProperties(prefix = "app.notification")
public record NotificationProperties(
boolean enabled,
String fromEmail,
Duration timeout,
Retry retry
) {
public record Retry(int maxAttempts, Duration delay) {}
}When NOT to use records
- JPA entities (Hibernate needs mutable objects, no-arg constructor)
- Classes that need inheritance
- Objects with mutable state
Sealed Classes (Java 17+)
Domain Modeling
// ✅ Restrict payment types at compile time
public sealed interface PaymentResult
permits PaymentSuccess, PaymentFailure, PaymentPending {
}
public record PaymentSuccess(String transactionId, BigDecimal amount)
implements PaymentResult {}
public record PaymentFailure(String errorCode, String message)
implements PaymentResult {}
public record PaymentPending(String referenceId)
implements PaymentResult {}
// Usage in service
public PaymentResult processPayment(PaymentRequest request) {
try {
String txId = gateway.charge(request);
return new PaymentSuccess(txId, request.amount());
} catch (InsufficientFundsException e) {
return new PaymentFailure("INSUFFICIENT_FUNDS", e.getMessage());
}
}Event Hierarchies
public sealed interface OrderEvent
permits OrderCreated, OrderShipped, OrderCancelled {
Long orderId();
LocalDateTime timestamp();
}
public record OrderCreated(Long orderId, LocalDateTime timestamp, Long customerId)
implements OrderEvent {}
public record OrderShipped(Long orderId, LocalDateTime timestamp, String trackingNumber)
implements OrderEvent {}
public record OrderCancelled(Long orderId, LocalDateTime timestamp, String reason)
implements OrderEvent {}Pattern Matching
instanceof (Java 16+)
// ❌ Old style
if (obj instanceof String) {
String s = (String) obj;
return s.length();
}
// ✅ Pattern matching
if (obj instanceof String s) {
return s.length();
}switch (Java 21+)
// ✅ Exhaustive switch with sealed types - compiler enforces all cases
public String handlePayment(PaymentResult result) {
return switch (result) {
case PaymentSuccess s -> "Paid: " + s.transactionId();
case PaymentFailure f -> "Failed: " + f.message();
case PaymentPending p -> "Pending: " + p.referenceId();
};
}
// ✅ Guarded patterns
public BigDecimal calculateDiscount(Order order) {
return switch (order) {
case Order o when o.getTotal().compareTo(new BigDecimal("100")) > 0 ->
o.getTotal().multiply(new BigDecimal("0.10"));
case Order o when o.isLoyaltyMember() ->
o.getTotal().multiply(new BigDecimal("0.05"));
default -> BigDecimal.ZERO;
};
}In Service Logic
// Replacing if-else chains with pattern matching
public String processNotification(Object event) {
return switch (event) {
case OrderCreated o when o.total().compareTo(BigDecimal.valueOf(1000)) > 0 ->
sendPriorityNotification(o);
case OrderCreated o -> sendStandardNotification(o);
case OrderCancelled c -> sendCancellationNotification(c);
case PaymentReceived p -> sendPaymentConfirmation(p);
default -> throw new IllegalArgumentException("Unknown event: " + event);
};
}
// Pattern matching with instanceof — no more casting
public BigDecimal calculateShipping(Address address) {
if (address instanceof DomesticAddress d) {
return d.isExpressZone() ? DOMESTIC_EXPRESS : DOMESTIC_STANDARD;
} else if (address instanceof InternationalAddress i) {
return BASE_INTERNATIONAL.multiply(i.distanceFactor());
}
throw new IllegalArgumentException("Unknown address type");
}In Exception Handlers
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)
public ProblemDetail handle(Exception ex) {
return switch (ex) {
case EntityNotFoundException e ->
ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, e.getMessage());
case DataIntegrityViolationException e ->
ProblemDetail.forStatusAndDetail(HttpStatus.CONFLICT, "Duplicate entry");
case ConstraintViolationException e ->
ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, "Invalid request");
default ->
ProblemDetail.forStatusAndDetail(HttpStatus.INTERNAL_SERVER_ERROR, "Unexpected error");
};
}
}Virtual Threads (Java 21 + Spring Boot 4.x)
# application.yml - enables virtual threads for all request handling
spring:
threads:
virtual:
enabled: trueThis single property:
- Runs each HTTP request on a virtual thread (Tomcat)
- Makes
@Asyncmethods use virtual threads - Allows blocking I/O (JDBC, RestClient) to scale like reactive code
// ✅ Blocking code scales with virtual threads - no code changes needed
@Service
@Transactional(readOnly = true)
public class ReportService {
private final OrderRepository orderRepository;
private final RestClient externalApi;
public ReportService(OrderRepository orderRepository, RestClient externalApi) {
this.orderRepository = orderRepository;
this.externalApi = externalApi;
}
public Report generate(Long customerId) {
// Both blocking calls - on virtual threads this scales to thousands of concurrent requests
List<Order> orders = orderRepository.findByCustomerId(customerId);
CustomerData data = externalApi.get()
.uri("/customers/{id}", customerId)
.retrieve()
.body(CustomerData.class);
return new Report(orders, data);
}
}Do NOT use with virtual threads:
synchronizedblocks holding across blocking calls (useReentrantLockinstead)- Thread-local heavy frameworks (check compatibility first)
Text Blocks (Java 15+)
// ✅ JPQL queries
@Query("""
SELECT p FROM Product p
WHERE p.active = true
AND p.price BETWEEN :minPrice AND :maxPrice
ORDER BY p.name
""")
List<Product> findActiveInPriceRange(
@Param("minPrice") BigDecimal min,
@Param("maxPrice") BigDecimal max);
// ✅ JSON in tests
mockMvc.perform(post("/api/v1/products")
.contentType(MediaType.APPLICATION_JSON)
.content("""
{
"name": "Widget",
"price": 10.00
}
"""))
.andExpect(status().isCreated());Sequenced Collections (Java 21)
SequencedCollection adds getFirst(), getLast(), and reversed() to ordered collections.
// ❌ Before Java 21
String first = list.get(0);
String last = list.get(list.size() - 1);
// ✅ Java 21+
String first = list.getFirst();
String last = list.getLast();
// Reversed view (no copy)
for (var item : list.reversed()) {
process(item);
}
// Works with all ordered collections: List, Deque, SortedSet, LinkedHashSet, LinkedHashMap
SortedSet<User> users = userRepository.findTopByOrderByCreatedAtDesc();
User newest = users.getFirst();
User oldest = users.getLast();Quick Decision Guide
| Feature | Use For | Avoid When |
| Records | DTOs, config, value objects | JPA entities, mutable state |
| Sealed classes | Closed type hierarchies, domain events | Open extension needed |
| Pattern matching switch | Handling sealed types, replacing if-else chains | Simple equality checks |
| Virtual threads | High-concurrency blocking I/O | CPU-bound work, synchronized over I/O |
| Text blocks | JPQL queries, JSON test data, SQL | Single-line strings |
| SequencedCollections | First/last access on ordered collections | Unordered sets/maps |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

