Java joins the native kernel (codegraph-kernel/src/java.rs), mirroring the wasm extractor's Java paths bug-for-bug: package namespaces, imports, javadoc, annotations→decorates, type_list inheritance, static-final constants, enum constants, anonymous classes (including the TS side's 0-based-line quirk on the extends ref), method_invocation calls with the this.field unwrap and the Foo.getInstance().bar() chain encoding (#645/#608), static-member value reads, method-reference fn-refs (#756), value-reference edges, and the full Lombok member synthesizer (#912: Getter/Setter/Data/Value/Builder/ToString/ EqualsAndHashCode/Slf4j-family with taken-member dedup). The shared docstring/textutil modules moved to crate level. Grammar: tree-sitter-java 0.23.5, with the wasm grammar vendored from the same tag (parser.c sha-matched) replacing tree-sitter-wasms' 2023-era build. Gate (plan §4c): extraction sweeps 100% — gson 262/262, retrofit 341/341, dubbo 4,048/4,048 — plus a Java torture fixture in npm test; full-init dump-diffs byte-identical on gson (49,766 rows), retrofit (62,735), and dubbo (441,266 rows); all R2/R3 repos re-verified; Linux container runs all 23 kernel tests green under CODEGRAPH_KERNEL_EXPECT=1. The gate caught a real cross-language bug: fn-ref dedupe and value-ref self-target checks must compare node ID STRINGS, not node-table rows — ids collide for same-(kind, name, line) nodes, which minified one-line bundles hit routinely (retrofit's website JS exposed it; latent in the TS/JS walker since R2, never released). Fixed in both walkers. Benchmark honesty: dubbo fresh-init on an 11-core Mac is ~flat (parse-loop wall 5,020→4,394ms; total ~11.3s both arms) because that wall is main-thread-bound (reads + store), not worker-CPU-bound — the §6 expectation assumed otherwise. Where worker CPU binds the kernel delivers: dubbo on a 2-CPU/6GB container drops 27.8-28.6s → 22.3-22.8s (~1.25×). The identified lever for the many-core headline is decoding kernel buffers directly into store rows (skipping per-node JS object materialization); the buffer contract already carries everything. DEFAULT_ROUTED now includes java. Full suite: 2,467 tests pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
103 lines
2.5 KiB
Java
103 lines
2.5 KiB
Java
/**
|
|
* Java torture fixture — exercises every Java extraction path the kernel
|
|
* ports: package namespace, imports, javadoc, annotations, inheritance,
|
|
* fields/constants, enums, anonymous classes, method references, static
|
|
* member reads, fluent chains, Lombok synthesis, value refs + shadowing.
|
|
*/
|
|
package com.example.torture;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import static java.util.Objects.requireNonNull;
|
|
import com.example.other.OtherClass;
|
|
import lombok.Data;
|
|
|
|
/** Javadoc for the service. */
|
|
@Service
|
|
@Component("torture")
|
|
public class TortureService extends BaseService implements Runnable, AutoCloseable {
|
|
/** A shared constant table (value-ref target). */
|
|
public static final Map<String, Integer> RETRY_LIMITS = Map.of("a", 1);
|
|
private static final String API_BASE = "https://example.test";
|
|
protected int count = 0;
|
|
private final List<String> names;
|
|
int packagePrivate, secondDeclarator;
|
|
|
|
/** Ctor javadoc. */
|
|
public TortureService(List<String> names) {
|
|
this.names = requireNonNull(names);
|
|
register(this::onEvent);
|
|
queue(TortureService::compute);
|
|
queue(OtherClass::handle);
|
|
Runnable r = () -> helper(RETRY_LIMITS);
|
|
executor.submit(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
helper(RETRY_LIMITS);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
@Deprecated
|
|
public void run() {
|
|
Config cfg = ConfigLoader.getInstance().load();
|
|
this.registry.lookup("x");
|
|
helper(Direction.UP);
|
|
String base = API_BASE;
|
|
int max = Limits.MAX_VALUE;
|
|
new StringBuilder(16).append(base);
|
|
}
|
|
|
|
private static Config helper(Object arg) {
|
|
return new Config();
|
|
}
|
|
|
|
private void onEvent() {}
|
|
private static void compute() {}
|
|
|
|
public void shadowed() {
|
|
String API_BASE = "local"; // shadows the class constant
|
|
log(API_BASE);
|
|
}
|
|
|
|
enum Direction {
|
|
UP,
|
|
DOWN;
|
|
|
|
Direction opposite() {
|
|
return this == UP ? DOWN : UP;
|
|
}
|
|
}
|
|
|
|
interface Listener {
|
|
void onChange(TortureService svc);
|
|
}
|
|
}
|
|
|
|
@Data
|
|
class LombokBean {
|
|
private String name;
|
|
private boolean isActive;
|
|
private final int id;
|
|
private static int counter;
|
|
private String toString; // taken: no synthetic toString field collision
|
|
|
|
public String getName() { return name; } // explicit getter — never overridden
|
|
}
|
|
|
|
@lombok.Getter
|
|
@lombok.extern.slf4j.Slf4j
|
|
@Builder
|
|
class LombokBuilderBean {
|
|
private List<String> items;
|
|
}
|
|
|
|
interface Shape extends Comparable<Shape>, Cloneable {
|
|
double area();
|
|
}
|
|
|
|
@interface Marker {
|
|
String value() default "";
|
|
}
|