Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Re: A switch oddity

aspect A {

   public final String Runnable.name = "Runnable";
}

Charles Zhang wrote:

Hey, Matthew, thanks for the reply. So, basically, a final Java field
cannot be declared in AspectJ, right? For my application, I can always get
around. But I can't think of philosophically why aspects should be
prohibited from doing so. Could this be a bug or an intended behaviour?
Thanks again.

Charles

On Tue, 10 Feb 2004, Matthew Webster wrote:





Charles,

Modifiers on inter-type declarations refer only to usage by the aspect and
do no determine the actual Java visibility. For example a private ITD field
is actually public WRT Java but given a mangled name so that it cannot be
used by other types. The same applies to final i.e. a final ITD field can
only be set in the scope of an initializer in the aspect that declares it.
These rules are policed by the AspectJ compiler. A final ITD field could
not be declared final WRT Java because otherwise its value could not be set
in the scope of the aspect (static final fields can only be set in a static
initializer and final fields in a constructor).

The implementation of final has some unfortunate side effects as you have
discovered.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

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


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




Back to the top