bridge methods explaination
        Posted  
        
            by xdevel2000
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by xdevel2000
        
        
        
        Published on 2010-06-17T09:01:07Z
        Indexed on 
            2010/06/17
            9:03 UTC
        
        
        Read the original article
        Hit count: 317
        
If I do an override of a clone method the compiler create a bridge method to guarantee a correct polymorphism:
class Point
{
    Point()
    {
    }
    protected Point clone()
        throws CloneNotSupportedException
    {
        return this; // not good only for example!!!
    }
    protected volatile Object clone()
        throws CloneNotSupportedException
    {
        return clone();
    }
}
so when is invoked the clone method the bridge method is invoked and inside it is invoked the correct clone method. But my question is when into the bridge method is called return clone() how do the VM to say that it must invoke Point clone() and not itself again???
© Stack Overflow or respective owner