Static inner class not seeing super class method

Discussion in 'Java' started by kishan bisht, Jul 2, 2003.

  1. kishan bisht

    kishan bisht Guest

    Hi,

    I have a situation like this

    public class Base {
    public void run(){}
    }
    public class Outer {
    public static class Inner extends Base {
    }
    }

    Now the problem is that at runtime my test wants to use inner class
    and its inherited run method but I get an exception saying that it
    can't find the run() method.

    The problem is solved if I change my inner class to this
    public class Outer {
    public static class Inner extends Base {
    public void run() {
    super.run();
    }
    }
    }
    Is there a way here or do I have to change my inner class to be
    non-static as I do not want to implement dummy run()in my inner
    classes.

    Thanks in advance.

    Kishan
     
    kishan bisht, Jul 2, 2003
    #1
    1. Advertising

  2. "kishan bisht" <> wrote in message
    news:...
    > Hi,
    >
    > I have a situation like this
    >
    > public class Base {
    > public void run(){}
    > }
    > public class Outer {
    > public static class Inner extends Base {
    > }
    > }
    >


    I typed in the above in two files named Base.java and Outer.java

    > Now the problem is that at runtime my test wants to use inner class
    > and its inherited run method but I get an exception saying that it
    > can't find the run() method.
    >


    Can you please post all of the code? Because Base.java and Outer.java
    compiled fine. It is not possible to figure out what you are doing at
    runtime.

    > The problem is solved if I change my inner class to this
    > public class Outer {
    > public static class Inner extends Base {
    > public void run() {
    > super.run();
    > }
    > }
    > }
    > Is there a way here or do I have to change my inner class to be
    > non-static as I do not want to implement dummy run()in my inner
    > classes.
    >


    Again, this works fine too.

    > Thanks in advance.
    >
    > Kishan



    --
    Shripathi Kamath
    NETAPHOR SOFTWARE INC.
    http://www.netaphor.com
     
    Shripathi Kamath, Jul 2, 2003
    #2
    1. Advertising

  3. kishan bisht

    xarax Guest

    (kishan bisht) wrote in message news:<>...
    > Hi,
    >
    > I have a situation like this
    >
    > public class Base {
    > public void run(){}
    > }
    > public class Outer {
    > public static class Inner extends Base {
    > }
    > }


    So far, so good.

    > Now the problem is that at runtime my test wants to use inner class
    > and its inherited run method but I get an exception saying that it
    > can't find the run() method.


    Huh? What message? How are you trying to invoke run()?

    > The problem is solved if I change my inner class to this
    > public class Outer {
    > public static class Inner extends Base {
    > public void run() {
    > super.run();
    > }
    > }
    > }
    > Is there a way here or do I have to change my inner class to be
    > non-static as I do not want to implement dummy run()in my inner
    > classes.


    Please post the actual code is that is getting the
    compile-time error message.

    I suspect it has something to do with resolving method
    names within nested namespaces. See the Java Language
    Specification (JLS) for the exact rules on how method
    names are resolved in this situation. You may need to
    add some qualification.
     
    xarax, Jul 2, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    super.super.super how?

    Guest, Feb 19, 2005, in forum: Java
    Replies:
    24
    Views:
    10,865
    Darryl Pierce
    Feb 24, 2005
  2. bugbear
    Replies:
    4
    Views:
    468
    bugbear
    Aug 23, 2006
  3. Robin
    Replies:
    0
    Views:
    439
    Robin
    Jun 6, 2007
  4. zweibieren

    A need for super.super.method()

    zweibieren, May 7, 2009, in forum: Java
    Replies:
    0
    Views:
    469
    zweibieren
    May 7, 2009
  5. fi3nd
    Replies:
    0
    Views:
    397
    fi3nd
    Apr 8, 2010
Loading...

Share This Page