Codekoll finds the Java bugs that compile perfectly and blow up in production.
A standalone static analyzer for Java source, built in Java 25 on the JDK's own compiler. Point one jar at a source tree; get back a short list of findings where every single one is worth reading — each with what's wrong, what happens at runtime, and how to fix it.
src/main/java/com/acme/JobService.java:42:16 ERROR CK-REF-EQUALITY
if (status == "ACTIVE") {
^^
`==` compares references, not contents. Use .equals().
✖ 3 errors, 5 warnings in 214 files (1.8s)
Honest answer first: most classic bug patterns overlap the incumbents. SpotBugs has ~400 patterns from 20 years of hard lessons; Error Prone's type analysis is excellent; PMD, SonarQube, find-sec-bugs, and NullAway each own a slice. Codekoll's own build runs several of them as quality gates. If a rule catalog were the whole product, you wouldn't need this tool.
Codekoll differs in how it works — and in one area, in what it finds:
-
Every finding is worth reading. A curated catalog of 133 rules, each with an explicit false-positive budget: exemptions are part of every rule's contract and covered by tests, heuristic rules are demoted to INFO and never break your build, and any false positive found in the wild becomes a regression test before it's fixed. The opposite philosophy of "400 patterns your team disables wholesale."
-
Zero build integration. SpotBugs needs your compiled bytecode. Error Prone must be wired into your javac invocation. Codekoll is one jar pointed at a source tree — no build-file changes, works on code you just checked out, drops into any CI as a single step with SARIF output for GitHub code scanning.
-
Rules that teach. Every rule carries what is wrong, what happens at runtime, and how to fix it as first-class metadata — shown in findings, via
codekoll --explain CK-…, and in a runnable examples project with a documented buggy/fixed pair for all 133 rules. Compare that to decodingRV_RETURN_VALUE_IGNORED. -
Modern Java, day one. Codekoll parses with the JDK's own compiler (
JavacTask), so new Java syntax works the day the JDK ships — no waiting for a third-party parser to catch up. -
Coverage where the incumbents are thin. Two whole packs of it. The
modernpack targets Java 21+ features that predate most incumbent catalogs:defaultbranches that silently defeat sealed-switch exhaustiveness, records with array components (brokenequals), pooled virtual threads,Subtask.get()beforejoin(),Instant.plus(MONTHS)(always throws), DST-unsafeDurationarithmetic, reused streams, FFM use-after-close. Theframeworkspack hunts silently ignored code — the sneakiest bug class there is, because nothing ever throws:@Transactionalon a private method (no transaction, no error),@Autowiredon a static field (stays null), a@Testthat's silently never run, a JPA entity that'sfinal, SLF4J placeholder mismatches, log calls that lose the stack trace. Plus JSpecify-aware nullness rules like overrides that weaken a supertype's nullness contract. -
Extensible without forking. Rules ship in packs discovered via
ServiceLoaderacross JPMS module boundaries. A team-specific rule pack is just a jar on--rule-path.
133 rules in twelve packs. Ten target bugs that compile cleanly and fail (or silently misbehave) at runtime; pqc inventories cryptography that works today and a quantum computer breaks, and dead-code lists code that can never run or is never used:
| Pack | Focus | Rules | Flavor |
|---|---|---|---|
correctness |
Provably or almost-certainly wrong logic | 26 | two next() per one hasNext() guard, side effects inside assert (silently skipped in production), discarded String.trim(), == on Strings, x.equals(null), the YYYY week-year date bug, format-string mismatches, infinite recursion, getBytes() without a charset, arrays as hash keys |
numeric |
Arithmetic and overflow traps | 8 | long ms = days * 86_400_000 (overflowed before widening), comparator by subtraction, Math.abs(hashCode()), 1 << 32 |
concurrency |
Threading and synchronization | 15 | counter.set(counter.get() + 1) on an Atomic (a lost update), Thread.run() instead of start(), synchronized on a Lock, ++ on volatile, double-checked locking without volatile, collection modified while iterating, a caught InterruptedException that never restores the interrupt (shutdowns hang), catch (Exception) or an exceptionally fallback that swallows cancellation, Thread.sleep or JDBC inside supplyAsync/parallelStream (stalls the shared common pool) |
resources |
Leaks, exception handling, cleanup | 9 | unclosed streams, empty catch blocks, rethrow that drops the cause, throw inside finally |
security |
Crypto, injection, TLS, ReDoS, LLM prompts and output | 14 | MD5/SHA-1, SQL/command built by concatenation, trust-all TLS, XXE-default XML factories, catastrophic-backtracking regexes, user text spliced into an LLM system prompt, model output passed to eval/a shell/SQL, hardcoded OpenAI/Anthropic/Google AI keys |
performance |
Accidentally-quadratic code | 6 | string concat in loops, regex recompiled per iteration, keySet()+get(), boxed accumulators |
api-misuse |
Stdlib contracts violated | 13 | matcher.group(3) on a two-group regex, Arrays.asList(intArray) (a list of size 1, not of ints), Map.of("k", null) and duplicate Set.of/Map.of keys (both always throw), Boolean.getBoolean(value) (reads a system property, always false), Map<String,User>.get(12345) (always null), mutating List.of(), (String[]) list.toArray(), split("."), List<Integer>.remove(1) (index, not value!), toMap without a merge function |
nullness |
NPEs the compiler can't see | 8 | int x = map.get(k) (unboxing NPE), x != null & x.length() > 0 (non-short-circuit), impossible null conditions, JSpecify contract violations |
modern |
Java 21+ platform misuse | 15 | sealed-switch default, record array components, pooled virtual threads, ThreadLocal caches in virtual-thread tasks, blocking under synchronized on Java 21-23 (carrier pinning), structured-concurrency ordering, java.time unit traps, stream reuse, FFM use-after-close, a confined Arena used from another thread (WrongThreadException), arenas never closed, native pointers resized without an owner |
frameworks |
Silently ignored code | 12 | @Transactional on a private method, proxy-bypassing self-invocation, @Autowired static, final JPA entities, tests that never run, SLF4J placeholder mismatches, stack traces lost in log calls, a Stream returned from a @Transactional method (consumed after commit), SecurityContextHolder/MDC read inside @Async, save inside readOnly = true, a sealed type's @JsonSubTypes list missing a permitted subtype, a final field in a setter-bound @ConfigurationProperties class |
pqc |
Quantum-vulnerable asymmetric crypto; warns, never fails a default build | 3 | RSA encryption, RSA/ECDSA/EdDSA signatures, (EC)DH and X25519, DHKEM, classical TLS groups and suites, XML signature methods; every name, alias and OID the JDK defines, with ML-KEM/ML-DSA guidance for the project's Java release |
dead-code |
Code that can never run or is never used | 4 | the statement after if (true) { return; }, an if (false) block, a private method nothing calls, a local that is never read; the last two are INFO |
The complete generated catalog — every rule's id, severity and one-line summary — is in docs/RULES.md (produced by codekoll --catalog); each rule's detection algorithm and exemption list is in SPEC.md, and each has a runnable, documented example in codekoll-examples showing the bug, the runtime failure, and the fix.
Requires JDK 25.
# analyze a source tree
java -jar codekoll.jar src/main/java
# machine-readable output for CI / GitHub code scanning
java -jar codekoll.jar --format sarif --output codekoll.sarif src/main/java
# only some packs, stricter threshold
java -jar codekoll.jar --packs security,concurrency --fail-on warning src/main/java
# what does a rule mean?
java -jar codekoll.jar --explain CK-WEEK-YEAR-FORMATExit codes: 0 clean, 1 findings at/above the --fail-on threshold, 2 usage/internal error. Configure per-project via codekoll.toml at the repo root — disable rules or packs, adjust severities, exclude paths — and run codekoll --print-config to see every effective value and the file and line it came from; suppress single findings with @SuppressWarnings("codekoll:CK-…"). Full CLI and config reference in docs/CLI-SPEC.md.
The 30-second demo: run codekoll on its own examples module and watch all 133 rules fire —
java -jar codekoll.jar codekoll-examples/src/main/java
java -jar codekoll.jar --release 21 codekoll-examples/src/release21/java # CK-VT-SYNC-PINNING only applies to Java 21-23 projectsCodekoll drives the JDK compiler itself: sources are parsed and attributed by javac (JavacTask.parse() + analyze()), giving every rule fully resolved types, generics, and symbols — the same answers the compiler has. A single combined traversal walks each file once, dispatching AST nodes to the rules subscribed to them; findings stream to console, JSON, or SARIF reporters.
Because analysis is source-level and compiler-backed: analyzed code must compile (a file that does not type-check gets no rule; the run ends with a footer saying how many files that was and which packages were missing, and --verbose lists them), results are exact rather than decompiled guesses, and there is exactly one runtime dependency (the CLI parser). Architecture details — module graph, rule SPI, dispatcher design — in ARCHITECTURE.md.
In active development — see PLAN.md for the milestone roadmap and SPEC.md for the complete design. The quality bar codekoll holds itself to: Checkstyle, PMD, SpotBugs, Error Prone + NullAway (JSpecify), ArchUnit, and ≥90 % line coverage all fail the build, and codekoll runs on its own source in CI (--fail-on error).
Performance is held to the same standard: a load-test harness (codekoll-load-test) measures CPU and peak memory on every build against a committed baseline, fails CI on regression, and charts every version — the trend diagrams live in docs/perf/.
This project is licensed under the MIT License - see the LICENSE file for details.