Token导航 LogoToken导航TokenDH.com
图像处理需要联网github未标认证来源可访问许可证需确认审计通过

graalvm-native-imagegraalvm 原生镜像

Agent Skill

用于辅助图像生成、图片编辑、视觉素材处理或图像模型工作流。它适合让 Agent 根据文本生成图片、处理背景、整理视觉提示词或调用相关图像工具。使用时需要确认输入图片、版权来源、输出格式和模型限制;涉及人物、品牌、商品或公开展示素材时,应额外核对授权、真实性和内容合规边界。

总安装

10,309

周安装

433

GitHub Stars

229

下载量

3,395
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:graalvm-native-image(graalvm 原生镜像)
来源仓库:https://github.com/giuseppe-trisciuoglio/developer-kit
仓库路径:skills/graalvm-native-image
安装命令:
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill graalvm-native-image
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill graalvm-native-image

简介

graalvm-native-image 辅助图像生成与视觉素材处理工作流。

  • 适合根据文本提示生成图片或编辑背景素材。graalvm-native-image 属于图像处理类 Skill,可作为该场景下的辅助能力补充。
  • 使用时需确认输入图片版权、输出格式及模型限制。
  • 涉及人物、品牌等内容时应额外核对授权与合规性。
  • 建议在安装前了解所用模型的能力与输出边界。

SKILL.md

GraalVM Native Image for Java Applications

Expert skill for building high-performance native executables from Java applications using GraalVM Native Image, dramatically reducing startup time and memory consumption.

Overview

GraalVM Native Image compiles Java applications ahead-of-time (AOT) into standalone native executables. These executables start in milliseconds, require significantly less memory than JVM-based deployments, and are ideal for serverless functions, CLI tools, and microservices where fast startup and low resource usage are critical.

This skill provides a structured workflow to migrate JVM applications to native binaries, covering build tool configuration, framework-specific patterns, reflection metadata management, and an iterative approach to resolving native build failures.

When to Use

Use this skill when:

  • Converting a JVM-based Java application to a GraalVM native executable
  • Optimizing cold start times for serverless or containerized deployments
  • Reducing memory footprint (RSS) of Java microservices
  • Configuring Maven or Gradle with GraalVM Native Build Tools
  • Resolving ClassNotFoundException, NoSuchMethodException, or missing resource errors in native builds
  • Generating or editing reflect-config.json, resource-config.json, or other GraalVM metadata files
  • Using the GraalVM tracing agent to collect reachability metadata
  • Implementing RuntimeHints for Spring Boot native support
  • Building native images with Quarkus or Micronaut

Instructions

1. Contextual Project Analysis

Before any configuration, analyze the project to determine the build tool, framework, and dependencies:

Detect the build tool:

# Check for Maven
if [ -f "pom.xml" ]; then
    echo "Build tool: Maven"
    # Check for Maven wrapper
    [ -f "mvnw" ] && echo "Maven wrapper available"
fi

# Check for Gradle
if [ -f "build.gradle" ] || [ -f "build.gradle.kts" ]; then
    echo "Build tool: Gradle"
    [ -f "build.gradle.kts" ] && echo "Kotlin DSL"
    [ -f "gradlew" ] && echo "Gradle wrapper available"
fi

Detect the framework by analyzing dependencies:

  • Spring Boot: Look for spring-boot-starter-* in pom.xml or build.gradle
  • Quarkus: Look for quarkus-* dependencies
  • Micronaut: Look for micronaut-* dependencies
  • Plain Java: No framework dependencies detected

Check the Java version:

java -version 2>&1
# GraalVM Native Image requires Java 17+ (recommended: Java 21+)

Identify potential native image challenges:

  • Reflection-heavy libraries (Jackson, Hibernate, JAXB)
  • Dynamic proxy usage (JDK proxies, CGLIB)
  • Resource bundles and classpath resources
  • JNI or native library dependencies
  • Serialization requirements

2. Build Tool Configuration

Configure the appropriate build tool plugin based on the detected environment.

For Maven projects, add a dedicated native profile to keep the standard build clean. See the Maven Native Profile Reference for full configuration.

Key Maven setup:

<profiles>
  <profile>
    <id>native</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.graalvm.buildtools</groupId>
          <artifactId>native-maven-plugin</artifactId>
          <version>0.10.6</version>
          <extensions>true</extensions>
          <executions>
            <execution>
              <id>build-native</id>
              <goals>
                <goal>compile-no-fork</goal>
              </goals>
              <phase>package</phase>
            </execution>
          </executions>
          <configuration>
            <imageName>${project.artifactId}</imageName>
            <buildArgs>
              <buildArg>--no-fallback</buildArg>
            </buildArgs>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

Build with: ./mvnw -Pnative package

For Gradle projects, apply the org.graalvm.buildtools.native plugin. See the Gradle Native Plugin Reference for full configuration.

Key Gradle setup (Kotlin DSL):

plugins {
    id("org.graalvm.buildtools.native") version "0.10.6"
}

graalvmNative {
    binaries {
        named("main") {
            imageName.set(project.name)
            buildArgs.add("--no-fallback")
        }
    }
}

Build with: ./gradlew nativeCompile

3. Framework-Specific Configuration

Each framework has its own AOT strategy. Apply the correct configuration based on the detected framework.

Spring Boot (3.x+): Spring Boot has built-in GraalVM support with AOT processing. See the Spring Boot Native Reference for patterns including RuntimeHints, @RegisterReflectionForBinding, and test support.

Key points:

  • Use spring-boot-starter-parent 3.x+ which includes the native profile
  • Register reflection hints via RuntimeHintsRegistrar
  • Run AOT processing with process-aot goal
  • Build with: ./mvnw -Pnative native:compile or ./gradlew nativeCompile

Quarkus and Micronaut: These frameworks are designed native-first and require minimal additional configuration. See the Quarkus & Micronaut Reference.

4. GraalVM Reachability Metadata

Native Image uses a closed-world assumption — all code paths must be known at build time. Dynamic features like reflection, resources, and proxies require explicit metadata configuration.

Metadata files are placed in META-INF/native-image/<group.id>/<artifact.id>/:

FilePurpose
reachability-metadata.jsonUnified metadata (reflection, resources, JNI, proxies, bundles, serialization)
reflect-config.jsonLegacy: Reflection registration
resource-config.jsonLegacy: Resource inclusion patterns
proxy-config.jsonLegacy: Dynamic proxy interfaces
serialization-config.jsonLegacy: Serialization registration
jni-config.jsonLegacy: JNI access registration

See the Reflection & Resource Config Reference for complete format and examples.

5. The Iterative Fix Engine

Native image builds often fail due to missing metadata. Follow this iterative approach:

Step 1 — Execute the native build:

# Maven
./mvnw -Pnative package 2>&1 | tee native-build.log

# Gradle
./gradlew nativeCompile 2>&1 | tee native-build.log

Step 2 — Parse build errors and identify the root cause:

Common error patterns and their fixes:

Error PatternCauseFix
ClassNotFoundException: com.example.MyClassMissing reflection metadataAdd to reflect-config.json or use @RegisterReflectionForBinding
NoSuchMethodExceptionMethod not registered for reflectionAdd method to reflection config
MissingResourceExceptionResource not included in native imageAdd to resource-config.json
Proxy class not foundDynamic proxy not registeredAdd interface list to proxy-config.json
UnsupportedFeatureException: SerializationMissing serialization metadataAdd to serialization-config.json

Step 3 — Apply fixes by updating the appropriate metadata file or using framework annotations.

Step 4 — Rebuild and verify. Repeat until the build succeeds.

Step 5 — If manual fixes are insufficient, use the GraalVM tracing agent to collect reachability metadata automatically. See the Tracing Agent Reference.

6. Validation and Benchmarking

Once the native build succeeds:

Verify the executable runs correctly:

# Run the native executable
./target/<app-name>

# For Spring Boot, verify the application context loads
curl http://localhost:8080/actuator/health

Measure startup time:

# Time the startup
time ./target/<app-name>

# For Spring Boot, check the startup log
./target/<app-name> 2>&1 | grep "Started .* in"

Measure memory footprint (RSS):

# On Linux
ps -o rss,vsz,comm -p $(pgrep <app-name>)

# On macOS
ps -o rss,vsz,comm -p $(pgrep <app-name>)

Compare with JVM baseline:

MetricJVMNativeImprovement
Startup time~2-5s~50-200ms10-100x
Memory (RSS)~200-500MB~30-80MB3-10x
Binary sizeJRE + JARsSingle binarySimplified

7. Docker Integration

Build minimal container images with native executables:

# Multi-stage build
FROM ghcr.io/graalvm/native-image-community:21 AS builder
WORKDIR /app
COPY . .
RUN ./mvnw -Pnative package -DskipTests

# Minimal runtime image
FROM debian:bookworm-slim
COPY --from=builder /app/target/<app-name> /app/<app-name>
EXPOSE 8080
ENTRYPOINT ["/app/<app-name>"]

For Spring Boot applications, use paketobuildpacks/builder-jammy-tiny with Cloud Native Buildpacks:

./mvnw -Pnative spring-boot:build-image

Best Practices

  1. Start with the tracing agent on complex projects to generate an initial metadata baseline
  2. Use the native profile to keep native-specific config separate from standard builds
  3. Prefer --no-fallback to ensure a true native build (no JVM fallback)
  4. Test with nativeTest to run JUnit tests in native mode
  5. Use GraalVM Reachability Metadata Repository for third-party library metadata
  6. Minimize reflection — prefer constructor injection and compile-time DI where possible
  7. Include resource patterns explicitly rather than relying on classpath scanning
  8. Profile before and after — always measure startup and memory improvements
  9. Use Java 21+ for the best GraalVM compatibility and performance
  10. Keep GraalVM and Native Build Tools versions aligned

Examples

Example 1: Adding Native Support to a Spring Boot Maven Project

Scenario: You have a Spring Boot 3.x REST API and want to compile it to a native executable.

Step 1 — Add the native profile to pom.xml:

<profiles>
  <profile>
    <id>native</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <executions>
            <execution>
              <id>process-aot</id>
              <goals>
                <goal>process-aot</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.graalvm.buildtools</groupId>
          <artifactId>native-maven-plugin</artifactId>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

Step 2 — Register reflection hints for DTOs:

@RestController
@RegisterReflectionForBinding({UserDto.class, OrderDto.class})
public class UserController {

    @GetMapping("/users/{id}")
    public UserDto getUser(@PathVariable Long id) {
        return userService.findById(id);
    }
}

Step 3 — Build and run:

./mvnw -Pnative native:compile
./target/myapp
# Started MyApplication in 0.089 seconds

Example 2: Resolving a Reflection Error in Native Build

Scenario: Native build fails with ClassNotFoundException for a Jackson-serialized DTO.

Error output:

com.oracle.svm.core.jdk.UnsupportedFeatureError:
  Reflection registration missing for class com.example.dto.PaymentResponse

Fix — Add to src/main/resources/META-INF/native-image/reachability-metadata.json:

{
  "reflection": [
    {
      "type": "com.example.dto.PaymentResponse",
      "allDeclaredConstructors": true,
      "allDeclaredMethods": true,
      "allDeclaredFields": true
    }
  ]
}

Or use the Spring Boot annotation approach:

@RegisterReflectionForBinding(PaymentResponse.class)
@Service
public class PaymentService { /* ... */ }

Example 3: Using the Tracing Agent for a Complex Project

Scenario: A project with many third-party libraries needs comprehensive reachability metadata.

# 1. Build the JAR
./mvnw package -DskipTests

# 2. Run with the tracing agent
java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image \
    -jar target/myapp.jar

# 3. Exercise all endpoints
curl http://localhost:8080/api/users
curl -X POST http://localhost:8080/api/orders -H 'Content-Type: application/json' -d '{"item":"test"}'
curl http://localhost:8080/actuator/health

# 4. Stop the application (Ctrl+C), then build native
./mvnw -Pnative native:compile

# 5. Verify
./target/myapp

Constraints and Warnings

Critical Constraints

  • GraalVM Native Image requires Java 17+ (Java 21+ recommended for best compatibility)
  • Closed-world assumption: All code paths must be known at build time — dynamic class loading, runtime bytecode generation, and MethodHandles.Lookup may not work
  • Build time and memory: Native compilation is resource-intensive — expect 2-10 minutes and 4-8 GB RAM for typical projects
  • Not all libraries are compatible: Libraries relying heavily on reflection, dynamic proxies, or CGLIB may require extensive metadata configuration
  • AOT profiles are fixed at build time: Spring Boot @Profile and @ConditionalOnProperty are evaluated during AOT processing, not at runtime

Common Pitfalls

  • Forgetting --no-fallback: Without this flag, the build may silently produce a JVM fallback image instead of a true native executable
  • Incomplete tracing agent coverage: The agent only captures code paths exercised during the run — ensure all features are tested
  • Version mismatches: Keep GraalVM JDK, Native Build Tools plugin, and framework versions aligned to avoid incompatibilities
  • Classpath differences: The classpath at AOT/build time must match runtime — adding/removing JARs after native compilation causes failures

Security Considerations

  • Native executables are harder to decompile than JARs, but are not tamper-proof
  • Ensure secrets are not embedded in the native image at build time
  • Use environment variables or external config for sensitive data

Troubleshooting

IssueSolution
Build runs out of memoryIncrease build memory: -J-Xmx8g in buildArgs
Build takes too longUse build cache, reduce classpath, enable quick build mode for dev
Application crashes at runtimeMissing reflection/resource metadata — run tracing agent
Spring Boot context fails to loadCheck @Conditional beans and profile-dependent config
Third-party library not compatibleCheck GraalVM Reachability Metadata repo or add manual hints

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.08%
按下载量换算1,225

Claude

27.49%
按下载量换算933

Cursor

19.39%
按下载量换算658

Gemini CLI

8.45%
按下载量换算287

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills