Skip to content

Add reachability-metadata-schema cross-validation#840

Merged
jormundur00 merged 11 commits into
1.0-M1from
jormundur00/gh-827
Mar 4, 2026
Merged

Add reachability-metadata-schema cross-validation#840
jormundur00 merged 11 commits into
1.0-M1from
jormundur00/gh-827

Conversation

@jormundur00

@jormundur00 jormundur00 commented Feb 25, 2026

Copy link
Copy Markdown
Member

In this PR we introduce cross-validation between the reachability-metadata-schema present in the users graal build and their reachability metadata repository. We do this to assure that the user is using compatible versions of graal and the metadata repo.

The validation covers the following cases, based on the presence of the new schema:

  1. If the schema is missing in both graal and the metadata repo, the validation is skipped,
  2. If the schema is present in graal, but missing from the metadata repo, the build warns with a suggestion for the user to update the version of the reachability metadata repo they're using,
  3. If the schema is present in the metadata repo, but missing from graal, the build fails with a suggestion for the user to update the version of graal they're using. If the graal they're using is under JDK21, the suggestion recommends upgrading to JDK 21 or 25, while if it is, it suggests upgrading to the latest release.
  4. If the schema is present in both graal and the metadata repo, the validation checks if their exact version matches. If the match fails, the build fails with a suggestion to update whichever has the lower schema version.

Also in this PR, we introduce tests for the SchemaValidationUtils, for both the old validateSchemas method and the new validateReachabilityMetadataSchema method. These tests verify that the newly-added utils work as intended.

Examples of stack traces which include various warnings/errors introduced by this validation:

  1. Case 2:
> Task :nativeTestCompile
[native-image-plugin] GraalVM Toolchain detection is disabled
Warning: Your GraalVM installation at /tmp/junit-12662119171325135338/graal-only provides a reachability-metadata schema,
but the configured reachability metadata repository at /tmp/junit-12662119171325135338/repo-no-schema does not.
Please update your reachability metadata repository to a newer version.
[native-image-plugin] GraalVM location read from environment variable: GRAALVM_HOME
[native-image-plugin] Native Image executable path: /home/jovan/ol/bb/master/graal/sdk/mxbuild/linux-amd64/GRAALVM_56069D68E4_JAVA25/graalvm-56069d68e4-java25-25.1.0-dev/lib/svm/bin/native-image
Apply jar:file:///home/jovan/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-core/10.0.20/cdb01ea7a0cde50cb94b439462a9c4c54d4cc9b0/tomcat-embed-core-10.0.20.jar!/META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/native-image.properties
Apply file:///home/jovan/Work/grm-fork/graalvm-reachability-metadata/tests/src/com.ecwid.consul/consul-api/1.4.5/build/resources/test/META-INF/native-image/commons-logging-hints/reflect-config.json
Apply file:///home/jovan/Work/grm-fork/graalvm-reachability-metadata/tests/src/com.ecwid.consul/consul-api/1.4.5/build/resources/test/META-INF/native-image/tomcat-hints/reflect-config.json
Apply file:///home/jovan/Work/grm-fork/graalvm-reachability-metadata/tests/src/com.ecwid.consul/consul-api/1.4.5/build/resources/test/META-INF/native-image/tomcat-hints/resource-config.json
Warning: Using a deprecated option --no-fallback from command line. No effect, no replacement available
Warning: Using a deprecated option --no-fallback from command line. No effect, no replacement available
Warning: The option '-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/tomcat-reflection.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
  1. Case 3:
> Task :nativeTestCompile FAILED

[Incubating] Problems report is available at: file:///home/jovan/Work/grm-fork/graalvm-reachability-metadata/tests/src/com.ecwid.consul/consul-api/1.4.5/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nativeTestCompile'.
> The configured GraalVM reachability metadata repository at /home/jovan/Work/grm-fork/graalvm-reachability-metadata/metadata provides a reachability-metadata schema, but your GraalVM installation at /home/jovan/.sdkman/candidates/java/25.0.1-graal does not. Please update your GraalVM installation to a newer version. Update to the latest available release in your line. For example: Update your GraalVM version from 25.0.0 to 25.0.2.
  1. Case 4 (when there is a version mismatch):
