-----Ursprüngliche Nachricht-----
Von: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] Im Auftrag von Bo Yi
Gesendet: Freitag, 21. Oktober
2005 15:19
An: aspectj-users@xxxxxxxxxxx
Cc:
aspectj-users-bounces@xxxxxxxxxxx; aspectj-users@xxxxxxxxxxx; 'Thiago
Bartolomei'
Betreff: Re: Possible Bug: [aspectj-users]
Overriding pointcuts
Hi,
I
believe this is a problem with target() and this().
target()
needs compile time type checking to make sure all types are consistent. Thus it
will fail when checks
pointcut log(Fifo fifo) : Logging.log(fifo) || execution(* Fifo.Get(..))
&& target(fifo);
On
the other hand, it is dynamically bound to the target object instance. Thus,
pointcut log(Fifo fifo) : Logging.log(fifo) || execution(* Fifo.Get(..)); will
fail for no target binding to the second part.
I think this is a bug but not sure whether it is fixable (without modify the
language spec).
A work around is to use target() in advices rather than in pointcuts.
Bo
----------------------------------------------------------
Dr. Bo Yi
WebSphere Development & Testing
IBM Toronto Lab
A2-713/Q2Z/8200/MKM
8200 Warden Ave. Markham ONT. L6G 1C7
Phone: 905-413-4819
Tie Line: 969-4819
E-Mail: boyi@xxxxxxxxxx
"Sven Apel"
<apel@xxxxxxxxxxxxxxxxxxxxxxx>
Sent
by: aspectj-users-bounces@xxxxxxxxxxx
10/21/2005 08:17 AM
Please
respond to
aspectj-users
|
|
To
|
"'Thiago Bartolomei'"
<thiagobart@xxxxxxxxx>
|
cc
|
aspectj-users@xxxxxxxxxxx
|
Subject
|
Possible Bug: [aspectj-users] Overriding
pointcuts
|
|
Hi,
Now that I have installed aspectj1.5 your proposal compiles
(I had aspectj1.2 installed before), however, but throws the same exception. I
think this could be a bug. Has anybody an idea?
Unfortunately, simply combining both pointcuts in one aspect
is not what I want.
Regards,
Sven
-----Ursprüngliche
Nachricht-----
Von: Thiago Bartolomei [mailto:thiagobart@xxxxxxxxx]
Gesendet: Freitag, 21. Oktober 2005 13:56
An: Sven Apel
Betreff: Re: [aspectj-users] Overriding pointcuts
Hi,
strange. Which version of ajc are you using? Because I don't get any errors on
compilation. I am using version 1.5 (from the last ajdt version).
Altough I don't get any compilation error, when I run the example, I get the
following exception:
Exception in thread "main" java.lang.VerifyError: (class: Fifo,
method: Get signature: ()LValue;) Unable to pop operand off an empty stack
I know it does not answer your question, but you could use this pointcut to
solve your particular problem:
( execution(* Fifo.Put(..)) || execution(* Fifo.Get(..)) ) &&
target(fifo);
I am not sure, but it looks like a bug to me (in the compiler or weaver).
Regards,
Thiago
On 10/21/05, Sven Apel <apel@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Hi Thiago,
Unfortunately this does not work. Using
"target(fifo)" I get the following error message:
ajc *.java
/home/apel/iti_home/Entwicklung/Eigene
Projekte/AOP/Semaphor/Fifo.java:25 [error] Cannot use target() to match at this
location and bind a formal to type 'Fifo' - the formal is already bound to type
'Fifo'. The secondary source location points to the problematic target().
public void Put(Value val)
^^^^^^^^^^^^^^^^^^^^^^^^^
see also:
/home/apel/iti_home/Entwicklung/Eigene Projekte/AOP/Semaphor/ExtLogging.java:3
/home/apel/iti_home/Entwicklung/Eigene Projekte/AOP/Semaphor/Fifo.java:30
[error] Cannot use target() to match at this location and bind a formal to type
'Fifo' - the formal is already bound to type 'Fifo'. The secondary source
location points to the problematic target().
public Value Get() throws NoSuchElementException
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
see also:
/home/apel/iti_home/Entwicklung/Eigene Projekte/AOP/Semaphor/ExtLogging.java:3
2 errors
For clarification, I send you the Fifo class:
public class Fifo
{
public void
Put(Value val)
{
m_buf.add(val);
}
public Value Get()
throws NoSuchElementException
{
Value result;
try
{
result =
(Value)m_buf.firstElement();
}
catch(NoSuchElementException exception)
{
throw
exception;
}
m_buf.remove(result);
return result;
}
public static void
main(String[] args)
{
Fifo fifo = new Fifo(256);
fifo.Put(new Value(23));
fifo.Put(new Value(32));
System.out.println(fifo.Get().GetInt());
}
}
regards
Sven
-----Ursprüngliche
Nachricht-----
Von: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] Im Auftrag von Thiago Bartolomei
Gesendet: Freitag, 21. Oktober 2005 12:55
An: aspectj-users@xxxxxxxxxxx
Betreff: Re: [aspectj-users] Overriding pointcuts
Hi,
try to append target to your pointcut:
pointcut log(Fifo fifo) : Logging.log(fifo) || execution(* Fifo.Get(..))
&& target(fifo);
I think the problem is that the compiler needs to know what to do with your
fifo variable in all cases . Without the target, the second part of the
"or" would have no context exposure..
[]s
Thiago T. Bartolomei
On
10/21/05, Sven Apel <apel@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Hi,
I have a problem with overriding and reusing pointcuts. I want to extend the
set of join points captured by the "log" pointcut in the aspect
"Logging":
abstract public aspect Logging
{
pointcut log(Fifo fifo) : execution(* Fifo.Put(..))
&& target(fifo);
before(Fifo fifo) : log(fifo)
{
System.out.println("---> Fifo method called");
}
}
For that I want to use a further aspect that inherits from "Logging":
public aspect ExtLogging extends Logging
{
pointcut log(Fifo fifo) : Logging.log(fifo) ||
execution(*
Fifo.Get(..));
}
The above example does not work because ajc cannot bind "fifo"
(inconsistent
binding).
The following example also does not work:
public aspect ExtLogging extends Logging
{
pointcut log() : Logging.log(Fifo) || execution(*
Fifo.Get(..));
}
This is because "ExtLogging.log" must have the same signature than
"Logging.log". Other variants that declare an argument list in
"ExtLogging.log" but do not pass "fifo" to
"Logging.log" also do not work
Is there a possibility to override and reuse parent pointcuts that expect
arguments? Without arguments the above example works!
Thanks in advance
Sven
--
Dipl.-Inf. Sven Apel
Institute for Technical and Business Information Systems
Otto-von-Guericke-University
P.O. Box 4120, D-39016 Magdeburg, Germany
Phone: ++49 (391) 67-11899, Fax: ++49 (391) 67-12020
Room: 29/108
E-Mail: apel@xxxxxxxxxxxxxxxxxxxxxxx
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users