Repository navigation
Conversation
The transform goals now write META-INF/native-image/<groupId>/<artifactId>/smallrye-ffm/reachability-metadata.json with a foreign.downcalls entry for each distinct downcall shape, read back from the invokedynamic instructions which use the Bootstraps.downcall bootstrap, so that classes transformed by an earlier build are included. The layouts follow Bootstraps.layoutOf on a 64-bit platform; C long and wchar_t use their canonical names, and a shape with a C char is registered both as jbyte and as jint. The skipNativeMetadata parameter turns it off.
dmlloyd
reviewed
Nov 17, 2026
Comment on lines
+40
to
+41
| @Parameter(defaultValue = "false", property = "smallrye-ffm.skipNativeMetadata") | ||
| private boolean skipNativeMetadata; |
Contributor
There was a problem hiding this comment.
Can we please make this opt-in instead of opt-out?
| sb.append("}\n"); | ||
| Files.createDirectories(file.getParent()); | ||
| byte[] bytes = sb.toString().getBytes(StandardCharsets.UTF_8); | ||
| if (Files.exists(file) && Arrays.equals(Files.readAllBytes(file), bytes)) { |
Contributor
There was a problem hiding this comment.
What happens if something else is competing to write the metadata for other things, like reflection etc.?
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.
The
transformandtransform-testgoals now writeMETA-INF/native-image/<groupId>/<artifactId>/smallrye-ffm/reachability-metadata.json(GraalVM 25 schema v1.2.0) with oneforeign.downcallsentry per distinct downcall shape, so that a native-image build no longer needs the shapes registered by hand. The shapes are read back from theinvokedynamicinstructions which useBootstraps.downcall, after the transform, so classes transformed by an earlier (incremental) build are included and@Dispatchcall sites are covered too. Each entry has the return and parameter layouts and, as applicable,firstVariadicArg,captureCallStateandcritical(allowHeapAccess); entries are deduplicated and sorted, and the file is only rewritten when its content changes (it is removed when there are no downcalls). The layouts followBootstraps.layoutOfon a 64-bit platform (the only kind native-image supports), with the names Quarkus uses inFfmType(jint,jlong,void*, ...); Clongandwchar_tuse their canonical names, which native-image resolves for the target, and a shape with a Ccharis registered twice, asjbyteand asjint, becauseBootstrapspicks one or the other by the signedness ofcharon the platform. The file is in its ownsmallrye-ffmdirectory below<groupId>/<artifactId>so that it never overwrites areachability-metadata.jsonthe project ships itself (native-image walks every directory underMETA-INF/native-image), and no JSON merging is needed.-Dsmallrye-ffm.skipNativeMetadata(skipNativeMetadata) turns it off. The reflection and run-time initialization entries that the bootstrap may need (Linker.downcallHandlelooked up withfindVirtual,Bootstraps.<clinit>) are not included, since I could not verify them without a native build; this PR only covers theforeignsection.The mapping duplicates
Bootstraps.layoutOf, so a change there needs the same change inNativeMetadata; in particular #86 promotes narrow variadic arguments toint, and whichever of the two is merged second should map those tojint.NativeMetadataTestbuilds a class with@Linkmethods (fixed, variadic with the marker on a parameter and on the method,@Critical,ErrnoConsumer,@As(stdc_long), a duplicate shape, avoidfunction), runs thetransformgoal, and compares the whole file; it also runs the goal again over the already-transformed class, checks the skip parameter, that no file is written without downcalls, and the two forms of acharshape. It fails onmain, where nothing is written. The layout names were also checked againstBootstraps.layoutOfat run time on Linux x86_64 for every descriptor code.mvn verifyon JDK 25 (Linux x86_64): 38 tests, 3 skipped.