Terminal
Terminal/Skill
Java 17 to 25 coding rules for writing and reviewing code, covering records, sealed types, Optional, virtual threads and null safety.
By JetBrains
Works with
npx skills add jetbrains/junie-extensions --skill java-engineerBaseline knowledge of the Java language (records, sealed, pattern matching, text blocks, streams, var, generics, Optional API) is assumed — this skill does not teach the language. It encodes the project policy and the traps that keep appearing in code review.
Before writing non-trivial code, verify:
java --version, and target version in pom.xml (<maven.compiler.release>) or build.gradle(.kts) (java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }). Adjust feature use if < 17. Current LTS: Java 25 (released Sept 2025); Java 21 is the previous LTS. Prefer LTS releases for new projects../mvnw / ./gradlew, never a globally installed mvn / gradle.lombok in dependencies. If present, prefer @RequiredArgsConstructor / @Slf4j / @Builder; if absent, do not introduce Lombok unless asked.error-prone, checkstyle, spotbugs, pmd. Respect existing rules; do not add new violations.--enable-preview, some features behave differently. Check flag before relying on preview syntax.Optional is a return type only. Never a parameter, field, or element of a collection.record. DTOs, events, results, config snapshots. Not JPA entities (records are final and have no no-arg constructor).sealed + exhaustive switch. Compiler catches new cases.switch expression over if / else if chains. Pattern-matching switch over instanceof chains.final unless you have a reason to reassign.Objects.requireNonNull in public-API constructors; validate invariants in record compact constructors.try-with-resources for anything AutoCloseable — including ExecutorService (Java 19+).Executors.newVirtualThreadPerTaskExecutor()). Not for CPU-bound work.try (var scope = new StructuredTaskScope.ShutdownOnFailure()) { ... }.log.info("user_updated userId={} status={}", id, status).Optional.get() without prior isPresent() — use .map(...).orElseThrow(...) or .orElse(default).List instead of List<Foo>), no @SuppressWarnings("rawtypes") to silence warnings.null from a collection-returning method. Return List.of() / Collections.emptyList().Stream / lambda. Wrap into an unchecked domain exception at the boundary.Exception / Throwable to "make the compiler happy". Handle a specific type or propagate.List.copyOf(input).synchronized around a blocking call on a virtual thread — it pins the carrier thread. Use ReentrantLock.Thread.sleep / blocking I/O on parallelStream() — shared common pool, starves other work.Stream.toList() result — it's unmodifiable (JDK 16+).| Load when | File |
|---|---|
| Debugging subtle language / API behavior (Optional, Stream, switch, records, generics) | references/pitfalls.md |
| Records, sealed hierarchies, pattern-matching switch, preview features (pitfalls & traps, not syntax tutorials) | references/modern-java.md |
Writing concurrent code (virtual threads, structured concurrency, ExecutorService lifecycle, ThreadLocal traps) | references/concurrency.md |
| File / stream / socket I/O, charsets, partial reads, NIO buffers | references/io.md |
When producing code:
When reviewing code: call out MUST-DO / MUST-NOT violations explicitly and suggest the minimal fix.