Loading ...
Sorry, an error occurred while loading the content.

Throwable and Exceptions returns useless stack traces

Expand Messages
  • w3bbo
    Using both RoboJDE and Eclipse (with rsload) whenever we catch an exception and call ex.printStackTrace() all that s output to the display (on the desktop) is
    Message 1 of 4 , Nov 24, 2010
    • 0 Attachment
      Using both RoboJDE and Eclipse (with rsload) whenever we catch an exception and call ex.printStackTrace() all that's output to the display (on the desktop) is the name of the exception type and nothing else.

      Here's my code:

      //////////////////////////////////////

      System.out.println("Exception: " + ex.getClass().getName() );
      System.out.println("Message: " + ex.getMessage() );
      System.out.println("Stack Trace:");
      ex.printStackTrace();

      //////////////////////////////////////

      And this is what gets printed to console:

      //////////////////////////////////////

      Exception: NullPointerException
      Message: NullPointerException
      Stack Trace:
      NullPointerException

      //////////////////////////////////////

      I've taken a look at the source code of Throwable.printStackTrace but the stuff that matters (this.mTrace) is refered to from native code, so I can't really see what I need to do in order to get a proper stack trace.
    • ridgesoft
      If you try this program: public class Ex { public static void main(String args[]) { try { throw new Exception( Test ); } catch (Exception ex) {
      Message 2 of 4 , Nov 24, 2010
      • 0 Attachment
        If you try this program:

        public class Ex {
        public static void main(String args[]) {
        try {
        throw new Exception("Test");
        }
        catch (Exception ex) {
        ex.printStackTrace();
        }
        }
        }

        do you get this output:

        RidgeSoft Loader 2.0.0
        (c) Copyright 2009 RidgeSoft, LLC. All rights reserved.
        Loading Ex..............
        Download complete
        Starting program
        Exception: Test
        at Ex.main(Ex.java:4)

        Program stopped

        Regards,

        RidgeSoft Support

        --- In intellibrain@yahoogroups.com, "w3bbo" <w3bbo@...> wrote:
        >
        > Using both RoboJDE and Eclipse (with rsload) whenever we catch an exception and call ex.printStackTrace() all that's output to the display (on the desktop) is the name of the exception type and nothing else.
        >
        > Here's my code:
        >
        > //////////////////////////////////////
        >
        > System.out.println("Exception: " + ex.getClass().getName() );
        > System.out.println("Message: " + ex.getMessage() );
        > System.out.println("Stack Trace:");
        > ex.printStackTrace();
        >
        > //////////////////////////////////////
        >
        > And this is what gets printed to console:
        >
        > //////////////////////////////////////
        >
        > Exception: NullPointerException
        > Message: NullPointerException
        > Stack Trace:
        > NullPointerException
        >
        > //////////////////////////////////////
        >
        > I've taken a look at the source code of Throwable.printStackTrace but the stuff that matters (this.mTrace) is refered to from native code, so I can't really see what I need to do in order to get a proper stack trace.
        >
      • w3bbo
        Weird. When I use your program, I get the expected result: /////////////////////////////////// RidgeSoft Loader 2.0.0 (c) Copyright 2009 RidgeSoft, LLC. All
        Message 3 of 4 , Nov 25, 2010
        • 0 Attachment
          Weird.

          When I use your program, I get the expected result:

          ///////////////////////////////////
          RidgeSoft Loader 2.0.0
          (c) Copyright 2009 RidgeSoft, LLC. All rights reserved.
          Loading test.Main..............
          Download complete
          Starting program
          Exception: Test
          at test.Main.main(Main.java:10)

          Program stopped
          ///////////////////////////////////

          But when I use this program:

          ///////////////////////////////////
          try {
          String x = null;
          System.out.println( x.toString() );
          } catch (Exception ex) {
          ex.printStackTrace();
          }
          ///////////////////////////////////

          I get this result:

          ///////////////////////////////////
          RidgeSoft Loader 2.0.0
          (c) Copyright 2009 RidgeSoft, LLC. All rights reserved.
          Loading test.Main..............
          Download complete
          Starting program
          NullPointerException

          Program stopped
          ///////////////////////////////////

          So it seems that runtime-raised exceptions don't get the stack trace, but user-raised exceptions do.

          --- In intellibrain@yahoogroups.com, "ridgesoft" <rs1@...> wrote:
          >
          > If you try this program:
          >
          > public class Ex {
          > public static void main(String args[]) {
          > try {
          > throw new Exception("Test");
          > }
          > catch (Exception ex) {
          > ex.printStackTrace();
          > }
          > }
          > }
          >
          > do you get this output:
          >
          > RidgeSoft Loader 2.0.0
          > (c) Copyright 2009 RidgeSoft, LLC. All rights reserved.
          > Loading Ex..............
          > Download complete
          > Starting program
          > Exception: Test
          > at Ex.main(Ex.java:4)
          >
          > Program stopped
          >
          > Regards,
          >
          > RidgeSoft Support
          >
          > --- In intellibrain@yahoogroups.com, "w3bbo" <w3bbo@> wrote:
          > >
          > > Using both RoboJDE and Eclipse (with rsload) whenever we catch an exception and call ex.printStackTrace() all that's output to the display (on the desktop) is the name of the exception type and nothing else.
          > >
          > > Here's my code:
          > >
          > > //////////////////////////////////////
          > >
          > > System.out.println("Exception: " + ex.getClass().getName() );
          > > System.out.println("Message: " + ex.getMessage() );
          > > System.out.println("Stack Trace:");
          > > ex.printStackTrace();
          > >
          > > //////////////////////////////////////
          > >
          > > And this is what gets printed to console:
          > >
          > > //////////////////////////////////////
          > >
          > > Exception: NullPointerException
          > > Message: NullPointerException
          > > Stack Trace:
          > > NullPointerException
          > >
          > > //////////////////////////////////////
          > >
          > > I've taken a look at the source code of Throwable.printStackTrace but the stuff that matters (this.mTrace) is refered to from native code, so I can't really see what I need to do in order to get a proper stack trace.
          > >
          >
        • ridgesoft
          There is a bug displaying the stack trace when the exception is in a classfile that does not include line numbers. Thank you for reporting the problem.
          Message 4 of 4 , Nov 25, 2010
          • 0 Attachment
            There is a bug displaying the stack trace when the exception is in a classfile that does not include line numbers.

            Thank you for reporting the problem.

            Regards,

            RidgeSoft Support

            --- In intellibrain@yahoogroups.com, "w3bbo" <w3bbo@...> wrote:
            >
            > Weird.
            >
            > When I use your program, I get the expected result:
            >
            > ///////////////////////////////////
            > RidgeSoft Loader 2.0.0
            > (c) Copyright 2009 RidgeSoft, LLC. All rights reserved.
            > Loading test.Main..............
            > Download complete
            > Starting program
            > Exception: Test
            > at test.Main.main(Main.java:10)
            >
            > Program stopped
            > ///////////////////////////////////
            >
            > But when I use this program:
            >
            > ///////////////////////////////////
            > try {
            > String x = null;
            > System.out.println( x.toString() );
            > } catch (Exception ex) {
            > ex.printStackTrace();
            > }
            > ///////////////////////////////////
            >
            > I get this result:
            >
            > ///////////////////////////////////
            > RidgeSoft Loader 2.0.0
            > (c) Copyright 2009 RidgeSoft, LLC. All rights reserved.
            > Loading test.Main..............
            > Download complete
            > Starting program
            > NullPointerException
            >
            > Program stopped
            > ///////////////////////////////////
            >
            > So it seems that runtime-raised exceptions don't get the stack trace, but user-raised exceptions do.
            >
            > --- In intellibrain@yahoogroups.com, "ridgesoft" <rs1@> wrote:
            > >
            > > If you try this program:
            > >
            > > public class Ex {
            > > public static void main(String args[]) {
            > > try {
            > > throw new Exception("Test");
            > > }
            > > catch (Exception ex) {
            > > ex.printStackTrace();
            > > }
            > > }
            > > }
            > >
            > > do you get this output:
            > >
            > > RidgeSoft Loader 2.0.0
            > > (c) Copyright 2009 RidgeSoft, LLC. All rights reserved.
            > > Loading Ex..............
            > > Download complete
            > > Starting program
            > > Exception: Test
            > > at Ex.main(Ex.java:4)
            > >
            > > Program stopped
            > >
            > > Regards,
            > >
            > > RidgeSoft Support
            > >
            > > --- In intellibrain@yahoogroups.com, "w3bbo" <w3bbo@> wrote:
            > > >
            > > > Using both RoboJDE and Eclipse (with rsload) whenever we catch an exception and call ex.printStackTrace() all that's output to the display (on the desktop) is the name of the exception type and nothing else.
            > > >
            > > > Here's my code:
            > > >
            > > > //////////////////////////////////////
            > > >
            > > > System.out.println("Exception: " + ex.getClass().getName() );
            > > > System.out.println("Message: " + ex.getMessage() );
            > > > System.out.println("Stack Trace:");
            > > > ex.printStackTrace();
            > > >
            > > > //////////////////////////////////////
            > > >
            > > > And this is what gets printed to console:
            > > >
            > > > //////////////////////////////////////
            > > >
            > > > Exception: NullPointerException
            > > > Message: NullPointerException
            > > > Stack Trace:
            > > > NullPointerException
            > > >
            > > > //////////////////////////////////////
            > > >
            > > > I've taken a look at the source code of Throwable.printStackTrace but the stuff that matters (this.mTrace) is refered to from native code, so I can't really see what I need to do in order to get a proper stack trace.
            > > >
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.