Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How to declare an error when implementations of an interface doesn't supply a certain constructor

Hi

I'm still having trouble with using hasmember() with AJDT 1.3 and Eclipse 3.1.1 (hasmember is enabled in the AspectJ compiler page).
I want to declare an error when mplementations of a certain interface doesn't supply a specific constructor.

Does anyone have a suggestion to what's wrong?

Here's the aspect:
public aspect OptionAspect {
   
   interface IBadOptionSubtype {};

    declare parents : (IOption+ && !IOption && !IXOption && !IYOption && !IZOption) && !hasmethod(new(OptionType))
                             implements IBadOptionSubtype;

    declare error : staticinitialization(IOption+ && IBadOptionSubtype+)
        : "IOption implementations must provide a constructor which accepts an OptionType";
   
}

And a sample class, which incorrectly gets marked with an error, even though it supplies the correct constructor:

public class MyXOption implements IXOption {
    public MyXOption(OptionType type) {
    }
}


Best regards

Jeppe

Back to the top