In the Elasticsearch foreign-library module, generated @LibrarySpecification implementations currently resolve a native symbol and then call Linker.downcallHandle() directly from the generated <clinit>. That leaves no way for a library to customize MethodHandle creation after lookup—for example adjusting the function descriptor or applying MethodHandles.insertArguments based on which symbol variant was actually chosen.
Today SymbolResolver only returns a bare MemorySegment address, so any post-resolve MethodHandle logic cannot see the resolved name. Add a pluggable MethodHandle-creation hook analogous to the existing symbolResolver attribute on @LibrarySpecification, and change symbol resolution so it reports both the actual symbol name chosen and its address. The default MethodHandle path must preserve current behavior (plain Linker.downcallHandle on the resolved address). Custom classes named on the annotation must be validated like symbol resolvers (implement the interface; public no-arg constructor). The annotation processor must instantiate the configured resolvers in generated <clinit> and route MethodHandle creation through the hook so custom resolvers are actually invoked at runtime. Existing SymbolResolver users/tests must be updated for the richer resolve result without changing default lookup semantics.
Interface contract — the change must expose exactly this surface:
org.elasticsearch.foreign.ResolvedSymbol record with (String name, MemorySegment address); SymbolResolver.resolve(String, SymbolLookup) returns ResolvedSymbol; org.elasticsearch.foreign.MethodHandleResolver with MethodHandle resolve(ResolvedSymbol, FunctionDescriptor, Linker, Linker.Option...); org.elasticsearch.foreign.DefaultMethodHandleResolver implementing that via linker.downcallHandle(symbol.address(), descriptor, options); @LibrarySpecification.methodHandleResolver() default DefaultMethodHandleResolver.class.
Work only inside this repository checkout. Make the code change the task
describes, keeping the diff focused — no drive-by refactors.
When you are done, leave your changes committed or in the working tree;
they are collected automatically.
Stay on this snapshot checkout (`task/ycb_elasticsearch_c774c7a2de98d`). Never checkout, pull, or rebase onto `main`. That branch is a README-only orphan.
Stay on this HEAD. Do not fetch another default branch. Push only on the Cursor-created `crazy-cursor/…` side branch from this HEAD.
Some past runs of this task were launched with a different prompt (the prompt template changed since, or those runs predate this benchmark's stored prompt). Each run persists the exact prompt it sent at launch — that per-launch record is the audit trail; this page shows only the current one.
Reference diff
The task commit's diff against its first parent — the judge's comparison target.