Skip to content

Document support for AppCDS #31497

Closed
Closed
@snicoll

Description

@snicoll

We want to explore the ability for a Spring-based app to run in a mode at build-time that allows recording various information that can be reused to optimize the actual app. We do this already with our Spring AOT engine that triggers application context parsing. During this special refresh phase (called refreshForAot) only a subset of the standard callbacks are invoked to prevent bean instantiation as much as possible.

The purpose of this issue is to see how that can be generalized or made a little bit more easy for tools to trigger it. The first candidate is AppCDS but there might be other components that need a "training run" of the app in a certain mode.

Concretely, we'd like to achieve the following:

  • Offer a configurable way of calling the regular refresh so that the app starts in a well-defined mode. This mode should be set externally so that the build-tool can have an impact on the application startup without any additional code change
  • Define a mode for AppCDS that performs as much as possible in terms of class loading.

Without any tooling, the following example could provide the class archive:

java -XX:ArchiveClassesAtExit=app-cds.jsa -Dspring.context.startup=AppCDS spring-petclinic-3.1.0-SNAPSHOT.jar

-Dspring.context.exit=onRefresh (see #31595) allows to tune the refresh phase, forcing the context to shut down once it has reached the requested phase so that the process stops and write the archive.

Spring Boot has additional tooling that could be reused to make that even more transparent for users.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions