Skip to content

Inline MH_ downcalls, absorb MethodHandles.lookup() in NativeLibrary.upcall - #352

Merged
dfa1 merged 2 commits into
mainfrom
inline-method-handles
Nov 16, 2026
Merged

dfa1 merged 2 commits into
mainfrom
inline-method-handles

Conversation

@dfa1

@dfa1 dfa1 commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Every `MH_` field is initialized at its declaration as `NativeLibrary.downcall(` / symbol and descriptor / `);` instead of assigned in a `static {}` block; `scripts/CheckPrototypes.java` now fails on any other shape, and AGENTS.md, CONTRIBUTING.md and the PR template document it.
  • `NativeLibrary.upcall(name, fd)` resolves its host class with `StackWalker`, so the 22 call sites no longer pass `MethodHandles.lookup()`; upcall stubs use the same layout as downcalls.
  • Upcall dispatch methods carry `@SuppressWarnings("unused")` with a comment, since they are only reached by name.

Test plan

  • `./mvnw test -pl core -am`
  • `java scripts/CheckPrototypes.java` (835 prototypes, 0 problems)
  • CI on all platforms

🤖 Generated with Claude Code

dfa1 and others added 2 commits November 16, 2026 07:35
MethodHandle fields are initialized in place as NativeLibrary.downcall(name, descriptor)
with the closing paren on its own line, instead of assigned in a static block.
CheckPrototypes fails on any other shape; AGENTS.md documents the rule.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Callers no longer pass MethodHandles.lookup(): upcall resolves the calling class
with StackWalker and takes a private lookup in it. Upcall stubs use the same
downcall( / name and descriptor / ); layout as MH_ handles, and the dispatch
methods, now reached only by name, are marked @SuppressWarnings("unused").

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dfa1
dfa1 force-pushed the inline-method-handles branch from 7cf496d to 7fbd173 Compare November 16, 2026 06:35
@dfa1
dfa1 merged commit bd537a1 into main Nov 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant