Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Antwort: [aspectj-dev] Declare parents extends quirk ? Comments?



Hello,

From my point of view, just the implementation of the compiler is false.

IMHO The correct implementation of the compiler would be to add the extends
relationship only to the class X and not to its subtype.
As soon as X is extended, everything is fine in the sample.

Not allowing the + might be a little to strict. Imagine a scenario, where
you want to glue a intermediate classlevel in the class tree.
As it is shown in following code fragment.

class X { }

class Y extends X{}

class SubX extends X { }

aspect A {
 declare parents: X+&&(!Y)&&(!X) extends Y;
}

So my recommendation would be to fix the compiler and do not restrict the
language.

Just my 0.00002 cents. ;-)
kind regards
   Arno



Arno Schmidmeier (sic)
AspectSoft
www.aspectsoft.de
mailto:Arno@xxxxxxxxxxxxx

c/o DaimlerChrysler Bank
Fon/Fax: +49 (711) 2574 - 6144


                                                                                                                             
                      CLEMAS@xxxxxxxxxx                                                                                      
                      Gesendet von:              An:      aspectj-dev@xxxxxxxxxxx                                            
                      aspectj-dev-admin@         Kopie:                                                                      
                      eclipse.org                Thema:   [aspectj-dev] Declare parents extends quirk ? Comments?            
                                                                                                                             
                                                                                                                             
                      24.08.2004 17:17                                                                                       
                      Bitte antworten an                                                                                     
                      aspectj-dev                                                                                            
                                                                                                                             
                                                                                                                             





Here is a simple set of types I have in a source file:

=========================
class X { }

class SubX extends X { }

aspect A {
 declare parents: X+ extends java.util.Observable;
}
=========================

(Note the inclusion of the + on the type pattern).

if I compile it, it succeeds and X now extends Observable (SubX does not
because X does)

Now, if I switch it to this (order of types switched):

=========================
class SubX extends X { }

class X { }

aspect A {
 declare parents: X+ extends java.util.Observable;
}
=========================

And compile it, I get:

============
C:\ajbugs\p\A.java:6 error can only insert a class into hierarchy, but
java.util.Observable is not a  subtype of X
declare parents: X+ extends java.util.Observable;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 error
============

It is because this time the compiler encountered 'SubX' first, which
matched 'X+' - it then barfed because we could not insert Observable into
the hierarchy, as Observable does not extend X.

This made me think that specifying a '+' on the type pattern in the case of
'extends <class>' should be regarded as an error ?  Is there any case when
it would actually make sense?

Andy.




Back to the top