java-language
FreeNo executable scriptsNot checkedModern Java 21+ language standards including Records, Pattern Matching, and Virtual Threads. Use for Java language constructs or Java-to-Java upgrades; defer…
by HoangNguyen0403★ 598 GitHub starsAbout this skill
Java Language Patterns
Priority: P0 (CRITICAL)
Implementation Guidelines
- Records: Use record for immutable DTOs/Value Objects. Records auto-generate equals, hashCode, toString. Avoid Lombok @Data on Pojos.
- Local Variables: Use
varfor inferred types. Explicitly type interface variables. - Switch: Use Switch Expressions (->) and Pattern Matching over complex if/else chains.
- Text Blocks: Use
"""(text blocks, Java 15+) for JSON, SQL, or multi-line strings; the opening"""must be followed by a line terminator, and closing-delimiter placement sets incidental indentation. - Pattern Matching: Use
instanceofwith pattern binding:if (obj instanceof String s). - Sealed Classes: Use sealed interface/class with permits clause for domain-driven restricted hierarchies. Switch expressions then exhaustive switch (compiler-verified).
- Collections: Use
List.of(),Map.of(), andSet.of()for immutable collections. - Streams: Use
stream()pipelines for functional transformations. Use.toList()(Java 16+). - Optional: Utilize
Optional<T>for return types. Use.ifPresentOrElse()or.orElseThrow(). - Virtual Threads: Favor
Executors.newVirtualThreadPerTaskExecutor()for I/O-heavy workloads (stable since 21). - Preview APIs:
StructuredTaskScopeand other preview features need an explicit project opt-in, an exact JDK pin, and--enable-previewat compile and runtime; never present them as a stable default on a JDK where they are still preview. See concurrency reference.
Anti-Patterns
- No Nulls: Return Optional or empty collections; avoid null parameters.
- No Raw Types: Always use generics; never use raw List or Map.
- No Old Switch: Use switch expressions (->); avoid fall-through.
- No Manual get/set: Use Records or value objects instead.
- No unbounded blocking in monitors: On JDK 21–23 blocking inside
synchronizedpins the carrier; JDK 24+ (JEP 491) removes that. PreferReentrantLockfor timed/try/interruptible locking, not merely to dodge pinning — and do not bansynchronizedwholesale.
References
Install java-language in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the java-language skill do?
Modern Java 21+ language standards including Records, Pattern Matching, and Virtual Threads. Use for Java language constructs or Java-to-Java upgrades; defer Kotlin, tests, formatting/build tools, CompletableFuture, builder patterns, and isolated null-handling questions.
How do I install the java-language skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the java-language skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
by Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
by Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropic