Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Why no args() for get()?

We are talking about get() not set(), aren't we? Then "after ...
returning <YourResult>" or "around ... YourResult = proceed() ..."
should work.

Daniel

David Mohr schrieb:
I'll try the setAccessible, but if I can avoid reflection, then I'd like to.

target() gives me the wrong object though. A quick example:

class Foo {
  private String x;
  ...
  public void bar() {
     do something with x;
  }
}

if I had a pointcut on get(String Foo.x) && target(t), then I would
get get a t of type Foo, not of type String, which I would like to
get.

~David

On Tue, Sep 30, 2008 at 11:15 PM, Andrew Eisenberg <andrew@xxxxxxxxxxxx> wrote:
Instead of args(), try using target().  Also, if you want to use
reflection, you can do field.setAccessible(true) to access private
members.

On Tue, Sep 30, 2008 at 7:22 PM, David Mohr <dmohr@xxxxxxxxxx> wrote:
Hi everyone,
I want to write an aspect which monitors what the current value is on
field accesses. I thought that a get() pointcut with args() would be
exactly what I need, but then in the docs I see that get() does not
support args(). I tried to work around it by using reflection (get the
Field from the FieldSignature), but then I get access violations from
the jvm runtime since some of the fields I am trying to access are
private, and the currently executing code is the aspect. Declaring the
aspect privileged does not change anything, since this is a runtime
not a compile time problem.

Is there a way I can work around that?

Thanks!

~David
_______________________________________________
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

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top