How to use aspects in Idea?

Any hint?

I have the simplest project on the world, containing one class with main()
method.
I want to write an aspect which will advise main method and print "foo"
before.
How can I do this? How can I add aspects to existing code?
Or...
- what can we do with aspects with 833?


--
---
Michal Szklanowski
Java Architect
---


13 comments
Comment actions Permalink

Michal Szklanowski wrote:

Any hint?


Just create aspects in "aj" suffixed files, next to your java source,
then build and run the project.
Watch the compiler message dialogs, while building, and you'll notice
aspect related ones.

Alain




0
Comment actions Permalink

On Sun, 22 Jun 2003 22:21:32 -0100, Alain Ravet wrote:

Just create aspects in "aj" suffixed files, next to your java source, then
build and run the project.
Watch the compiler message dialogs, while building, and you'll notice
aspect related ones.


And just how does one create .aj files? Theres no "new aspect" option to
create a file, and I can't find any "add to file" option either.

Mark

--
...turn to the light - don't be frightened by the shadows it creates,
...turn to the light - turning away could be a terrible mistake
...dream theater - the great debate


0
Comment actions Permalink

Mark Derricutt wrote:

And just how does one create .aj files?


-> "New File"

Alain

0
Comment actions Permalink

Great, but when I created aspect file, I am not able to open it in Idea - it
displays internal error and doesn't open aspect file.
Btw. where is Aspects toolwindow I saw somewhere in earlier builds of Idea?
Even if I turned on
disabled toolwindows in preferences, there isn't any Aspects window....


Uzytkownik "Alain Ravet" <alain.ravet.list@wanadoo.be> napisal w wiadomosci
news:bd5dlo$4p2$1@is.intellij.net...

Michal Szklanowski wrote:

Any hint?

>

Just create aspects in "aj" suffixed files, next to your java source,
then build and run the project.
Watch the compiler message dialogs, while building, and you'll notice
aspect related ones.

>

Alain

>
>
>
>


0
Comment actions Permalink

On Sun, 22 Jun 2003 22:21:32 -0100, Alain Ravet wrote:

Just create aspects in "aj" suffixed files, next to your java source, then
build and run the project.
Watch the compiler message dialogs, while building, and you'll notice
aspect related ones.


Just did "create file" and added an aspect and it all compiles fine, but
doesn't run :(

public class Main {

public static void main( String[] args ) {

Main main = new Main();
main.test();
}



public void test() {
System.out.println("Test");
}

}

public aspect TestAspect {

pointcut construct(): within(Main) && execution( void test());

after(): construct() {
System.out.println("Aspectz!!!");
}

}


If I'm right, I'd expect to see "Aspectsz!!!!" get printed -after- "Test",
but all I see is "Test". mmm



--
...turn to the light - don't be frightened by the shadows it creates,
...turn to the light - turning away could be a terrible mistake
...dream theater - the great debate


0
Comment actions Permalink

Yep, the first aspect-related bug-report.
We'll fixe that, thanks for reporting!

--

Best regards,
Eugene Zhuravlev
JetBrains, Inc, http://www.intellij.com
"Develop with pleasure!"

"Mark Derricutt" <pinhead@satinism.org> wrote in message news:pan.2003.06.23.06.59.37.517847@satinism.org...

On Sun, 22 Jun 2003 22:21:32 -0100, Alain Ravet wrote:

>

Just create aspects in "aj" suffixed files, next to your java source, then
build and run the project.
Watch the compiler message dialogs, while building, and you'll notice
aspect related ones.

>

Just did "create file" and added an aspect and it all compiles fine, but
doesn't run :(

>

public class Main {

>

public static void main( String[] args ) {

>

Main main = new Main();
main.test();
}

>
>
>

public void test() {
System.out.println("Test");
}

>

}

>

public aspect TestAspect {

>

pointcut construct(): within(Main) && execution( void test());

>

after(): construct() {
System.out.println("Aspectz!!!");
}

>

}

>
>

If I'm right, I'd expect to see "Aspectsz!!!!" get printed -after- "Test",
but all I see is "Test". mmm

>
>
>

--
...turn to the light - don't be frightened by the shadows it creates,
...turn to the light - turning away could be a terrible mistake
...dream theater - the great debate

>


0
Comment actions Permalink

Btw. where is Aspects toolwindow I saw somewhere in earlier builds of Idea?


Thanks, Michal,
The view is enabled in the next build.

--

Best regards,
Eugene Zhuravlev
JetBrains, Inc, http://www.intellij.com
"Develop with pleasure!"



0
Comment actions Permalink

On Mon, 23 Jun 2003 12:21:48 +0400, Eugene Zhuravlev wrote:

Yep, the first aspect-related bug-report. We'll fixe that, thanks for
reporting!


I'm not sure if it is a bug, or just my misunderstanding, however, using
cflow(this(Main)) works, although I have no idea what that syntax actually
means :)

I just went to aspectj.org and started looking at some tutorials.

I've also added some task tracker issues for the asject stuff as well.

One question to the Jetbrainers - whats in the aspect_rt.jar - is that
"intellij's" aspectj runtime??? is there a runtime???

--
...turn to the light - don't be frightened by the shadows it creates,
...turn to the light - turning away could be a terrible mistake
...dream theater - the great debate


0
Comment actions Permalink

>One question to the Jetbrainers - whats in the aspect_rt.jar - is that
>"intellij's" aspectj runtime??? is there a runtime???

These are runtime classes that support aspect reflection: 'thisJoinPoint' etc. This jar should be in a classpath of your application
if it uses aspects.

--

Best regards,
Eugene Zhuravlev
JetBrains, Inc, http://www.intellij.com
"Develop with pleasure!"




0
Comment actions Permalink

On Mon, 23 Jun 2003 17:01:45 +0400, Eugene Zhuravlev wrote:

These are runtime classes that support aspect reflection: 'thisJoinPoint'
etc. This jar should be in a classpath of your application if it uses
aspects.


Mmmm, is this an IntelliJ/AspectJ thing or a standard AspectJ thing?

--
...turn to the light - don't be frightened by the shadows it creates,
...turn to the light - turning away could be a terrible mistake
...dream theater - the great debate


0
Comment actions Permalink

The interfaces are standard for AspectJ

--

Best regards,
Eugene Zhuravlev
JetBrains, Inc, http://www.intellij.com
"Develop with pleasure!"


"Mark Derricutt" <pinhead@satinism.org> wrote in message news:pan.2003.06.24.09.33.13.933520@satinism.org...

On Mon, 23 Jun 2003 17:01:45 +0400, Eugene Zhuravlev wrote:

>

These are runtime classes that support aspect reflection: 'thisJoinPoint'
etc. This jar should be in a classpath of your application if it uses
aspects.

>

Mmmm, is this an IntelliJ/AspectJ thing or a standard AspectJ thing?

>

--
...turn to the light - don't be frightened by the shadows it creates,
...turn to the light - turning away could be a terrible mistake
...dream theater - the great debate

>


0
Comment actions Permalink

f i use build->rebuild project
then run my application without select"make project before running/debuging"
i can get the right answer

if i just run my application with selected "make project before running/debuging"
it will give me a exception that i get wrong

under the former circumstances,it generated a class file named "$$Trace_ASPECT_INSTANCE$$.class".
under the latter circumstances,it will not generate the class file as the former,or it deleted the file

so i guess
there must be something wrong

0
Comment actions Permalink

Please submit a bug for this

--

Best regards,
Eugene Zhuravlev
JetBrains, Inc, http://www.intellij.com
"Develop with pleasure!"


"aiya" <no_mail@jetbrains.com> wrote in message news:18952870.1056510194439.JavaMail.itn@is.intellij.net...

f i use build->rebuild project
then run my application without select"make project before running/debuging"
i can get the right answer

>

if i just run my application with selected "make project before running/debuging"
it will give me a exception that i get wrong

>

under the former circumstances,it generated a class file named "$$Trace_ASPECT_INSTANCE$$.class".
under the latter circumstances,it will not generate the class file as the former,or it deleted the file

>

so i guess
there must be something wrong



0

Please sign in to leave a comment.