Installation

Install as Agent Plugin Recommended
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install java-development@skills-hub

Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled). Plugin java-development v1.0.0 follows the Agent Plugins spec.

Install with the gh extension
gh skills-hub install java-development

Don't have the extension? Run gh extension install samueltauil/skills-hub first.

Download and extract to your repository:

.github/skills/java-development/

Extract the ZIP to .github/skills/ in your repo. The folder name must match java-development for Copilot to auto-discover it.

Skill Files (4)

SKILL.md 7.7 KB
---
name: java-development
description: 'Day-to-day plain Java development without a framework: Maven and Gradle usage and wrappers, project layout, dependency and vulnerability management, modern Java idioms by JDK version (records, sealed types, pattern matching, virtual threads), SLF4J logging, error and null handling, immutability, concurrency basics, static analysis and formatting (Spotless, Error Prone, -Xlint), packaging (jar, jlink, jpackage) and GitHub Actions CI. Use when writing, building, reviewing or maintaining ordinary Java code.'
---

# Java Development (plain Java)

Everyday guidance for Java projects that are not tied to a framework. If the project uses Spring Boot, Quarkus, Helidon or similar, prefer that framework's skills for framework concerns and use this one for the plain-Java parts.

## Rules that always apply

1. **Detect before you write.** Read `pom.xml`/`build.gradle*`, `.mvn/`, `gradle/`, `.java-version`/`.sdkmanrc`, `.editorconfig`, CI files, and a few source files. Match the build tool, Java release, formatter, naming, logging and test libraries already in use.
2. **Never upgrade implicitly.** Do not change the Java release, build-tool version, plugin or dependency versions, or add a formatter/linter/static analyzer the project lacks, as a side effect of another task. Suggest it and ask. Version upgrades are their own task (`java-upgrade`, if installed).
3. **Use the wrapper** (`./mvnw`, `./gradlew`) when present; otherwise the installed `mvn`/`gradle`. Do not commit a wrapper unprompted.
4. **Verify with a build.** After any change run the project's own verification (`./mvnw -B verify` or `./gradlew build`) and report the result. Run a narrower command first while iterating. If you could not run it, say so.
5. **Ask the user** before: changing public APIs or serialized/DB/wire formats, raising the Java release, adding runtime dependencies, adding tools to the build, deleting or weakening tests, changing CI, or when two reasonable designs have different trade-offs.
6. Prefer the standard library and small, explicit code over new dependencies. No Lombok unless already used.

## Pick idioms by the project's Java release

Check `maven.compiler.release`/`<release>`, `java.toolchain`, or `sourceCompatibility`; never use a feature newer than that release. Summary (details and snippets in `references/modern-java.md`):

| Release | You can use |
| --- | --- |
| 8 | lambdas, streams, `Optional`, `java.time` |
| 11 | `var`, `String.isBlank/strip/lines`, `java.net.http.HttpClient`, `List.of`/`Map.of` (9) |
| 17 | records, sealed classes, text blocks, switch expressions, `instanceof` patterns |
| 21 | pattern matching for `switch`, record patterns, **virtual threads**, `SequencedCollection` (`getFirst/getLast/reversed`) |
| 22-24 | unnamed variables `_` (22), `Stream.gather` (24) |
| 25 | scoped values, instance `main`/compact source files, module import declarations (all final) |

Structured concurrency (`StructuredTaskScope`) is still a **preview API** in 25 and 27 (verified: needs `--enable-preview`); do not use it in production code unless the user opts in to preview features.

## Build tools in practice

- Maven: `./mvnw -B verify` (compile, unit tests, integration tests, packaging), `-pl <module> -am` for one module, `dependency:tree`, `-DskipTests` only when the user asks. Gradle: `./gradlew build`, `test --tests 'pkg.Class'`, `dependencies`, `dependencyInsight --dependency <name>`.
- Standard layout: `src/main/java`, `src/main/resources`, `src/test/java`, `src/test/resources`; package by feature, one top-level type per file, no split packages.
- Set the Java version explicitly (`maven.compiler.release` / Gradle toolchain with `options.release`) and UTF-8 encoding; do not rely on the JDK that happens to run the build.
- Wrapper, BOM and `dependency:tree`/`versions:` usage, version catalogs and multi-module layout: `references/build-and-dependencies.md`.

