test(api): pin the enum ordinals - #840
Merged
Merged
Conversation
andiwand
force-pushed
the
refactor/one-way-to-edit
branch
from
September 6, 2026 14:12
0b80ffd to
6a8c287
Compare
Twenty-seven public enums cross a binding by ordinal - jni resolves constants with values()[code], and the apple and wasm mirrors are positional too - and the only thing saying so was a comment in four headers. This pins all 214 enumerators, so inserting or reordering fails in the same commit rather than in a consumer months later. Appending stays silent by design. Not explicit values in the headers: that is noise, and it does not stop anyone who reorders from renumbering as they go. wasm/tests/enums.test.mjs already does this on the JS side; this is the C++ half. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016hxDa2rev11eLUEJZJ5nmz
andiwand
force-pushed
the
test/pin-enum-ordinals
branch
from
September 6, 2026 14:26
5316deb to
8ad4ad0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Generated with Claude Code
PR 10 of the v7 API plan.
Stacked on #839. Non-breaking — a test and a doc amendment.
The rule this enforces
27 public enums cross a binding by ordinal. JNI resolves constants with
values()[code](jni_style.cpp:91); the apple and wasm mirrors arepositional too. Four headers say so, in comments:
A comment is not a guard. Reordering
FileTypecompiles, links, passes thesuite, and then silently mis-maps in a consumer that was built against the old
jar. This pins all 214 enumerators so that fails here instead.
Appending stays silent by design — a new enumerator adds a line. Inserting or
reordering fails loudly, in the same commit.
Why not explicit values in the headers
The plan originally said to write
= 0, 1, 2, …into the enums. Doing it, Idon't think that earns its place, and I have amended the plan rather than
leave the two disagreeing:
the header still compiles.
A test is what catches it.
wasm/tests/enums.test.mjsalready does exactlythis on the JS side; this is the C++ half, and the file says so.
Proof it works
Swapping
softandhardinHtmlTableGridlines— a two-line, entirelyplausible tidy-up:
(reverted; the swap was only to check the guard bites)
Notes
The list was generated from the headers, not typed, so it cannot disagree with
them by transcription. 27 tests, one per enum, and they run in 0 ms.