Community
Participate
Working Groups
I'm trying to encapsulate the SWT thread safety in an aspect using the new annotation style (but I've verified that rewriting the aspect using the "normal" syntax changes nothing). My aspect is: package it.uniba.di.cdg.xcore.ui; import it.uniba.di.cdg.xcore.util.RunnableWithReturn; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.eclipse.swt.widgets.Display; @Aspect public class SwtThreadSafety { @Pointcut( "call( @SwtSynchExec * *.*(..) )" ) protected void uiSynchMethods() {} @Pointcut( "call( @SwtAsynchExec * *.*(..) )" ) protected void uiAsynchMethods() {} @Around( "uiSynchMethods()" ) public Object wrapSynchMethods( final ProceedingJoinPoint thisJoinPoint ) { RunnableWithReturn r = new RunnableWithReturn() { public void run() { try { _returnValue = thisJoinPoint.proceed(); } catch (Throwable e) { throw new RuntimeException( e ); // Soft the exception ... } } }; Display.getCurrent().asyncExec( r ); return r.getReturnValue(); } @Around( "uiAsynchMethods()" ) public void wrapAsynchMethods( final ProceedingJoinPoint thisJoinPoint ) { Runnable r = new Runnable() { public void run() { try { thisJoinPoint.proceed(); } catch (Throwable e) { throw new RuntimeException( e ); // Soft the exception ... } } }; Display.getCurrent().asyncExec( r ); } } @SwtAsynchExec and @SwtSynchExec are plain markers which define no property. When I save the file the exception is thrown (see the uploaded stacktrace). This is the interface containing the enum type: package it.uniba.di.cdg.xcore.ui.views; public interface IMessageBoard { enum LookType { SYSTEM, LOCAL_USER, BUDDY }; void appendMessage( LookType look, String message ); } If I change LookType to be a classe, the npe goes away (it is generated every time I try to save the file and restarting the JDT changes nothing).
Created attachment 30150 [details] The stacktrace
Mario, what is your exact version of AspectJ / AJDT? Passing over to AspectJ.
Ops, right: I'm using the 1.3.0.20051117130227 aspectj feature (using update manager with http://download.eclipse.org/technology/ajdt/31/dev/update url), eclipse 3.1.1 under linux/gtk and jdk 1.5.0 update 5.
this is the same problem as bug 115204 - hopefully with the info across these two bugs I can resolve it.
fix for this is checked in - waiting on build.
the fix for this is available in the latest AspectJ dev build - it will be in AJDT early next week. the scenario is quite complicated (as incremental related ones always are) ... so if your scenario isnt fixed by what I've done, please reopen.