Bug 116890 - enums make the ajdt compiler to throw a npe
Summary: enums make the ajdt compiler to throw a npe
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P2 blocker (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-17 10:59 EST by Mario Scalas CLA
Modified: 2005-11-18 07:09 EST (History)
0 users

See Also:


Attachments
The stacktrace (9.55 KB, text/plain)
2005-11-17 10:59 EST, Mario Scalas CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mario Scalas CLA 2005-11-17 10:59:03 EST
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).
Comment 1 Mario Scalas CLA 2005-11-17 10:59:48 EST
Created attachment 30150 [details]
The stacktrace
Comment 2 Matt Chapman CLA 2005-11-17 11:26:03 EST
Mario, what is your exact version of AspectJ / AJDT?

Passing over to AspectJ.
Comment 3 Mario Scalas CLA 2005-11-17 12:25:32 EST
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. 
Comment 4 Andrew Clement CLA 2005-11-18 04:16:38 EST
this is the same problem as bug 115204 - hopefully with the info across these
two bugs I can resolve it.
Comment 5 Andrew Clement CLA 2005-11-18 05:38:42 EST
fix for this is checked in - waiting on build.
Comment 6 Andrew Clement CLA 2005-11-18 07:09:51 EST
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.