[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Using aspects on Swing classes?

Hello all... I am very new to aspect-oriented programming, so forgive my simple questions. I'm interesting in applying aspects to base Java classes... in this particular case I want to modify the painting behavior of Swing components. I've written a basic aspect like this:

aspect ComponentSupport
{
pointcut paint(Graphics g): execution(void paintComponent(Graphics)) && args(g);


	void around(Graphics g): paint(g)
	{
		
	}
}

In this case I am theoretically intercepting any calls to paintComponent() and doing nothing, so I should see nothing on my GUI. However, everything looks the same. This is the latest in a long series of test aspects I've written; I can't seem to alter any painting behavior. Am I doing something wrong with my pointcut?

The second question concerns how to build this stuff. I put the standard jar as the inpath:

<iajc
sourceRoots="build/src:src"
destdir="build/classes"
debug="on"
source="1.5"
target="1.5"
classpathref="project.classpath"
inPath="/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/ Classes/classes.jar"
aspectPath="${project_base}/ThirdPartyLibraries/trunk/lib/com.e- nspire.gemini-1.0.jar;${anaglyph}/trunk/build/lib/anaglyph.jar"
fork="yes"
maxmem="1024m"
>
</iajc>


I'm building on a Mac, which explains the unusual location of the standard classes. The aspect shown above is in the anaglyph.jar. When I run this the compiler regenerates every single class in the Java runtime into the output directory, even though only a small number of classes should be affected by my aspect. I end up with a huge jar file which essentially duplicates the runtime jar plus my application. I hope that when I run my modified classes are overriding the base library, although I'm not sure which ones will take precedence...

Thanks in advance!