Skip to content

Commit e46e576

Browse files
authored
Merge pull request #50949 from geoand/jdk25-aot-workflow
Use simplified AOT file creation workflow provided by JEP-514
2 parents 9211a18 + 9350a85 commit e46e576

File tree

2 files changed

+10
-61
lines changed

2 files changed

+10
-61
lines changed

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JvmStartupOptimizerArchiveBuildStep.java

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -226,68 +226,22 @@ private Path createAppCDSFromExit(JarBuildItem jarResult,
226226
private Path createAot(JarBuildItem jarResult,
227227
OutputTargetBuildItem outputTarget, String javaBinPath, String containerImage,
228228
boolean isFastJar) {
229-
// first we run java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf -jar ...
230-
ArchivePathsContainer aotConfigPathContainers = ArchivePathsContainer.aotConfFromQuarkusJar(jarResult.getPath());
231-
Path aotConfPath = launchArchiveCreateCommand(aotConfigPathContainers.workingDirectory,
232-
aotConfigPathContainers.resultingFile,
233-
recordAotConfCommand(jarResult, outputTarget, javaBinPath, containerImage, isFastJar, aotConfigPathContainers));
234-
if (aotConfPath == null) {
235-
// something went wrong, bail as the issue has already been logged
236-
return null;
229+
if (Runtime.version().feature() < 25) {
230+
throw new IllegalStateException(
231+
"AOT cache generation requires building with JDK 25 or newer (see JEP 514). ");
237232
}
238-
239-
// now we run java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf -jar ...
240233
ArchivePathsContainer aotPathContainers = ArchivePathsContainer.aotFromQuarkusJar(jarResult.getPath());
241234
return launchArchiveCreateCommand(aotPathContainers.workingDirectory, aotPathContainers.resultingFile,
242-
createAotCommand(jarResult, outputTarget, javaBinPath, containerImage, isFastJar, aotConfPath));
235+
createAotCommand(jarResult, outputTarget, javaBinPath, containerImage, isFastJar, aotPathContainers));
243236

244237
}
245238

246-
private List<String> recordAotConfCommand(JarBuildItem jarResult, OutputTargetBuildItem outputTarget, String javaBinPath,
247-
String containerImage, boolean isFastJar,
248-
ArchivePathsContainer aotConfigPathContainers) {
249-
List<String> javaArgs = new ArrayList<>();
250-
javaArgs.add("-XX:AOTMode=record");
251-
javaArgs.add("-XX:AOTConfiguration=" + aotConfigPathContainers.resultingFile.getFileName().toString());
252-
javaArgs.add(String.format("-D%s=true", MainClassBuildStep.GENERATE_APP_CDS_SYSTEM_PROPERTY));
253-
javaArgs.add("-jar");
254-
255-
List<String> command;
256-
if (containerImage != null) {
257-
List<String> dockerRunCommand = dockerRunCommands(outputTarget, containerImage,
258-
isFastJar ? CONTAINER_IMAGE_BASE_BUILD_DIR + "/" + FastJarFormat.DEFAULT_FAST_JAR_DIRECTORY_NAME
259-
: CONTAINER_IMAGE_BASE_BUILD_DIR + "/" + jarResult.getPath().getFileName().toString());
260-
command = new ArrayList<>(dockerRunCommand.size() + 1 + javaArgs.size());
261-
command.addAll(dockerRunCommand);
262-
command.add("java");
263-
command.addAll(javaArgs);
264-
if (isFastJar) {
265-
command.add(FastJarFormat.QUARKUS_RUN_JAR);
266-
} else {
267-
command.add(jarResult.getPath().getFileName().toString());
268-
}
269-
} else {
270-
command = new ArrayList<>(2 + javaArgs.size());
271-
command.add(javaBinPath);
272-
command.addAll(javaArgs);
273-
if (isFastJar) {
274-
command
275-
.add(jarResult.getLibraryDir().getParent().resolve(FastJarFormat.QUARKUS_RUN_JAR)
276-
.getFileName().toString());
277-
} else {
278-
command.add(jarResult.getPath().getFileName().toString());
279-
}
280-
}
281-
return command;
282-
}
283-
284239
private List<String> createAotCommand(JarBuildItem jarResult, OutputTargetBuildItem outputTarget, String javaBinPath,
285240
String containerImage, boolean isFastJar,
286-
Path aotConfPath) {
241+
ArchivePathsContainer aotPathContainers) {
287242
List<String> javaArgs = new ArrayList<>();
288-
javaArgs.add("-XX:AOTMode=create");
289-
javaArgs.add("-XX:AOTConfiguration=" + aotConfPath.getFileName().toString());
290-
javaArgs.add("-XX:AOTCache=app.aot");
243+
javaArgs.add("-XX:AOTCacheOutput=" + aotPathContainers.resultingFile.getFileName().toString());
244+
javaArgs.add(String.format("-D%s=true", MainClassBuildStep.GENERATE_APP_CDS_SYSTEM_PROPERTY));
291245
javaArgs.add("-jar");
292246

293247
List<String> command;
@@ -369,10 +323,6 @@ public static ArchivePathsContainer appCDSFromQuarkusJar(Path jar) {
369323
return doCreate(jar, "app-cds.jsa");
370324
}
371325

372-
public static ArchivePathsContainer aotConfFromQuarkusJar(Path jar) {
373-
return doCreate(jar, "app.aotconf");
374-
}
375-
376326
public static ArchivePathsContainer aotFromQuarkusJar(Path jar) {
377327
return doCreate(jar, "app.aot");
378328
}

docs/src/main/asciidoc/appcds.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,14 @@ AppCDS has improved significantly in the latest JDK releases. This means that to
9898
[TIP]
9999
====
100100
Starting with JDK 24, the JVM provides an evolution of the class-data sharing in the form of the AOT cache.
101-
If you are building an application that will target JDK 24+ you can take advantage of this feature by adding the following system property when packaging your application:
101+
If you are building an application that will target JDK 25+ you can take advantage of this feature by adding the following system property when packaging your application:
102102
103103
[source,bash]
104104
----
105-
-Dquarkus.package.jar.appcds.use-aot=true
105+
-Dquarkus.package.jar.appcds.enabled=true -Dquarkus.package.jar.appcds.use-aot=true
106106
----
107107
108-
The result of this flag (plus the `-Dquarkus.package.jar.appcds.enabled=true` original one) is the creation of an AOT cache file
109-
named `app.aot`.
108+
The result of using these flags is the creation of an AOT cache file named `app.aot`.
110109
111110
You can use this AOT cache when launching the application like so:
112111

0 commit comments

Comments
 (0)