Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » AspectJ Question
AspectJ Question [message #47994] Tue, 15 February 2005 08:22 Go to next message
Eclipse UserFriend
Originally posted by: kh_see.yahoo.com

hi,

Was evaluating AspectJ when i encounter this problem. Hopefully someone
can enlighten me.

AspectJ compiler ver 1.2.1
JDK compiler ver 1.5.0_01-b08
Linux kernel 2.6.10-1.760_FC3

------ JTest.java --------

public class JTest {

public void prtSomeThing(){
System.out.println("Hello World");
}
public static void main(String[] args){
JTest jt = new JTest();
jt.prtSomeThing(); }
}

------- JTestAspectJ.aj -------

public aspect JTestAspectJ {
pointcut logAllSystemPrint() : call(* System.out.println(..));
before() : logAllSystemPrint(){
System.out.println("Before Method");
}
}

--------------------------------

After compiling the two codes above, i got this warning message:

[tomcat@cm212 Test]$ ajc JTest.java JTestAspectJ.aj
/home/tomcat/aspectj/Test/JTestAspectJ.aj:17 [warning] no match for this
type name: System.out [Xlint:invalidAbsoluteTypeName]
pointcut logAllSystemPrint() : call(* System.out.println(..));
^^^^^^^^^^^^^^^^

[tomcat@cm212 Test]$ java JTest
Hello World

Why is there no match for 'System.out.println(..)' ?
I've tried these and they all don't work.
call(* System.out.*(..))
call(* System.out.println(String))
Re: AspectJ Question [message #48026 is a reply to message #47994] Tue, 15 February 2005 08:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adrian_colyer.uk.ibm.com

Freddy wrote:

> [tomcat@cm212 Test]$ ajc JTest.java JTestAspectJ.aj
> /home/tomcat/aspectj/Test/JTestAspectJ.aj:17 [warning] no match for this
> type name: System.out [Xlint:invalidAbsoluteTypeName]
> pointcut logAllSystemPrint() : call(* System.out.println(..));
> ^^^^^^^^^^^^^^^^

> [tomcat@cm212 Test]$ java JTest
> Hello World

> Why is there no match for 'System.out.println(..)' ?
> I've tried these and they all don't work.
> call(* System.out.*(..))
> call(* System.out.println(String))

Because System.out.println is such a common idiom in Java, we tend to
forget what it really means.

System.out is an access to a static field on the System class called "out"
println is then a method invocation on the out object.

So there is no type "System.out" (the call pcd needs a type pattern in
that position, and is interpreting "System.out" as "a type named out in
the System package").

call( * println(..)) would work, as would
call( * PrintStream.println(..))

a common aspectj idiom used to catch System.out/err printing is:

get(* System.out) || get(* System.err)

which actually matches the field access but gives you what you want 99% of
the time.
Re: AspectJ Question [message #48243 is a reply to message #48026] Wed, 16 February 2005 08:26 Go to previous message
Eclipse UserFriend
Originally posted by: kh_see.yahoo.com

Adrian Colyer wrote:

> Because System.out.println is such a common idiom in Java, we tend to
> forget what it really means.

> System.out is an access to a static field on the System class called "out"
> println is then a method invocation on the out object.

> So there is no type "System.out" (the call pcd needs a type pattern in
> that position, and is interpreting "System.out" as "a type named out in
> the System package").

> call( * println(..)) would work, as would
> call( * PrintStream.println(..))

> a common aspectj idiom used to catch System.out/err printing is:

> get(* System.out) || get(* System.err)

> which actually matches the field access but gives you what you want 99% of
> the time.

OK, now i understand, thanks for the info.
Re: AspectJ Question [message #586678 is a reply to message #47994] Tue, 15 February 2005 08:54 Go to previous message
Adrian Colyer is currently offline Adrian ColyerFriend
Messages: 61
Registered: July 2009
Member
Freddy wrote:

> [tomcat@cm212 Test]$ ajc JTest.java JTestAspectJ.aj
> /home/tomcat/aspectj/Test/JTestAspectJ.aj:17 [warning] no match for this
> type name: System.out [Xlint:invalidAbsoluteTypeName]
> pointcut logAllSystemPrint() : call(* System.out.println(..));
> ^^^^^^^^^^^^^^^^

> [tomcat@cm212 Test]$ java JTest
> Hello World

> Why is there no match for 'System.out.println(..)' ?
> I've tried these and they all don't work.
> call(* System.out.*(..))
> call(* System.out.println(String))

Because System.out.println is such a common idiom in Java, we tend to
forget what it really means.

System.out is an access to a static field on the System class called "out"
println is then a method invocation on the out object.

So there is no type "System.out" (the call pcd needs a type pattern in
that position, and is interpreting "System.out" as "a type named out in
the System package").

call( * println(..)) would work, as would
call( * PrintStream.println(..))

a common aspectj idiom used to catch System.out/err printing is:

get(* System.out) || get(* System.err)

which actually matches the field access but gives you what you want 99% of
the time.
Re: AspectJ Question [message #586773 is a reply to message #48026] Wed, 16 February 2005 08:26 Go to previous message
Freddy is currently offline FreddyFriend
Messages: 2
Registered: July 2009
Junior Member
Adrian Colyer wrote:

> Because System.out.println is such a common idiom in Java, we tend to
> forget what it really means.

> System.out is an access to a static field on the System class called "out"
> println is then a method invocation on the out object.

> So there is no type "System.out" (the call pcd needs a type pattern in
> that position, and is interpreting "System.out" as "a type named out in
> the System package").

> call( * println(..)) would work, as would
> call( * PrintStream.println(..))

> a common aspectj idiom used to catch System.out/err printing is:

> get(* System.out) || get(* System.err)

> which actually matches the field access but gives you what you want 99% of
> the time.

OK, now i understand, thanks for the info.
Previous Topic:Compiling to jar deletes all .class files?
Next Topic:Compiling to jar deletes all .class files?
Goto Forum:
  


Current Time: Thu Apr 25 07:24:58 GMT 2024

Powered by FUDForum. Page generated in 0.03360 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top