java-topology/tools/tickets/defects/javac-0002b.md
russell@unturf.com db29a08762 undefect. CWE-407 — 92 sites, 42 ecosystems
B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections.
Squash of 94 local commits onto remote master.
2026-03-26 19:48:18 -04:00

1.1 KiB

id repo severity status created
javac-0002b openjdk HIGH patched 2026-03-23

Defect

File: src/jdk.compiler/.../javac/comp/Infer.java:1747 Pattern: uncached closure DFS Complexity: O(K·V) Language: Java

Description

At line 1747, the inference engine performs a DFS to compute the transitive closure of inference variable dependencies, but the result is not cached between calls. Each query for reachability retraverses the full dependency subgraph, costing O(V) per call. With K such queries per inference round, the total cost becomes O(K·V) where both K and V grow with program complexity.

Fix

Replace: uncached DFS closure traversal With: precomputed and cached transitive closure map Data structure change: (none — add Map<InferenceVar, Set<InferenceVar>> closureCache)

Work required

  • Patch in defects/javac/patch/
  • Unit test — asserts exact operation counts before/after (in defects/javac/unit/)
  • Integration test (in defects/javac/integration/)
  • Benchmark — before/after on V=100,200,400,800 (in defects/javac/bench/)
  • White paper section