Repository navigation
Conversation
FlatHashtable minted its tables with Array.newInstance(entryClass, n), and grew them with Array.newInstance(table.getClass().getComponentType(), n), to keep a precise component type: typed reads, real array-store checks and a precise element type for the JIT. GraalVM 17's native-image rejects that call unless each entry array type is registered for reflection; the failure surfaces in a class initializer and poisons the class for the life of the process. The factories now take an array constructor instead of a Class, last per the functional-parameter convention, e.g. FlatHashtable.D1.createFixed(capacity, MyEntry[]::new). An array constructor reference compiles to a plain new MyEntry[n], so the table keeps the same precise runtime type with no reflection. D1 and D2 keep the constructor to grow, and the raw core's resize / resizingInsert take it too, so growth stays precisely typed as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
This branch has not been deployed
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.
What Does This Do
FlatHashtablenow creates and grows its tables with an array constructor instead ofArray.newInstance.Class, last per the functional-parameter convention. For example,FlatHashtable.D1.createFixed(capacity, MyEntry[]::new), or for the raw core,FlatHashtable.create(capacity, MyEntry[]::new).D1andD2keep the constructor and use it when they grow. The raw core'sresizeandresizingInserttake it as their last argument.MyEntry[]::newcompiles to a plainnew MyEntry[n], so tables keep a precise runtime component type: typed reads, real array-store checks, and a precise element type for the JIT. That precision was the reason for passing aClass, and a new test pins it through growth.Motivation
GraalVM 17's native-image rejects
Array.newInstanceunless each entry array type is registered for reflection. The failure surfaces in a class initializer, which poisons the class for the life of the process.The first production user of
FlatHashtable, the dense store's sizing-hint table (#12926), hit exactly this: a native app sent no traces at all on GraalVM 17. GraalVM 21 and 25 were unaffected, most likely because they fold a constant class argument. The growth path's class comes fromtable.getClass(), which isn't a constant, so a growable table would probably fail on newer versions too; that part is untested.Fixing it here means no
FlatHashtableuser needs a per-type native-image registration.Additional Notes
Hashtable.create(Class, int)andStringIndex.mapValues(String[], Class, Function)also allocate reflectively, but have no production callers.ConcurrentHashtableandHashtable.D1/D2, which do have production users, already allocate without reflection.🤖 Generated with Claude Code