JEP 483: Ahead-of-Time Class Loading & Linking failing on a simple Gradle Spring Boot project

Sebastien Deleuze sebastien.deleuze at broadcom.com
Sat May 10 10:39:22 UTC 2025


Hi Daniel,

The Spring team does not recommend generating the AOT cache using the app
tests.

See related documentation and guidance in
https://docs.spring.io/spring-framework/reference/7.0-SNAPSHOT/integration/aot-cache.html
and
https://docs.spring.io/spring-boot/reference/packaging/class-data-sharing.html#packaging.class-data-sharing.aot-cache
.

Best regards,
Sébastien

On Fri, May 9, 2025 at 4:14 PM Daniel Andres Pelaez Lopez <
estigma88 at gmail.com> wrote:

> Hi loi,
>
> Thanks for the input.
>
> Yes, I am aware that packaging the app as a JAR will work, I have tested
> that before for production code, however, that doesn't fit the use case I
> am looking for: Using the app tests to generate the AOT cache. If we
> require to package a JAR that executes the tests, that seems like overkill.
> My thinking is that the Java community is most likely using CI/CD to run
> tests and using Maven/Gradle for that purpose, so, having support for
> creating the AOT cache from tests and from those tools, will allow to the
> community to adopt this features faster.
>
> El jue, 8 may 2025 a las 21:58, <ioi.lam at oracle.com> escribió:
>
>> It looks like your classpath have some directories:
>>
>>
>> [4,648s][error  ][cds        ] Error: non-empty directory
>> '/home/danielpelaez/Documents/Distribution/aot/java-aot/build/classes/java/test'
>> [4,648s][error  ][cds        ] Error: non-empty directory
>> '/home/danielpelaez/Documents/Distribution/aot/java-aot/build/classes/java/main'
>> [4,648s][error  ][cds        ] Error: non-empty directory
>> '/home/danielpelaez/Documents/Distribution/aot/java-aot/build/resources/main'
>>
>>
>> Please try to package these directories into a JAR file and use that in
>> your classpath.
>>
>>
>> Thanks
>>
>> - Ioi
>> On 5/7/25 12:57 PM, Daniel Andres Pelaez Lopez wrote:
>>
>> Hi everyone,
>>
>> We are testing JEP 483 on JDK 24 using the following dummy Gradle Spring
>> Boot project: https://github.com/estigma88/java-aot/tree/master. As we
>> want to generate the AOT cache from the tests, we added a custom Test task
>> to receive the AOT flags for the JVM as follows:
>>
>> tasks.withType<Test> {
>>    useJUnitPlatform()
>>
>>    project.findProperty("aot")?.let {
>>       val aotFlags = it.toString().split(",")
>>       jvmArgs(aotFlags)
>>     }
>> }
>>
>> And we are using the following commands to generate the AOT cache:
>>
>> ./gradlew :test
>> -Paot="-XX:AOTMode=record,-XX:AOTConfiguration=app.aotconf" -> This one
>> succeed
>>
>> ./gradlew :test
>> -Paot="-XX:AOTMode=create,-XX:AOTConfiguration=app.aotconf,-XX:AOTCache=app.aot"
>> -> This one fails
>>
>> The following are the logs for the create command:
>>
>> [1,328s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.http.client.ReactorResourceFactory
>> [1,579s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.test.context.transaction.TransactionalTestExecutionListener
>> [1,581s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener
>> [1,668s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.boot.logging.log4j2.Log4J2LoggingSystem
>> [2,412s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.http.codec.multipart.DefaultPartHttpMessageReader
>> [2,575s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.boot.autoconfigure.cache.InfinispanCacheConfiguration
>> [2,577s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.boot.autoconfigure.cache.RedisCacheConfiguration
>> [2,799s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer
>> [3,029s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.core.ReactiveAdapterRegistry$ReactorAdapter
>> [3,109s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.boot.http.client.JettyClientHttpRequestFactoryBuilder
>> [3,110s][warning][cds] Preload Warning: Verification failed for
>> org.springframework.boot.http.client.HttpComponentsClientHttpRequestFactoryBuilder
>> [3,180s][warning][cds] java.lang.ClassNotFoundException:
>> org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher
>> [3,180s][warning][cds] Preload Warning: Cannot find
>> org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher
>> [3,196s][warning][cds] Preload Warning: Verification failed for
>> org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator
>> [3,197s][warning][cds] java.lang.NoClassDefFoundError:
>> org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher
>> [3,197s][warning][cds] Preload Warning: Cannot find
>> org/mockito/internal/creation/bytebuddy/MockMethodAdvice
>> [3,307s][warning][cds] java.lang.ClassNotFoundException:
>> net.bytebuddy.utility.Invoker$Dispatcher
>> [3,307s][warning][cds] Preload Warning: Cannot find
>> net/bytebuddy/utility/Invoker$Dispatcher
>> [3,906s][warning][cds,resolve] :
>> An error has occurred while processing class list file app.aotconf 9635:5.
>> [3,906s][warning][cds,resolve] @cp
>> org/mockito/internal/creation/bytebuddy/MockMethodAdvice 1 2 7 9 10 11 17
>> 22 26 28 29 33 36 40 44 48 258
>> class org/mockito/internal/creation/bytebuddy/MockMethodAdvice is not
>> (yet) loaded by one of the built-in loaders[3,906s][warning][cds,resolve]
>>   ^
>> [3,906s][warning][cds,resolve] Your classlist may be out of sync with the
>> JDK or the application.
>> An error has occurred while processing class list file app.aotconf
>> 11862:5.
>> [4,467s][warning][cds,resolve] :
>> class org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher
>> is not (yet) loaded by one of the built-in
>> loaders[4,467s][warning][cds,resolve] @cp
>> org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher 1 2 8
>> 14 20 25 27 38 59
>> [4,467s][warning][cds,resolve]     ^
>> [4,467s][warning][cds,resolve] Your classlist may be out of sync with the
>> JDK or the application.
>> [4,608s][warning][cds        ] Preload Warning: Verification failed for
>> org.springframework.web.servlet.view.freemarker.FreeMarkerView
>> [4,648s][error  ][cds        ] Error: non-empty directory
>> '/home/danielpelaez/Documents/Distribution/aot/java-aot/build/classes/java/test'
>> [4,648s][error  ][cds        ] Error: non-empty directory
>> '/home/danielpelaez/Documents/Distribution/aot/java-aot/build/classes/java/main'
>> [4,648s][error  ][cds        ] Error: non-empty directory
>> '/home/danielpelaez/Documents/Distribution/aot/java-aot/build/resources/main'
>> Hint: enable -Xlog:class+path=info to diagnose the failure
>> Error occurred during CDS dumping
>> Cannot have non-empty directory in paths
>>
>> Error logs seem related to the AOT feature and not Gradle, but you will
>> know better.
>>
>> Any help would be appreciated.
>>
>> --
>> Daniel
>> e. estigma88 at gmail.com
>>
>>
>
> --
> Daniel
> e. estigma88 at gmail.com
>

-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/leyden-dev/attachments/20250510/411f5057/attachment.htm>


More information about the leyden-dev mailing list