2 Replies Latest reply on Jul 25, 2008 11:38 PM by 843810

    An exception event is caught by the trace command, but not by java command

    843810
      I am having a strange exception in the output of the trace command. The exception is only happening if I instantiate a new object in test class (I have included the code below).

      This is the exception is the output of trace:

      ThreadName: ====== main ======
      methodEntryEvent: main -- simplestTest location:simplestTest:13
      | Exception event found: instance of java.lang.ClassNotFoundException(id=39) catch: java.lang.ClassLoader:303 exception details: class com.sun.tools.jdi.ObjectReferenceImpl
      | Exception event found: instance of java.lang.ClassNotFoundException(id=40) catch: java.lang.ClassLoader:303 exception details: class com.sun.tools.jdi.ObjectReferenceImpl
      | Exception event found: instance of java.lang.ClassNotFoundException(id=40) catch: java.lang.ClassLoader:303 exception details: class com.sun.tools.jdi.ObjectReferenceImpl
      | methodEntryEvent: <init> -- Tutti location:Tutti:22
      | | methodExitEvent: <init> -- Tutti
      | methodEntryEvent: <init> -- Tutti location:Tutti:22
      | | methodExitEvent: <init> -- Tutti
      | methodExitEvent: main -- simplestTest
      Death of ThreadName:====== main end ======
      -- The application exited --


      This is the very simple test class:
      public class simplestTest {
      
          public static void main(String[] args) {
              int x = 10;
              System.out.println("hello test");
              Tutti tuttike;
              tuttike = new Tutti();
              Tutti tuttike2;
              tuttike2 = new Tutti();
          }
      }
      
      class Tutti {    
      }
      If I do not have any instantiations, I do not have the exception in the trace output. Also, if I run the above test application normally (with the java command), I do not have these exceptions.

      Anybody have an idea?
        • 1. Re: An exception event is caught by the trace command, but not by java comm
          800575
          hese exceptions are thrown and caught in normal loading of classes. Not the best way for it to work but ...

          Debuggers compensate for this by typically ignoring exceptions that will be caught. Run your simplestTest under jdb and you will see it runs ok.
          Then do run jdb again and do:
              stop in simplestTest.main
              run
              <hit the bkpt>
              help    <to see all jdb commands>
              catch   <to see the default behavior for exceptions>
          You will find that it says
            Break when these exceptions occur:
               uncaught java.lang.Throwable
          meaning that when a caught exception occurs, jdb doesn't break but lets the debuggee keep on running.
          Now do
              catch all *   < tell jdb to break on all exceptions>
               cont
          and you will see that your exceptions occur.
          • 2. Re: An exception event is caught by the trace command, but not by java comm
            843810
            Indeed, in jdb I do not get these exceptions. I was also about to say that running the trace tool from the command line (not from within Netbeans as before) yielded a slightly more detailed result:
            -- VM Started --
            ThreadName: ====== main ======
            methodEntryEvent: main  --  simplestTest location:simplestTest:13
            | Exception event found: instance of java.lang.ClassNotFoundException(id=39) cat
            ch: java.lang.ClassLoader.loadClass(java.lang.String, boolean)+39 exception deta
            ils: class com.sun.tools.jdi.ObjectReferenceImpl
            | Exception event found: instance of java.lang.ClassNotFoundException(id=40) cat
            ch: java.lang.ClassLoader.loadClass(java.lang.String, boolean)+39 exception deta
            ils: class com.sun.tools.jdi.ObjectReferenceImpl
            | Exception event found: instance of java.lang.ClassNotFoundException(id=40) cat
            ch: java.lang.ClassLoader.loadClass(java.lang.String, boolean)+39 exception deta
            ils: class com.sun.tools.jdi.ObjectReferenceImpl
            | methodEntryEvent: <init>  --  Tutti location:Tutti:22
            | | methodExitEvent: <init>  --  Tutti
            | methodEntryEvent: <init>  --  Tutti location:Tutti:22
            | | methodExitEvent: <init>  --  Tutti
            | methodExitEvent: main  --  simplestTest
            Death of ThreadName:====== main end ======
            -- The application exited --
            But I now understand this is completely normal behavior. What a strange way to signal class loading... In my own, much more elaborate debugging application, I have now signaled through JDI not to report these exceptions anymore.

            A question, is there a reason for this behavior?