Skip to content

Investigate remaining GraalVM native-image reachability concerns #206

Description

@stalep

Background

PR #205 fixed the main GraalVM native-image issue by removing FfmPty and LibC from reflect-config.json and excluding FfmTerminalProvider from ServiceLoader discovery. However, there may be other reachability paths that could cause issues.

Concerns to investigate

1. TtyDetect → LibC path

TtyDetect.tryNativeIsatty() uses Class.forName("org.aesh.terminal.tty.impl.LibC"). GraalVM's static analysis follows Class.forName string constants regardless of runtime guards (OSUtils.IS_WINDOWS). This could make LibC (and its FFM bytecode) reachable during native-image builds.

The native-image.properties only excludes FfmTerminalProvider from ServiceLoader — it doesn't address the TtyDetectLibC path.

Possible fix: Add a native-image substitution that replaces tryNativeIsatty() with a no-op in native-image, or ensure the Throwable catch in tryNativeIsatty() handles GraalVM analysis gracefully.

2. WinConsoleNative FFM variant bytecode parsing

Our WinConsoleNative FFM variant (Java 22+) has an OS guard that sets MethodHandle fields to null on non-Windows. But the if-branch still contains Linker.nativeLinker() and SymbolLookup.libraryLookup("kernel32", ...) calls. GraalVM may parse this bytecode during static analysis even on non-Windows builds.

Possible fix: If this causes issues, may need to exclude WinConsoleNative from reachability similar to how FfmTerminalProvider is excluded.

3. WinSysTerminalProvider reachability chain

WinSysTerminalProviderWinSysTerminalAbstractWindowsTerminalWinConsoleNative — this class chain could make Windows FFM classes reachable on Linux native-image builds. The ServiceLoader exclusion only covers FfmTerminalProvider, not WinSysTerminalProvider.

WinSysTerminalProvider.isSupported() returns false on non-Windows, but GraalVM may follow the class references during static analysis regardless.

Possible fix: May need to exclude WinSysTerminalProvider from ServiceLoader discovery on non-Windows native-image builds, or use reflection for the WinSysTerminal reference.

Verification

The CI job added in PR #205 (GraalVM native-image build on Linux) should catch these if they're actual failures. If the CI passes, these concerns are theoretical and can be documented as non-issues.

Priority

Medium — depends on CI results. If the native-image build passes, these are non-issues for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions