>>>>> Weiqi Gao writes:

    Weiqi> Jesper Nordenberg wrote:
    >> 
    >> Is there any way to obtain the Class-instance associated with the
    >> current class in a static method? Obviously, this.getClass() doesn't
    >> work ;)

    Weiqi> If you know the class' name, and I suspect that you do
    Weiqi> since you are in a static method of the class, you can do a
    Weiqi> Class.forName(className).

    Weiqi> Each derivative class have to override this method if the
    Weiqi> obtained Class is used in some substantial way.

Static methods can't be overriden, a static method _hides_ methods of
the same name in superclasses.  See section 8.4.6.1 and 8.4.6.2 in the
JLS.


        Juergen

-- 
Juergen Kreileder, Blackdown Java-Linux Porting Team
http://www.blackdown.org/java-linux.html


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

Reply via email to