This is totally off topic, but somebody may have an idea... You can 
answer (or flame me ;) in private to avoid contaminating the list further.

Is there any way to invoke a method for a class two levels up the hierarchy?
To be more specific, consider the following scenario:
class A {
        void doit() {
                // ...
        }
}
        
abstract class B extends A {
        abstract void doit();
}
        
class C extends B {
        void doit() {
                // ...
        }
}

Now, say that an instance of C wants to invoke the method implementation 
in A. Apparently, there is no way to do it... 

Neither a reflective invokation or a direct invokation will work. 
That is, in an instance of C,
super.doit() is invalid (since doit is an abstract method in B), while
A.class.getDeclaredMethod( "doit", null ).invoke( this, null ) will 
invoke the method implementation in C, which overrides the method 
implementation in A, hence falling into an infinite loop.

Is there any way to work around this, apart from declaring B like this: 
abstract class B {
        void doit() { super.doit(); }
}
(this is not satisfactory, because you may want to force B subclasses to 
override doit(), and a declaration like this may allow C to compile without
doing so).

-- dimitris
   mailto:[EMAIL PROTECTED]


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to