## Dependencies and vulnerabilities

- Import BOMs (`junit-bom`, `testcontainers-bom`, the framework's BOM) instead of repeating versions; one version per library across modules.
- Inspect before changing: `mvn dependency:tree -Dincludes=group:artifact` / `gradlew dependencyInsight`. Resolve conflicts with `dependencyManagement` or Gradle constraints, not by excluding randomly.
- Check updates with `mvn versions:display-dependency-updates` (add `-Dmaven.version.ignore` to hide alpha/beta/RC) and report them; do not apply major upgrades without asking.
- Vulnerabilities: use what the project has (Dependabot/Renovate alerts, OWASP dependency-check, OSV-Scanner, GitHub dependency review). Suggest one if none exists; do not add it silently. Keep secrets out of scanner config; NVD-based scanners need an API key to be practical.

## Version-dependent failures (verified)

- **JDK 23+ no longer runs annotation processors implicitly** (Lombok, MapStruct, Dagger...): `-proc:none` is the default unless `-processor`, `--processor-path` or `--processor-module-path` is given. Declare the processor path in the build (Maven `annotationProcessorPaths`, Gradle `annotationProcessor`) or pass `-proc:full`. JDK 21+ prints a warning when it detects implicit use; `-proc:full` is also backported to 17.0.11, 11.0.23 and 8u411. Source: <https://inside.java/2024/06/18/quality-heads-up/>.
- **Virtual threads and `synchronized`**: on JDK 21-23 a virtual thread that blocks inside `synchronized` is pinned to its carrier; JEP 491 removes nearly all such pinning in JDK 24+. On 21-23 prefer `ReentrantLock` around blocking calls. Source: <https://openjdk.org/jeps/491>.
- **Error Prone** on JDK 16+ needs the `--add-exports`/`--add-opens` javac flags, and on JDK 21 `-XDaddTypeAnnotationsToSymbol=true` (see the quality reference).
- Never use a language feature newer than the project's release (see the table above).

## Static analysis and formatting (only if already present, or the user agrees)

Respect what is configured: if the project uses Spotless/Checkstyle/SpotBugs/Error Prone, run them and fix findings; if not, do not add them. When asked to introduce them, start with `-Xlint:all` and Spotless (formatter only), then Error Prone. Verified configs for Maven and Gradle on JDK 21 and 25 (including the JDK-21-only `-XDaddTypeAnnotationsToSymbol=true` requirement and Maven `.mvn/jvm.config` flags) are in `references/quality-and-packaging.md`. Never reformat the whole codebase in an unrelated change.

## Packaging and CI

- Plain library jar: `mvn package`/`gradlew jar`. Runnable app: shaded/fat jar or `lib/` directory plus manifest `Main-Class`; custom runtime with `jlink`; native installer/app-image with `jpackage` (verified on macOS, see `references/quality-and-packaging.md`).
- GitHub Actions: `actions/checkout`, `actions/setup-java` with `distribution: temurin`, an explicit `java-version`, built-in dependency `cache`, then `./mvnw -B verify` or `./gradlew build`. Snippet and notes in `references/quality-and-packaging.md`. Do not change CI without asking.

## Related skills (use when installed)

`java-junit` (unit tests), `java-testcontainers` (integration tests with Docker), `java-hibernate-jpa` (persistence), `java-debugging` (failures and stack traces), `java-diagnostics` (performance, memory, threads, JFR), `java-upgrade` (JDK/framework upgrades), `lsp-setup` (Java language server for navigation and refactoring).

## References

- `references/modern-java.md`: idioms and verified snippets (records, sealed types, switch patterns, text blocks, virtual threads, `SequencedCollection`, unnamed variables), preview status, pitfalls.
- `references/build-and-dependencies.md`: Maven/Gradle commands, wrappers, BOMs, conflict diagnosis, update checking, Dependabot/Renovate, vulnerability scanning.
- `references/quality-and-packaging.md`: logging setup, `-Xlint`, Spotless, Error Prone, Checkstyle/SpotBugs notes, jar/jlink/jpackage, GitHub Actions.
references/
build-and-dependencies.md 5.3 KB
# Build tools, dependencies and vulnerabilities

Commands below were run on Maven 3.10.0 / 3.9.11 (wrapper) and Gradle 9.8.1 with JDK 21 and 25 unless marked unverified.

## Maven

```bash
mvn -v                               # shows Maven AND the JDK it runs on; check it matches the project's release
./mvnw -B verify                     # compile + unit tests + integration tests (+ checks bound to verify)
./mvnw -B -q test                    # unit tests only
./mvnw -B -pl service -am verify     # one module and what it depends on
./mvnw -B dependency:tree -Dincludes=org.slf4j
./mvnw -B versions:display-dependency-updates
./mvnw -B versions:display-plugin-updates
```

Generate a wrapper (only when the user wants one): `mvn wrapper:wrapper -Dmaven=3.9.11` creates `mvnw`, `mvnw.cmd`, `.mvn/wrapper/maven-wrapper.properties` (verified, wrapper 3.3.4, script-only distribution that downloads Maven on first run). Commit those files and keep `.mvn/` in version control.

Minimal `pom.xml` essentials:

```xml
<properties>
  <maven.compiler.release>21</maven.compiler.release>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
```

Pin plugin versions (`maven-compiler-plugin` 3.16.0, `maven-surefire-plugin` 3.6.0, `maven-jar-plugin` 3.5.1 were used in verification) instead of relying on Maven's defaults; an explicit `<release>` beats `source`/`target`.

`versions:display-dependency-updates` also proposes pre-releases (it proposed `slf4j-api 2.1.0-alpha1`). Hide them with `-Dmaven.version.ignore='(?i).*(alpha|beta|rc|-m)[-.0-9]*'` (verified: the alpha disappears). Report updates; do not apply majors without asking.

Multi-module: a parent `pom.xml` with `<packaging>pom</packaging>`, `<modules>`, and `<dependencyManagement>`/`<pluginManagement>`; children inherit versions. Do not use `-Dmaven.test.failure.ignore` to get a green build.

## Gradle

```bash
./gradlew build                      # compile + test + check
./gradlew test --tests 'demo.OrdersTest'
./gradlew dependencies --configuration runtimeClasspath
./gradlew dependencyInsight --dependency slf4j-api --configuration runtimeClasspath
./gradlew --version                  # Gradle + JVM
```

Generate a wrapper: `gradle wrapper --gradle-version 9.8.1` (verified; creates `gradlew`, `gradlew.bat`, `gradle/wrapper/*`). Upgrade later with `./gradlew wrapper --gradle-version <v>` only when asked.

```kotlin
plugins { java }
repositories { mavenCentral() }
java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }
tasks.withType<JavaCompile>().configureEach { options.release = 21 }
dependencies {
    implementation("org.slf4j:slf4j-api:2.0.20")
    runtimeOnly("ch.qos.logback:logback-classic:1.6.5")
    testImplementation(platform("org.junit:junit-bom:6.0.3"))
    testImplementation("org.junit.jupiter:junit-jupiter")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
tasks.test { useJUnitPlatform() }
```

A toolchain makes Gradle pick or download the right JDK; keep the toolchain version equal to the release. Prefer a version catalog (`gradle/libs.versions.toml`) when the project already has one. Use `api` vs `implementation` only in `java-library` projects.

## Dependency hygiene

- BOMs: Maven `<scope>import</scope>` in `dependencyManagement`; Gradle `platform("group:bom:version")`.
- When a transitive version is wrong, find who brings it (`dependency:tree` / `dependencyInsight`), then override with `dependencyManagement` or a Gradle `constraints {}` block with a comment saying why.
- Do not mix two logging backends or two JSON/mapping libraries without reason; check the tree for duplicates (e.g. both `logback-classic` and `slf4j-simple`).
- Remove unused dependencies (`mvn dependency:analyze` reports used-undeclared and unused-declared; review by hand before deleting, since reflection and runtime-only libraries are false positives).
- Scope correctly: test libs `test`, JDBC drivers/logging backends `runtime`.

## Automated updates

Dependabot (`.github/dependabot.yml`), unverified here but standard:

```yaml
version: 2
updates:
  - package-ecosystem: maven        # or gradle
    directory: "/"
    schedule: { interval: weekly }
    groups:
      minor-and-patch:
        update-types: [minor, patch]
  - package-ecosystem: github-actions
    directory: "/"
    schedule: { interval: weekly }
```

Renovate (`renovate.json`) is the alternative; both need the user's consent to enable. Merge update PRs only when `verify` passes.

## Vulnerability scanning (unverified here)

Not run in this skill's verification (it needs network downloads of vulnerability databases and, for NVD, an API key). Pick what fits the project:

- GitHub Dependabot alerts / dependency review action (no build change).
- OWASP dependency-check Maven plugin `org.owasp:dependency-check-maven` (13.0.0 on Maven Central when this was written): `mvn org.owasp:dependency-check-maven:check -DnvdApiKeyEnvironmentVariable=NVD_API_KEY`; set `NVD_API_KEY` via CI secret, never in the repo or as a literal command-line value. The parameter tells the plugin which environment variable to read; exporting the variable alone does not configure it.
- OSV-Scanner (`osv-scanner scan source -r .`) reads `pom.xml`/Gradle lockfiles.

Report findings with the vulnerable artifact, the fixed version and whether it is direct or transitive; fix by raising the managed version, and run `verify`.
modern-java.md 5.3 KB
# Modern Java idioms by release

Snippets in this file compiled and ran on JDK 21 and 25 (`-Xlint:all -Werror`) unless marked. Use a feature only if the project's configured release supports it; do not raise the release to use one.

## Records, sealed types, pattern matching (17 / 21)

```java
public sealed interface Shape permits Circle, Rect, Group {}

public record Circle(double r) implements Shape {
    public Circle {                                   // compact constructor: validate
        if (r <= 0) throw new IllegalArgumentException("r must be > 0");
    }
}
public record Rect(double w, double h) implements Shape {}
public record Group(List<Shape> items) implements Shape {
    public Group { items = List.copyOf(items); }      // defensive immutable copy
}

static double area(Shape s) {
    return switch (s) {                                // exhaustive: no default, compiler checks
        case Circle(double r) -> Math.PI * r * r;     // record pattern (21)
        case Rect(double w, double h) -> w * h;
        case Group(List<Shape> items) -> items.stream().mapToDouble(Main::area).sum();
    };
}

static String describe(Object o) {
    return switch (o) {
        case null -> "null";
        case Integer i when i > 10 -> "big int " + i; // guard
        case Integer i -> "int " + i;
        case String str -> "string " + str.length();
        default -> "other";
    };
}
```

- Records are shallowly immutable: copy mutable components (`List.copyOf`). They are good DTOs/value types, not JPA entities (see `java-hibernate-jpa`).
- Prefer a sealed hierarchy and an exhaustive `switch` without `default`, so adding a subtype breaks compilation where handling is missing.
- Pre-21 (17): `if (o instanceof String s && !s.isBlank()) {...}` and arrow-form switch expressions work; `case Integer i ->` patterns in `switch` do not.

## Text blocks (15)

```java
String json = """
    {
      "name": "demo"
    }
    """;
```

Indentation is stripped relative to the closing delimiter; use `.formatted(...)` for values; never build SQL/JSON by concatenating untrusted input.

## Virtual threads (21, final)

```java
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
    List<Future<Integer>> futures = new ArrayList<>();
    for (int i = 0; i < 1_000; i++) {
        int n = i;
        futures.add(executor.submit(() -> { Thread.sleep(Duration.ofMillis(10)); return n; }));
    }
    for (var f : futures) f.get();
}
Thread.ofVirtual().name("worker-", 0).start(task);   // single thread
```

Verified: 1,000 tasks, each sleeping 10 ms, run through `newVirtualThreadPerTaskExecutor` on JDK 21 and 25; `Thread.currentThread().isVirtual()` is true inside tasks.

- Use for blocking I/O workloads (HTTP, JDBC); no benefit for CPU-bound work.
- Do not pool them or cache them; create one per task. Limit concurrency to a downstream resource with a `Semaphore`, not a pool size.
- Avoid heavy `ThreadLocal` state per task. On JDK 21-23 a virtual thread blocked inside `synchronized` pins its carrier; JEP 491 (JDK 24) removes most of this pinning. Use `ReentrantLock` on 21 for long blocking critical sections.
- Frameworks may switch to virtual threads by configuration (e.g. a Spring Boot property); that is framework territory, not this skill.

## Structured concurrency and scoped values

- `ScopedValue`: preview on 21, **final in 25** (verified: compiles and runs on 25 without `--enable-preview`, rejected on 21 as a preview API).
- `StructuredTaskScope`: **preview** on 25 and on 27 (verified: "is a preview API and is disabled by default"). Its API changed between 21 and 25 (25 uses `StructuredTaskScope.open()`). Do not use without explicit user approval to enable `--enable-preview` for compile and run; Maven needs `<compilerArgs>--enable-preview</compilerArgs>` and Surefire `argLine`.

## SequencedCollection (21)

```java
static <T> Optional<T> last(SequencedCollection<T> c) {
    return c.isEmpty() ? Optional.empty() : Optional.ofNullable(c.getLast()); // Null-permitting collections
}
```

`getFirst/getLast/addFirst/removeLast/reversed()` are available on `List`, `Deque`, `LinkedHashSet`, `SortedSet`; `getFirst()` on an empty list throws `NoSuchElementException`. `SequencedCollection` implementations may permit null elements (for example, `LinkedList` and `LinkedHashSet`), so use `Optional.ofNullable` when the result can be null.

## Later features

| Feature | Status (verified on JDK 25 / 27 unless noted) |
| --- | --- |
| Unnamed variables `_` | Final in 22; on 21 the compiler says "unnamed variables are a preview feature" |
| `Stream.gather` / `Gatherers.windowFixed(2)` | Works on 25 and 27; not present on 21 |
| Instance `void main()` (compact source file) | Works without flags on 25 and 27 |
| `import module java.base;` | Works without flags on 25 and 27 |
| `ScopedValue` | Works without flags on 25 and 27 |
| `StructuredTaskScope` | Preview on 25 and 27 |

Verify the status of any other feature with `java <File>.java` on the target JDK before recommending it; JEP statuses change every six months.

## Collection and API pitfalls

- `stream().toList()` (16+) returns an unmodifiable list; `Collectors.toList()` makes no guarantee.
- `Map.of`/`List.of` reject nulls and `Map.of` has undefined iteration order; use `LinkedHashMap` when order matters.
- Do not use `finalize`, `Thread.stop`, `new Integer(...)`, `Date`/`Calendar`, `SecurityManager`.
quality-and-packaging.md 8.7 KB
# Logging, static analysis, packaging and CI

Verified with Maven 3.10.0 and Gradle 9.8.1 on JDK 21.0.12 and 25.0.4 unless marked unverified.

## Logging: SLF4J + one backend

```xml
<dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>2.0.20</version></dependency>
<dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.6.5</version><scope>runtime</scope></dependency>
```

```java
private static final Logger log = LoggerFactory.getLogger(Main.class);

log.info("order {} placed for {}", orderId, customerId);     // placeholders, no concatenation
log.warn("payment failed for order {}", orderId, exception); // exception last: full stack trace
log.atInfo().addKeyValue("area", area).log("computed");     // SLF4J 2 fluent API (verified)
```

- Libraries depend only on `slf4j-api`; the application chooses the backend. Exactly one backend on the runtime classpath (otherwise SLF4J warns about multiple bindings).
- Minimal `src/main/resources/logback.xml` (verified): a `ConsoleAppender` with pattern `%d{HH:mm:ss.SSS} %-5level [%thread] %logger{36} requestId=%X{requestId} - %msg %kvp%n`, `<logger name="your.package" level="DEBUG"/>`, root level `INFO`. `%X{requestId}` renders the MDC request ID and `%kvp` renders fluent `addKeyValue` fields; `%msg` alone renders neither. Without a config file Logback logs at DEBUG to the console.
- Guard expensive argument construction with a lambda (`log.atDebug().log(() -> ...)`) or `isDebugEnabled`. Levels: ERROR = needs attention now, WARN = unexpected but handled, INFO = business events, DEBUG/TRACE = diagnostics.
- Never log secrets, tokens, full request bodies or personal data; use MDC (`MDC.put("requestId", id)` ... `finally MDC.remove`) for correlation. Do not use `System.out` for diagnostics in application code.
- Do not log an exception and also rethrow it (duplicate noise); log at the place that handles it.

## Compiler warnings: `-Xlint`

Maven:

```xml
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.16.0</version>
  <configuration>
    <release>21</release>
    <compilerArgs><arg>-Xlint:all</arg><arg>-Werror</arg></compilerArgs>
  </configuration>
</plugin>
```

Gradle: `tasks.withType<JavaCompile>().configureEach { options.release = 21; options.compilerArgs.addAll(listOf("-Xlint:all", "-Werror")) }`.

`-Werror` turns warnings into build failures; verified as clean for the sample project on 21 and 25, but on an existing codebase it can fail on hundreds of warnings. Introduce `-Xlint:all` first and add `-Werror` only when the project is clean and the user agrees.

## Spotless (formatting)

Maven (verified 3.10.4; `spotless:check` fails on violations, `spotless:apply` fixes):

```xml
<plugin>
  <groupId>com.diffplug.spotless</groupId>
  <artifactId>spotless-maven-plugin</artifactId>
  <version>3.10.4</version>
  <configuration>
    <java><googleJavaFormat/><removeUnusedImports/></java>
  </configuration>
</plugin>
```

Gradle (verified 8.10.4): `plugins { id("com.diffplug.spotless") version "8.10.4" }` and `spotless { java { googleJavaFormat(); removeUnusedImports() } }`; run `./gradlew spotlessCheck` / `spotlessApply`.

Format style is a team decision: google-java-format uses 2-space indentation. If the project already has `.editorconfig`/Eclipse/IntelliJ formatting, configure Spotless to match instead (or do not add it). Apply `spotless:apply` to touched files only, never as a drive-by reformat of the repo. Works the same on JDK 21 and 25.

## Error Prone (bug patterns at compile time)

Maven, verified with `error_prone_core` 2.50.0 on JDK 21 and 25 (it caught `String.equals(Integer)` as `EqualsIncompatibleType`):

```xml
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.16.0</version>
  <configuration>
    <release>21</release>
    <compilerArgs>
      <arg>-XDcompilePolicy=simple</arg>
      <arg>-XDaddTypeAnnotationsToSymbol=true</arg>   <!-- required on JDK 21; accepted on 25 -->
      <arg>--should-stop=ifError=FLOW</arg>
      <arg>-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode</arg>
    </compilerArgs>
    <annotationProcessorPaths>
      <path>
        <groupId>com.google.errorprone</groupId>
        <artifactId>error_prone_core</artifactId>
        <version>2.50.0</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
</plugin>
```

and `.mvn/jvm.config` (JDK 16+ strong encapsulation; one flag per line):

```
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
```

Without `-XDaddTypeAnnotationsToSymbol=true` on JDK 21 the compiler fails with "-XDaddTypeAnnotationsToSymbol=true is required by Error Prone on JDK 21" (verified). Error Prone warnings appear as `[BugPattern]` compiler warnings and become errors under `-Werror`; suppress a specific finding with `@SuppressWarnings("BugPattern")` plus a comment, not a global disable.

Gradle (verified with `net.ltgt.errorprone` 5.1.1, which adds the JVM flags itself):

```kotlin
plugins { java; id("net.ltgt.errorprone") version "5.1.1" }
dependencies { errorprone("com.google.errorprone:error_prone_core:2.50.0") }
```

## Checkstyle and SpotBugs (unverified here)

Run them only if the project configures them (`maven-checkstyle-plugin`, `spotbugs-maven-plugin`, Gradle `checkstyle`/`com.github.spotbugs`). Use the project's existing rule files; do not create a new ruleset or suppress findings wholesale. SpotBugs analyses bytecode, so check its JDK support before upgrading Java. They overlap with Error Prone; adding all three is rarely justified.

## Packaging

Executable jar needs dependencies. For a plain app (verified: the jar alone fails with `NoClassDefFoundError` for SLF4J):

```bash
mvn -B package dependency:copy-dependencies -DincludeScope=runtime -DoutputDirectory=target/lib
java -cp 'target/app.jar:target/lib/*' demo.Main
```

or use a shade/assembly plugin (or Gradle `application` + `installDist`) to produce a distributable. Set `Main-Class` in the jar manifest (`maven-jar-plugin` `<archive><manifest><mainClass>`).

**jlink** (verified, JDK 21): build a trimmed runtime:

```bash
MODS=$(jdeps --ignore-missing-deps --multi-release 21 --print-module-deps --class-path 'target/lib/*' target/app.jar)
jlink --add-modules "$MODS,jdk.unsupported" --strip-debug --no-header-files --no-man-pages --output target/rt
target/rt/bin/java -cp 'target/app.jar:target/lib/*' demo.Main
```

`jdeps` misses modules used by reflection or `ServiceLoader`; if the app fails with `NoClassDefFoundError`/missing provider, add modules (e.g. `java.sql`, `java.xml`, `jdk.crypto.ec`) explicitly. Runtime size was 44 MB for `java.base` only.

**jpackage** (verified on macOS with `--type app-image`): the `--input` directory must contain only the jar and its dependencies, not the output directory (using `target` as input recursed until "File name too long"):

```bash
mkdir target/in && cp target/app.jar target/lib/*.jar target/in/
jpackage --type app-image --name devapp --input target/in --main-jar app.jar \
  --main-class demo.Main --runtime-image target/rt --dest target/app
```

Native installers (`dmg`, `pkg`, `msi`, `deb`, `rpm`) need platform tooling and signing and were not tested; each must be built on its own OS.

## GitHub Actions CI (unverified: not executed)

`actions/setup-java` v6 and `actions/checkout` v7 were the latest major release tags as of 2026-10 (checked through the GitHub API); verify the current majors, and pin to a full commit SHA if the repository's policy requires it.

```yaml
name: CI
on:
  push:
    branches: [main]
  pull_request:
permissions:
  contents: read
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [21, 25]
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-java@v6
        with:
          distribution: temurin
          java-version: ${{ matrix.java }}
          cache: maven            # or gradle
      - run: ./mvnw -B verify     # or ./gradlew build
```

Match the matrix to the Java releases the project supports (and the build's release setting); one JDK is fine for an application. For Gradle also consider `gradle/actions/setup-gradle`. Keep `permissions` minimal, never print secrets, and do not edit existing workflows without asking.

License (MIT)

View full license text
MIT License

Copyright GitHub, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.