> Task :nativeTestCompile FAILED

[Incubating] Problems report is available at: file:///home/jovan/Work/grm-fork/graalvm-reachability-metadata/tests/src/com.ecwid.consul/consul-api/1.4.5/build/reports/problems/problems-report.html
FAILURE: Build failed with an exception.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.

* What went wrong:
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
Execution failed for task ':nativeTestCompile'.

> Detected reachability-metadata schema version mismatch. Repository v1.1.0 vs graal v1.2.0. Please update your reachability metadata repository to a newer version.
For more on this, please refer to https://docs.gradle.org/9.1.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

Fixes: #827

@jormundur00 jormundur00 requested a review from vjovanov February 25, 2026 09:34
@jormundur00 jormundur00 self-assigned this Feb 25, 2026
@jormundur00 jormundur00 added the enhancement New feature or request label Feb 25, 2026
@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 25, 2026

@jormundur00 jormundur00 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offline pair-review results.

}
try {
String content = Files.readString(schemaFile);
Matcher vm = Pattern.compile("\"version\"\\s*:\\s*\"(\\d+)\\.(\\d+)\\.(\\d+)\"").matcher(content);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pattern.compile("") should be a constant, it's a common pattern to execute this only once as it is an expensive operation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a constant.

// Since both the metadata repository and the graal installation don't provide a schema,
// we skip validation.
} else if (schemaExistsInMetadataRepo && !schemaExistsInGraal) {
String message = "The configured GraalVM reachability metadata repository at "

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to try this PR out on a practical example and report on how error messages look like in the PR description.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left parts of the outputs for the 3 major cases of this validation in the PR description. Take note that smart IDEs (such as IntelliJ Idea) automatically "multi-line" these outputs.

@jormundur00 jormundur00 merged commit 74d0d31 into 1.0-M1 Mar 4, 2026
566 checks passed
@jormundur00 jormundur00 deleted the jormundur00/gh-827 branch March 4, 2026 08:58
jormundur00 added a commit that referenced this pull request Mar 18, 2026
* Remove the usage of the global metadata/index.json from the nbt plugins (#837)

* Add reachability-metadata-schema cross-validation (#840)

* Move to 1.0-M1-SNAPSHOT

* Fix broken ReachabilityMetadataFunctionalTest so that it works with the new metadata format

* Disable LayeredApplicationFunctionalTest

* Move to using actual 1.0-M1 release of reachability metadata
mergify Bot added a commit to robfrank/linklift that referenced this pull request May 3, 2026
…1.5 to 1.1.0 [skip ci]

Bumps [org.graalvm.buildtools:native-maven-plugin](https://github.com/graalvm/native-build-tools) from 0.11.5 to 1.1.0.
Release notes

*Sourced from [org.graalvm.buildtools:native-maven-plugin's releases](https://github.com/graalvm/native-build-tools/releases).*

> 1.1.0
> -----
>
> What's Changed
> --------------
>
> * Release 1.0.0 by [`@​graalvmbot`](https://github.com/graalvmbot) in [graalvm/native-build-tools#857](https://redirect.github.com/graalvm/native-build-tools/pull/857)
> * Bump version to 1.0.1-SNAPSHOT by [`@​graalvmbot`](https://github.com/graalvmbot) in [graalvm/native-build-tools#858](https://redirect.github.com/graalvm/native-build-tools/pull/858)
> * Use a safer way to create the temporary access filter file by [`@​sschuberth`](https://github.com/sschuberth) in [graalvm/native-build-tools#852](https://redirect.github.com/graalvm/native-build-tools/pull/852)
> * Bump io.netty:netty-codec-http from 4.1.129.Final to 4.1.132.Final in /samples/metadata-repo-integration by [`@​dependabot`](https://github.com/dependabot)[bot] in [graalvm/native-build-tools#859](https://redirect.github.com/graalvm/native-build-tools/pull/859)
> * Add class introduced in 5.14.1/6.0.1 by [`@​marcphilipp`](https://github.com/marcphilipp) in [graalvm/native-build-tools#794](https://redirect.github.com/graalvm/native-build-tools/pull/794)
> * Reduce CI usage by running CI only on "pull\_request" and running only the latest gradle version (except when creating a new release) by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#861](https://redirect.github.com/graalvm/native-build-tools/pull/861)
> * Update latest docs symlink and improve 1.0.0 release notes by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#866](https://redirect.github.com/graalvm/native-build-tools/pull/866)
> * Fix early classpath resolution in GenerateDynamicAccessMetadata by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#868](https://redirect.github.com/graalvm/native-build-tools/pull/868)
> * Bump reachability metadata version to 1.0.0 by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#879](https://redirect.github.com/graalvm/native-build-tools/pull/879)
> * Add listLibrariesMissingMetadata task/goal for Gradle and Maven by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#877](https://redirect.github.com/graalvm/native-build-tools/pull/877)
>
> **Full Changelog**: <graalvm/native-build-tools@1.0.0...1.1.0>
>
> 1.0.0
> -----
>
> Breaking Changes
> ----------------
>
> * Native Build Tools 1.0.0 moves to the `1.0-M1` release of the reachability metadata repository, which uses the new `reachability-metadata.json` metadata format and no longer uses the global `metadata/index.json`.
> * This may require dependency and metadata updates in downstream projects; some stacks can regress until they adapt.
>
> What's Changed
> --------------
>
> * Fix broken JavaApplicationFunctionalTest due to using a removed feature by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#850](https://redirect.github.com/graalvm/native-build-tools/pull/850)
> * Remove the usage of the global metadata/index.json from the nbt plugins by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#829](https://redirect.github.com/graalvm/native-build-tools/pull/829)
> * Add reachability-metadata-schema cross-validation by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#840](https://redirect.github.com/graalvm/native-build-tools/pull/840)
> * Merge 1.0-M1 branch to master by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#848](https://redirect.github.com/graalvm/native-build-tools/pull/848)
>
> **Full Changelog**: <graalvm/native-build-tools@0.11.5...1.0.0>


Commits

* [`84cc046`](graalvm/native-build-tools@84cc046) Release 1.1.0
* [`95512d0`](graalvm/native-build-tools@95512d0) Add listLibrariesMissingMetadata task/goal for Gradle and Maven ([#877](https://redirect.github.com/graalvm/native-build-tools/issues/877))
* [`0dcda78`](graalvm/native-build-tools@0dcda78) Merge pull request [#879](https://redirect.github.com/graalvm/native-build-tools/issues/879) from jormundur00/bump-metadata-repository-1.0.0
* [`e5b90f0`](graalvm/native-build-tools@e5b90f0) Bump reachability metadata version to 1.0.0
* [`05f45d3`](graalvm/native-build-tools@05f45d3) Fix early classpath resolution in GenerateDynamicAccessMetadata ([#868](https://redirect.github.com/graalvm/native-build-tools/issues/868))
* [`4d614c7`](graalvm/native-build-tools@4d614c7) Update latest docs symlink and improve 1.0.0 release notes ([#866](https://redirect.github.com/graalvm/native-build-tools/issues/866))
* [`ee1351d`](graalvm/native-build-tools@ee1351d) Reduce CI usage by running CI only on "pull\_request" and running only the lat...
* [`c6f3674`](graalvm/native-build-tools@c6f3674) Add class introduced in 5.14.1/6.0.1 ([#794](https://redirect.github.com/graalvm/native-build-tools/issues/794))
* [`5bc69bd`](graalvm/native-build-tools@5bc69bd) Bump io.netty:netty-codec-http from 4.1.129.Final to 4.1.132.Final in /sample...
* [`395f3b2`](graalvm/native-build-tools@395f3b2) Use a safer way to create the temporary access filter file ([#852](https://redirect.github.com/graalvm/native-build-tools/issues/852))
* Additional commits viewable in [compare view](graalvm/native-build-tools@0.11.5...1.1.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.graalvm.buildtools:native-maven-plugin&package-manager=maven&previous-version=0.11.5&new-version=1.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants