Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aspect not invoked in native image #30529

Closed
phejl opened this issue May 23, 2023 · 7 comments
Closed

Aspect not invoked in native image #30529

phejl opened this issue May 23, 2023 · 7 comments
Assignees
Labels
for: external-project Needs a fix in external project theme: aot An issue related to Ahead-of-time processing

Comments

@phejl
Copy link

phejl commented May 23, 2023

While trying to prepare the reproducible case for #30525 I noticed there is a problem with aspect in native image. I'll provide a repro.

@phejl
Copy link
Author

phejl commented May 23, 2023

@sdeleuze sdeleuze self-assigned this Jun 5, 2023
@sdeleuze
Copy link
Contributor

sdeleuze commented Jun 5, 2023

Looks like a duplicate of #28711.

@sdeleuze sdeleuze closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2023
@sdeleuze sdeleuze added status: duplicate A duplicate of another issue theme: aot An issue related to Ahead-of-time processing and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 5, 2023
@sdeleuze
Copy link
Contributor

After more testing, seems to be a distinct issue.

@sdeleuze sdeleuze reopened this Jun 15, 2023
@sdeleuze sdeleuze added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) and removed status: duplicate A duplicate of another issue labels Jun 15, 2023
@sdeleuze sdeleuze added this to the 6.0.11 milestone Jun 15, 2023
@sdeleuze
Copy link
Contributor

The repro for that issue is interesting because it is still broken after fixing #28711 in 6.0.11-SNAPSHOT. Based on my tests, it works on the JVM with AOT enabled, but fails on native even with the native configuration generated by the tracing agent which is surprising.

Comparing DEBUG/TRACE logs between JVM/native may allow to identify what causes the aspect to be ignored.

@sdeleuze
Copy link
Contributor

sdeleuze commented Jun 16, 2023

On native, fails with
@Pointcut("execution(* com.example.demo.data.DataRepository.*(..))")

Works with
@Pointcut("execution(* com.example.demo.data.DataRepositoryCustom.*(..))")
or
@Pointcut("execution(* com.example.demo.data.DataRepositoryImpl.*(..))").

With

public interface DataRepository extends MongoRepository<Data, ObjectId>, DataRepositoryCustom { ... }
public class DataRepositoryImpl implements DataRepositoryCustom { ... }

On the JVM, it works with all 3 pointcut expressions.

More reflection hints do not seem to fix this. Maybe there's a difference of behavior between the JVM and native?

@sbrannen
Copy link
Member

On native, fails with
@Pointcut("execution(* com.example.demo.data.DataRepository.*(..))")

Out of curiosity, what happens if you try this (note the extra +)?

@Pointcut("execution(* com.example.demo.data.DataRepository+.*(..))")

It probably does not make any difference, but I'm interested in knowing.

Maybe a difference of behavior between the JVM and native?

Could well be the case.

@sdeleuze
Copy link
Contributor

@sbrannen Same result

I managed to identify that the difference between JVM and native is the invocation of ClassUtils#getMostSpecificMethod in AspectJExpressionPointcut#getTargetShadowMatch which returns jdk.proxy2.$Proxy64.findByUidAndUpdateAccess(java.lang.String) on the JVM and com.example.demo.data.DataRepository.findByUid(java.lang.String) because a NoSuchMethodException is thrown. The impact is that on the JVM, a pointcut on execution(* com.example.demo.data.DataRepository.*(..)) with a Spring Data repository interface ends up to a ShadowMatch#alwaysMatches while on native ShadowMatch#neverMatches.

Looks like related to oracle/graal#6079, so I will close this issue and add a commend on GraalVM side.

@sdeleuze sdeleuze closed this as not planned Won't fix, can't repro, duplicate, stale Jun 19, 2023
@sdeleuze sdeleuze removed this from the 6.0.11 milestone Jun 19, 2023
@sdeleuze sdeleuze added for: external-project Needs a fix in external project and removed in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project Needs a fix in external project theme: aot An issue related to Ahead-of-time processing
Projects
None yet
Development

No branches or pull requests

4 participants