Skip to content

InaccessibleObjectException with SetFromMap in GraalVM Native Image Build #152

@LiveNathan

Description

@LiveNathan

Class<?> clazz = XReflect.getDeclaredNestedClass(Collections.class, "java.util.Collections$SetFromMap");

Description:
While building a native image of a Spring Boot application using GraalVM (v21.0.5, Java 21) and EclipseStore (v2.0.0), I encountered the following error due to SetFromMap:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field final java.util.Map java.util.Collections$SetFromMap.m accessible...

I've attempted multiple configurations (reflect-config.json, --add-opens, RuntimeHints) without success. A community suggestion pointed out that Eclipse Serializer might rely on reflective access to internal Java classes. Could Serializer adapt to avoid internal class access to ensure compatibility with GraalVM native images?

Steps to Reproduce:

  1. Add EclipseStore to a Spring Boot application.
  2. Build with GraalVM native-image.
  3. Run the native image.

Expected Behavior: No reflection errors in GraalVM native image builds.

Additional Information:

GitHub Repository: LiveNathan/nativeImageTest
Stackoverflow Question: GraalVM native image build fails using EclipseStore
EclipseStore Discussion: Eclipse Store GitHub Discussion #297

Thank you!

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