Skip to content

Clean and automate native-image metadata#1887

Merged
bodiam merged 1 commit into
mainfrom
agent/reliable-native-metadata-generation
Jul 22, 2026
Merged

Clean and automate native-image metadata#1887
bodiam merged 1 commit into
mainfrom
agent/reliable-native-metadata-generation

Conversation

@bodiam

@bodiam bodiam commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • regenerate GraalVM reachability metadata without test classes, test dependencies, or test-only resources
  • add a repeatable tracing-agent profile and generation script
  • derive test-class exclusions from compiled test output and include resources from Datafaker plus runtime dependencies
  • validate generated metadata before replacing the published file

Root cause

The checked-in metadata was generated from the full test process without sufficient filtering. That allowed JUnit, Mockito, Byte Buddy, IDE, and test fixture metadata to leak into the library artifact. Resource discovery was also dependent on which paths happened to execute during tests.

Validation

  • JAVA_HOME=/Users/erikpragt/.sdkman/candidates/java/current ./scripts/update-native-image-metadata.sh
    • 20,445 tests; 0 failures; metadata validation passed
  • GraalVM 25 native REST build with --no-fallback
  • native executable smoke test: GET /persons returned 10 generated people, including phone and address data
  • git diff --check and JSON syntax validation

@what-the-diff

what-the-diff Bot commented Jul 21, 2026

Copy link
Copy Markdown

PR Summary

  • Enhanced Native Image Documentation
    The project's guidance document (README.md) has been updated to help users better understand how to generate metadata for native images and to clarify the prerequisites needed.

  • New Automatic Metadata Generation Script
    A new Bash script update-native-image-metadata.sh has been introduced, which automates the process of generating metadata for native images using GraalVM.

  • Additional Maven Build Configurations
    A new Maven profile nativeMetadata has been added to the Maven configuration file (pom.xml). This provides more build options during the project development process.

  • Test Class for Metadata Verification
    There's a new set of tests named NativeImageMetadataTest.java. These tests will ensure that the generated metadata only contains information about production level code, improving the overall accuracy and relevance of the metadata.

  • Filtering of Native Image Analysis
    A new JSON file named native-image-agent-filter.json has been added. It helps in eliminating certain classes from the analysis performed by the native image agent, ensuring more precise and concise information in the analysis results.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.49%. Comparing base (66360d3) to head (da3c506).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1887      +/-   ##
============================================
+ Coverage     92.44%   92.49%   +0.05%     
- Complexity     3566     3568       +2     
============================================
  Files           347      347              
  Lines          7051     7051              
  Branches        675      675              
============================================
+ Hits           6518     6522       +4     
+ Misses          369      366       -3     
+ Partials        164      163       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kingthorin

Copy link
Copy Markdown
Collaborator

I have zero insight/knowledge on this

@bodiam

bodiam commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

I have zero insight/knowledge on this

yeah, same, but I made an native build using Codex, and it mentioned that our image is too big. This was the context Codex gave me:

  Datafaker worked natively, but its reachability metadata contained test-runner, JUnit,
  Mockito, Byte Buddy, and IDE entries. I cleaned that metadata and added src/test/java/net/
  datafaker/NativeImageMetadataTest.java:15 to prevent regression.

  Results:

  - Reachability metadata: 470 KB → 259 KB
  - Reflection entries: 856 → 372
  - Native-image warnings: removed
  - Native executable: 48.27 MB → 41.47 MB
  - Metadata regression test and formatting checks pass

I've built an new app now using Datafaker as a native build with the updated version of Datafaker, and it works fine, so I think it's fine.

@bodiam
bodiam marked this pull request as ready for review July 22, 2026 04:16
@bodiam

bodiam commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

I'm just gonna assume you approved it. Thanks @kingthorin ;-)

@bodiam
bodiam merged commit 2729350 into main Jul 22, 2026
17 checks passed
@bodiam
bodiam deleted the agent/reliable-native-metadata-generation branch July 22, 2026 04:18
@asolntsev asolntsev added this to the 3.0.0 milestone Jul 23, 2026
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.

4 participants