Class NativeImageConfigGenerator

java.lang.Object
cloud.opencode.base.classloader.graalvm.NativeImageConfigGenerator

public final class NativeImageConfigGenerator extends Object
GraalVM Native Image configuration file generator GraalVM Native Image 配置文件生成器

Scans specified packages using ClassScanner and generates GraalVM native image configuration files (reflect-config.json and resource-config.json).

使用 ClassScanner 扫描指定包并生成 GraalVM Native Image 配置文件(reflect-config.json 和 resource-config.json)。

Usage | 使用示例:

NativeImageConfigGenerator.builder()
    .addPackage("com.example.model")
    .addPackage("com.example.service")
    .addResourcePattern("config/.*")
    .addResourcePattern("templates/.*")
    .outputDir(Path.of("META-INF/native-image"))
    .generate();

Security | 安全性:

  • Thread-safe: Yes (Builder is not shared across threads) - 线程安全: 是(Builder 不跨线程共享)
Since:
JDK 25, opencode-base-classloader V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • builder

      public static NativeImageConfigGenerator.Builder builder()
      Create a new builder 创建新的构建器
      Returns:
      new builder instance | 新的构建器实例
    • generate

      public void generate() throws IOException
      Generate native image configuration files 生成 Native Image 配置文件

      Scans all configured packages, creates reflect-config.json and resource-config.json in the output directory.

      扫描所有已配置的包,在输出目录中创建 reflect-config.json 和 resource-config.json。

      Throws:
      IOException - if an I/O error occurs | 如果发生 I/O 错误
      IllegalStateException - if outputDir is not set | 如果未设置输出目录