Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Formal support for Kotlin?

I would probably need to see a lot of demand before exploring an ajc like experience for Kotlin. It would be a very large amount of effort and binary weaving of the class files can get you a long way. If I had cycles to work on the compile time experience I'd probably prefer to put that into improving the annotation based model, but I know that isn't great for folks relying on inter type declarations and static checking at compile time.


On Tue, 14 May 2019 at 06:46, Matthew Adams <matthew@xxxxxxxxxxxxxxx> wrote:
No, Martin, I’m not experiencing these problems, and my mentioning Spring was tangential.

I’m basically asking that ajc support Kotlin source files.

On May 13, 2019, at 5:43 PM, Martin Gainty <mgainty@xxxxxxxxxxx> wrote:

from what i see its not a matter of spring like or dislike..its a matter of keeping JDK class file consist

aj => .java => .class

kt => .java => .class

but this same scenario goes fubar when you switch JDKs ..this is an example

aj => => 1_dot_eight.class

kt  => => 1_dot_none.class

because spring is native compiled to 1.8 class format ..all .aj and all .kt dsl files will compile to 1.8 class
access to class files in jar is no problem 
doing reflection e.g. Class.forName(One_dot_eight); also no problem

things fall apart quickly with aj, kt or .java files when you mix 1.8 class files with 1.9 class files

(1.9 lambda functions fubar on accessing 1.8 class files)

maven folk say full compile the whole lot to your runtime JDK will supposedly cure this scenario

is this what you're experiencing?

To convert a Kotlin source file to a Java source file you need to (when you in Android Studio):. Press Cmd-Shift-A on a Mac, or press Ctrl-Shift-A on a Windows machine.. Type the action you're looking for: Kotlin Bytecode and choose Show Kotlin Bytecode from menu. Press Decompile button on the top of Kotlin Bytecode panel.; Now you get a Decompiled Java file along with Kotlin file in a ...

What you want is not possible with @AspectJ style, you need to use the more powerful native syntax. (Why do you want to switch anyway?) The reason behind this is that the Java compiler can only convert @DeclareParents to a form in which Village is a subclass of whatever interface implementation you define in your aspect, for example something like this:

From: aspectj-users-bounces@xxxxxxxxxxx <aspectj-users-bounces@xxxxxxxxxxx> on behalf of Matthew Adams <matthew@xxxxxxxxxxxxxxx>
Sent: Monday, May 13, 2019 5:53 PM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] Formal support for Kotlin?
Hi all,

I’ve been doing some googling around to see what I can find with regard to using AspectJ with Kotlin.  Things don’t look particularly great at first glance:

There are of course many more hits, but it appears the current state of the art is to compile with kotlin, then apply AspectJ to the kotlin .class files.

Problem is, we have some libraries that we can only compile via ajc due to their design, so I’m wondering what thought has been given to adding kotlin language support to ajc.  I didn’t see any issues requesting Kotlin language support in ajc so far.  Kotlin looks promising, and it appears that Spring also is liking Kotlin enough to add support for it.  I’d love to have my Kotlin & AspectJ, too.

Any comments, folks?


aspectj-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

aspectj-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top