Skip to content

Inaccessible During AOT/Native Compilation - Graalvm #2967

Closed
@alirezaalj

Description

@alirezaalj

Here’s a well-structured bug report you can submit to the springdoc-openapi GitHub repository:


Bug Report: Private Inner Class SpecificationStringPropertiesCustomizerBeanPostProcessor Inaccessible During AOT/Native Compilation

Description

When building a GraalVM native image with springdoc-openapi (v2.5.0+) and Spring Boot 3.x, the AOT compiler fails with the following error:

/build/generated/aotSources/org/springdoc/core/configuration/SpringDocSpecPropertiesConfiguration__BeanDefinitions.java:48: error: SpecificationStringPropertiesCustomizerBeanPostProcessor has private access in SpringDocSpecPropertiesConfiguration
private static BeanInstanceSupplier<SpringDocSpecPropertiesConfiguration.SpecificationStringPropertiesCustomizerBeanPostProcessor> getSpecificationStringPropertiesCustomizerBeanPostProcessorInstanceSupplier(

The issue occurs because the AOT-generated code cannot access the private inner class SpecificationStringPropertiesCustomizerBeanPostProcessor in SpringDocSpecPropertiesConfiguration.

Steps to Reproduce

  1. Environment:

    • Spring Boot: 3.4.4
    • SpringDoc OpenAPI: 2.5.0 (or 2.8.6)
    • GraalVM Native:
      openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30) OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing)
    • Java: 21
  2. Reproduction Steps:

    • Create a Spring Boot 3.x project with springdoc-openapi-starter-webmvc-ui.
    • Enable GraalVM native image compilation (org.graalvm.buildtools.native).
    • Run:
      ./gradlew nativeCompile
    • Result: Build fails with the above error.
  3. Minimal Test Case:

    @SpringBootApplication
    public class DemoApplication {
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    }

    (No explicit OpenAPI config needed—fails with default setup.)

Expected Behavior

  • The native image compilation should succeed, as springdoc-openapi should support Spring AOT and GraalVM native builds.

  • The SpecificationStringPropertiesCustomizerBeanPostProcessor should either be public or use a different mechanism for AOT compatibility.

  • Impact:

    • Blocks native image adoption for projects using springdoc-openapi.

Request

  • Could the SpecificationStringPropertiesCustomizerBeanPostProcessor be made public or modified for AOT compatibility?
  • Alternatively, could an official GraalVM native image hint be provided?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions