Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » aspects across eclipse projects?
aspects across eclipse projects? [message #583765] Mon, 04 October 2004 16:31
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi again - and sorry for my high NG volume! I seem to keep bumping
into all kinds of problem today...

We are writing some code, that should NOT use static variables since
that may make later multi-threading or "componentization" of the code
more difficult than necessary.
Ah - "a case for AspectJ!" I thought at first but now I am running
into the problem, that AJDT seems to declare warnings only for files
within the same project. Is that so? Since when? I am pretty sure,
that I have written aspects that have worked accross project
boundaries under older AJDT versions (i.e. 1.1.10 and earlier).

I boiled that down to the following tiny example: a classes and an
aspect:

class Test: - has a static and a non-static field and fiddles a bit
with both...
---------------------------
package test;

public class Test
{
public static int a = 2;
public int b;

public Test() {
super();
methodA(a);
}

public void methodA(int x) {
System.out.println("methodA: " + x);
b = x;
a = x*2;
}
}
---------------------------

aspect FlagStatics: should flag accesses to the static field:
---------------------------
package test;

public aspect FlagStatics
{
pointcut allStaticVariableAccesses():
(
get(* test.*.*)
||
set(* test.*.*)
);

declare warning:
allStaticVariableAccesses()
: "Warning: use of static variable";
}
---------------------------

If the above two files reside within the same project things work and
the locations where the static field is set or used are properly
flagged.
If I separate these file into TWO projects, i.e. the file Test.java in
one project, the file FlagStatics.aj in another then no warnings are
emitted, no matter whether I make the first project import the second
or vice versa.

I tried the Java Build Path-s as well as the project references
settings, but couldn't get things to work. How do I apply an aspect
within a project to (an) other project(s)?

Michael
Previous Topic:type is not exposed to the weaver???
Next Topic:AJDT 1.1.12 released for Eclipse 3.0
Goto Forum:
  


Current Time: Wed Apr 24 16:34:33 GMT 2024

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

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

Back to the top