0

I have this snippet of code:

@Aspect
@Component
open class Advice
{
    @AfterThrowing(pointcut = "execution(* project.service..*(..)) && !within(is(FinalType))", throwing = "throwable")
    open fun sendError(throwable: Exception)
    {
    println("exception thrown")
    }
}

It seems to be working okay, except that IJ does not tell me what methods are advised - this functionality works only when I rewrite this class to Java. q

(this little icon on line 12 is what is missing in Kotlin - it shows the list of methods advised by the advice. It's present when the code is written in Java)

Any ideas? Thanks in advance.

user3285241
  • 319
  • 2
  • 3
  • 18
  • 2
    Your observation is correct. Not all features of IntelliJ IDEA automatically work for all supported languages; this one is implemented only for Java. – yole Feb 11 '18 at 16:05
  • 1
    AspectJ support in general had a good start in older IntelliJ versions, but has been neglected for years. As much as I love IDEA, I usually switch to Eclipse + AJDT if I want to do anything aspect-related, even though AJDT has not improved much in the last few years either but it merely kept functioning. Still it is better than IDEA because AspectJ is an Eclipse project. – kriegaex Feb 12 '18 at 00:45
  • How did you get aspectj working with kotlin? I tried following the link - https://stackoverflow.com/a/49319700/6743176, but no luck. Can you help? – BATMAN Sep 27 '18 at 07:52
  • @KashishMalhotra could you please provide more information why is it not working? any stacktrace? code? – user3285241 Sep 27 '18 at 16:00
  • I used aspectj with kotlin in an android application. If I convert my @Aspect annotated class in Java, the code works fine. But if I use it in kotlin, the code simply doesn't get executed, no errors, nothing. – BATMAN Sep 27 '18 at 18:15
  • I can't seem to find @Component annotation. Maybe that's the reason. – BATMAN Sep 27 '18 at 18:18

1 Answers1

0

I've had the same issue.

Workaround:

  1. Create java file
  2. Put your aop here
  3. Debug/test/develop
  4. Move the code to Kotlin file then

It's a bit ugly but is working.

OlegB
  • 1
  • 3