Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] A possible compiler bug when using declare error


Hi Antti,

Building with AspectJ 1.2 on the command line I cannot reproduce the error that you are seeing. Here is my test code that contains a paste of your aspect inside my simple version of a TransferTableTestBase ...

public class TransferTableTestBase {

  public void doThisQuick(String cmd) {
    System.out.println("Doing " + cmd + " quickly");
  }

  public void doThisSlow(String cmd) {
    System.out.println("Doing " + cmd + " slowly");
  }


  public static void main(String[] args) {
    TransferTableTestBase tb = new TransferTableTestBase();
    tb.doThisQuick("tango");
    tb.doThisSlow("tango");

    AnotherTestBase atb = new AnotherTestBase(tb);
    atb.activate(true);
    atb.activate(false);    
  }


  /*********************************************
   * Antti's aspect copied from original email.
   *********************************************/  
  private static aspect HookMethodCallControlAspect {
    declare error : !within(TransferTableTestBase) &&
      call(* TransferTableTestBase.do*(..)) :
        "Hook methods are not to be called outside the parent class TransferTableTestBase";
  }
}


class AnotherTestBase {

  private TransferTableTestBase testBase;

  public AnotherTestBase(TransferTableTestBase testBase) {
    this.testBase = testBase;
  }
 
  public void activate(boolean quickly) {
    if (quickly) {
      this.testBase.doThisQuick("run");
    }
    else {
      this.testBase.doThisSlow("run");
    }
  }
}


When I try and compile the above using plain old ajc (with no options) I get the following output as expected ...

C:\development\scratch\antti\TransferTableTestBase.java:46 error Hook methods are not to be called outside the parent class TransferTableTestBase
this.testBase.doThisQuick("run");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        method-call(void TransferTableTestBase.doThisQuick(java.lang.String))
        see also: C:\development\scratch\antti\TransferTableTestBase.java:29
C:\development\scratch\antti\TransferTableTestBase.java:49 error Hook methods are not to be called outside the parent class TransferTableTestBase
this.testBase.doThisSlow("run");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        method-call(void TransferTableTestBase.doThisSlow(java.lang.String))
        see also: C:\development\scratch\antti\TransferTableTestBase.java:29

2 errors


What am I doing different to you ? What compiler options are you using and are there any other special features of your development environment that may be significant ?

If possible, could you distil your failing case into a small self-contained project that can demonstrate the problem ?

Best regards,
George
________________________________________
George C. Harley



"Antti Karanta" <antti.karanta@xxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

16/09/2004 09:35

Please respond to
aspectj-users

To
<aspectj-users@xxxxxxxxxxx>
cc
Subject
[aspectj-users] A possible compiler bug when using declare error







                      Hi!

 I just run into a weird compiler errors when using "declare error".

 Here is what I declared inside a class that acts as a base for
different test cases. The aspect is intended to watch that the hook
methods are not called by others, they are only intended to be
overridden as necessary:

 private static aspect HookMethodCallControlAspect {
   declare error : !within(TransferTableTestBase) &&
       call(* TransferTableTestBase.do*(..)) :
       "Hook methods are not to be called outside the parent class
TransferTableTestBase";
 }

 At least to me this seems like a perfectly sensible error declaration.
However, it causes very strange compiler errors that are totally
unrelated to the above declaration (TransferTableTestBase is the class
that contains the above aspect:

can't find type [Lfi.napa.tabletransfer.link.Column;
Key.java
can not resolve this member: java.lang.Object [I.clone()
[Xlint:unresolvableMember]                                  TransferTableTestBase.java
can not resolve this member: java.lang.Object
[Lfi.napa.tabletransfer.link.Column;.clone() [Xlint:unresolvableMember]
TransferTableTestBase.java
can not resolve this member: java.lang.Object
[Lfi.napa.tabletransfer.link.Column;.clone() [Xlint:unresolvableMember]
TransferTableTestBase.java
can't find type [I                 TableSimpleImpl.java

 These error messages do not make much sense, e.g. the last one claims
it can not find type of int[].

 All these errors disappear once I comment out the above declare error
statement.


 Any ideas? It seems like a compiler bug.


       -Antti-





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


Back to the top