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


This is very strange. The same code in Eclipse 3.1.1 with the latest AJDT 1.3 shows an error for MyXOption but not for MyBrokenOption.

I also tried under Eclipse 3.2M4 with the latest AJDT 1.4  and it showed the same result.

Can anyone reproduce this under Eclipse?


Andy Clement wrote:
Sorry if I've come to this late and am missing some context.... I typed in your program, added some missing types and added a type that broke the rule:

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";


interface IOption {}
interface IXOption extends IOption {}
interface IYOption extends IOption {}
interface IZOption extends IOption {}

class OptionType {}

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

class MyBrokenOption implements IXOption {

I then compiled it:

C:\aspectj1.5>ajc -XhasMember -showWeaveInfo OptionAspect.java
Extending interface set for type 'MyBrokenOption' ( OptionAspect.java) to include 'OptionAspect$IBadOptionSubtype' (OptionAspect.java)

C:\aspectj1.5\OptionAspect.java:24 [error] IOption implementations must provide a constructor which accepts an OptionType
class MyBrokenOption implements IXOption {
        staticinitialization(void MyBrokenOption.<clinit>())
        see also: C:\aspectj1.5\OptionAspect.java:8::0

1 error

-showWeaveInfo just shows me which is being marked as a bad option.  My correct class that implements the ctor is not flagged and my broken one that doesn't implement it is marked with the declare error.  Now I presume I must have made some incorrect assumption in my definition of the missing types since its working ok for me...


_______________________________________________ aspectj-users mailing list aspectj-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/aspectj-users