Provide guidelines in AspectJ documentation to avoid dumps #27650
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: documentation
A documentation task
Milestone
Preface
When using
spring-aspects
with native AspectJ LTW, the AspectJ weaving agent core-dumps, at least in some Spring Boot playground projects I am using in order to answer AOP-related StackOverflow questions. I am not sure if this is is specific to Spring Boot (did not try without it) and ought to be fixed there, or if it is a Spring Core (spring-aspects) problem. Maybe, it even needs some work in AspectJ. Probably the best person to answer that is @aclement, who I had a private conversation with about this issue already.Either way, it is an issue that needs to be tracked here, because it affects Spring users.
Issue description
As discussed in StackOverflow question #69800420, running a minimal Spring Boot application with JVM parameters (parameter in a single line, of course, and the first one only necessary for JDK 16+)
yields
ajcore.*.txt
core dump files created by AspectJ. Corresponding stack traces featuringMissingResolvedTypeWithKnownSignature
are logged to the console. The missing resolved type varies between Spring Boot versions and is e.g.org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer
for Boot 2.3.3 andorg.springframework.boot.jdbc.DataSourceBuilder.OraclePoolDataSourceProperties
for Boot 2.5.6.How to reproduce
aspectj
if you prefer Gradle and branchaspectj-with-maven
for Maven. The code in both branches is equivalent, only the build tool differs.aop.xml
file, you are not going to see any problems.aop.xml
file or comment out the<exclude within="..."/>
tags.Workaround
The default
aop.xml
forspring-aspects
simply declares aspects and no further weaving options.A simple way to avoid the core dumps is to exclude problematic target classes from weaving. Even if a future AspectJ release would contain a fix avoiding the core dumps, until then Spring Core could avoid weaving unwanted classes and/or packages by excluding them like I have shown in my custom
aop.xml
file:These weaver options could be merged into the upstream
aop.xml
forspring-instruments
. Otherwise, all users would have to create a customaop.xml
by themselves like I did, just so as to avoid an upstream problem.BTW, the weaver by default prints lots of
[Xlint:cantFindType]
warnings, which do no harm but clutter the console log. You might also want to consider adding the-Xlint:ignore
weaver option. Another helpful default option is-showWeaveInfo
, because it would show to the user by default all woven joinpoints. I think the latter is more desireable than the Xlint messages. But both options are unrelated to the workaround for this issue, I am just mentioning them as ideas for improvement.The text was updated successfully, but these errors were encountered: