Bug???: Calling abstract method in superclass constructor throws exception

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug???: Calling abstract method in superclass constructor throws exception

Leo User
Hi,

I found this behavior today and was quite mystified
over it:
1. A abstract class calls an abstract method in its
constructor.
2. a jython subclass subclasses said abstract class.
It overrides the abstract method.
3. Instantiating causes an exception to be thrown.
Though the method is overriden, it is not recognized
as having been overriden.

Code Example:
//@+leo-ver=4-thin
//@+node:zorcanda!.20051007114938:@thin
TestAbstract.java
//@@language java


public abstract class TestAbstract{

    public TestAbstract(){
   
        super();
        boom(); //due to the fact that this is
abstract, this causes the Jython object to crash,
though it has been overriden
   
    }

    public abstract void boom();


}
/*
import TestAbstract

class X( TestAbstract ):
    def __init__( self ):
        TestAbstract.__init__( self )
       
    def boom( self ): print "BOOM!"


a = X()# exception thrown, was expecting: BOOM!

*/


//@-node:zorcanda!.20051007114938:@thin
TestAbstract.java
//@-leo

-------------------
I looked at the bug reports and saw 2 that had
something but not exactly like this.  I plan to open a
bug report in a couple of days unless someone tells me
its not a bug. :)

I guess this raises the question: When does a jython
override take effect?  Does the superclass constructor
have to return before it exists?  If so, is this the
reason my non-abstract method is considered abstract
by Jython at the point it is called in the superclass
constructor?  This seems unnatural to me if its the
case.  A user of an abstract class, especially if they
aren't the source owner, may always have to subclass
the abstract class in java before they can say with
certainty that it will work.  Does the mysterious
constructor call an abstract method? Who can say...

leouser



               
__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Jython-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Bug???: Calling abstract method in superclass constructor throws exception

Leo User
hmm...

this is looking more and more like a bug.  I added a
method called:
public void goom(){ System.out.println( "GOOM" ); }

to the class.  I then call goom() before boom().
goom() executes ok, but then we have an exception with
boom().

then if I override goom in the jython subclass, goom()
calls the jython override.  When it gets to boom, I
expect an exception but I get a "BOOM" instead.

so in a nutshell: if I call an overriden method before
calling the overriden abstract method it *works*.
This is an odd one. :D

But it does help answer my question: overriden methods
appear to take effect immediately, you don't have to
wait.  The abstract method is the weirdo.

leouser



               
__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Jython-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Bug???: Calling abstract method in superclass constructor throws exception

fwierzbicki@gmail.com
Are you using the latest from cvs or the alpha release?  Some work has been done to fix method over-riding, but I don't think this particular scenario has been tested.

-Frank

On 10/7/05, Leo User <[hidden email]> wrote:
hmm...

this is looking more and more like a bug.  I added a
method called:
public void goom(){ System.out.println( "GOOM" ); }

to the class.  I then call goom() before boom().
goom() executes ok, but then we have an exception with
boom().

then if I override goom in the jython subclass, goom()
calls the jython override.  When it gets to boom, I
expect an exception but I get a "BOOM" instead.

so in a nutshell: if I call an overriden method before
calling the overriden abstract method it *works*.
This is an odd one. :D

But it does help answer my question: overriden methods
appear to take effect immediately, you don't have to
wait.  The abstract method is the weirdo.

leouser




__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Jython-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-dev

Reply | Threaded
Open this post in threaded view
|

Re: Bug???: Calling abstract method in superclass constructor throws exception

Leo User
Im using the latest alpha release.  It seems like
there is some missing initialization step if an
abstract override is called before any other overriden
method.  If I remember correctly it is Ok to call an
abstract after the __init__ has ran.  Ill have to look
at that sometime today.

leouser

--- Frank Wierzbicki <[hidden email]> wrote:

> Are you using the latest from cvs or the alpha
> release? Some work has been
> done to fix method over-riding, but I don't think
> this particular scenario
> has been tested.
>
> -Frank
>
> On 10/7/05, Leo User <[hidden email]> wrote:
> >
> > hmm...
> >
> > this is looking more and more like a bug. I added
> a
> > method called:
> > public void goom(){ System.out.println( "GOOM" );
> }
> >
> > to the class. I then call goom() before boom().
> > goom() executes ok, but then we have an exception
> with
> > boom().
> >
> > then if I override goom in the jython subclass,
> goom()
> > calls the jython override. When it gets to boom, I
> > expect an exception but I get a "BOOM" instead.
> >
> > so in a nutshell: if I call an overriden method
> before
> > calling the overriden abstract method it *works*.
> > This is an odd one. :D
> >
> > But it does help answer my question: overriden
> methods
> > appear to take effect immediately, you don't have
> to
> > wait. The abstract method is the weirdo.
> >
> > leouser
> >
> >
> >
> >
> > __________________________________
> > Yahoo! Music Unlimited
> > Access over 1 million songs. Try it free.
> > http://music.yahoo.com/unlimited/
> >
> >
> >
>
-------------------------------------------------------

> > This SF.Net email is sponsored by:
> > Power Architecture Resource Center: Free content,
> downloads, discussions,
> > and more.
> http://solutions.newsforge.com/ibmarch.tmpl
> > _______________________________________________
> > Jython-dev mailing list
> > [hidden email]
> >
>
https://lists.sourceforge.net/lists/listinfo/jython-dev
> >
>



       
               
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Jython-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Bug???: Calling abstract method in superclass constructor throws exception

fwierzbicki@gmail.com
We have fixed similar bugs in the head and this is probably fixed as well, wait until the next cut (or try the cvs version) to see if the bug still exists before filing a bug report.

Thanks,
Frank

On 10/8/05, Leo User <[hidden email]> wrote:
Im using the latest alpha release.  It seems like
there is some missing initialization step if an
abstract override is called before any other overriden
method.  If I remember correctly it is Ok to call an
abstract after the __init__ has ran.  Ill have to look
at that sometime today.

leouser

--- Frank Wierzbicki <[hidden email]> wrote:

> Are you using the latest from cvs or the alpha
> release? Some work has been
> done to fix method over-riding, but I don't think
> this particular scenario
> has been tested.
>
> -Frank
>
> On 10/7/05, Leo User <[hidden email]> wrote:
> >
> > hmm...
> >
> > this is looking more and more like a bug. I added
> a
> > method called:
> > public void goom(){ System.out.println( "GOOM" );
> }
> >
> > to the class. I then call goom() before boom().
> > goom() executes ok, but then we have an exception
> with
> > boom().
> >
> > then if I override goom in the jython subclass,
> goom()
> > calls the jython override. When it gets to boom, I
> > expect an exception but I get a "BOOM" instead.
> >
> > so in a nutshell: if I call an overriden method
> before
> > calling the overriden abstract method it *works*.
> > This is an odd one. :D
> >
> > But it does help answer my question: overriden
> methods
> > appear to take effect immediately, you don't have
> to
> > wait. The abstract method is the weirdo.
> >
> > leouser
> >
> >
> >
> >
> > __________________________________
> > Yahoo! Music Unlimited
> > Access over 1 million songs. Try it free.
> > http://music.yahoo.com/unlimited/
> >
> >
> >
>
-------------------------------------------------------

> > This SF.Net email is sponsored by:
> > Power Architecture Resource Center: Free content,
> downloads, discussions,
> > and more.
> http://solutions.newsforge.com/ibmarch.tmpl
> > _______________________________________________
> > Jython-dev mailing list
> > [hidden email]
> >
>
https://lists.sourceforge.net/lists/listinfo/jython-dev
> >
>





__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Jython-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-dev