3 Replies Latest reply: May 9, 2008 2:38 PM by 800575 RSS

    ModificationWatchpointEvent Problem

    843810
      My problem is that when I modified the following code, watch filed event doesnot work. I really do not know why. The modification should not affect the code. Here is what I have done:
      The Original which works perfect is :

      MethodEntryEvent works
      MethodExitEvent works
      ModificationWatchpointEvent works
       /**
           * Run the event handling thread.  
           * As long as we are connected, get event sets off 
           * the queue and dispatch the events within them.
           */
          public void run() { 
              EventQueue queue = vm.eventQueue();
              while (connected) {
                  try {
                      EventSet eventSet = queue.remove();
                      EventIterator it = eventSet.eventIterator();
                      while (it.hasNext()) {
                          handleEvent(it.nextEvent());
                      }
                      eventSet.resume();
                  } catch (InterruptedException exc) {
                      // Ignore
                  } catch (VMDisconnectedException discExc) {
                      handleDisconnectedException();
                      break;
                  }
              }
          }
      I have changed it to :

      MethodEntryEvent works
      MethodExitEvent works
      ModificationWatchpointEvent Does not work
      public void run() { 
      queue = vm.eventQueue();
      
      }
      /////////////////////////////////////////////////////
      // Call this function when next button pressed
      
      public void traceMe(){
      if (connected){ 
      try {
      
      EventSet eventSet = queue.remove();
      EventIterator it = eventSet.eventIterator();
      while (it.hasNext()) { 
      handleEvent(it.nextEvent()); 
      }
      eventSet.resume();
      } catch (InterruptedException exc) {
      // Ignore
      } catch (VMDisconnectedException discExc) {
      handleDisconnectedException();
      
      }
      }
      }
      I did this because I want to call traceMe method form the original interface like the following:
      startB.addActionListener(
      new ActionListener()
      {
      public void actionPerformed(ActionEvent event)
      {
      eventThread.traceMe();// call traceMe method in EventThread
      
      }
      }
      ); // end of action Listener
        • 1. Re: ModificationWatchpointEvent Problem
          800575
          It appears that you are calling traceMe each time you press a key, is that right? Each key press will result in just one EventSet being handled.
          Lots of MethodEntry/Exit events come in very fast- maybe you just haven't pressed the key enough times to get thru them to the watchpoint event?

          The JDI front-end contains a mechanism to prevent the event queues from getting too long. If this occurs, then a VirtualMachine.holdEvents JDWP command
          is sent to the back-end agent. This could be happening to you since you are removing events from the queue infrequently.

          Try calling VirtualMachine.setDebugTraceMode in your start-up to get a trace of events coming over JDWP to see if your watchpoint events show up there
          or if a holdEvents JDWP command is being sent to the backend.
          • 2. Re: ModificationWatchpointEvent Problem
            843810
            when I use the original code the output is as the following:
            -- VM Started --
            ======* main *======
            Method Entry: main -- test
            Method Entry: <init> -- test
            Method Exit: <init> -- test
            Method Entry: toString -- test
            Method Exit: toString -- test
            Method Entry: setInt_value -- test
            int_value = 1
            Method Exit: setInt_value -- test
            Method Entry: setString_value -- test
            string_value = "test"
            Method Exit: setString_value -- test
            Method Entry: toString -- test
            Method Exit: toString -- test
            Method Entry: getInt_value -- test
            Method Exit: getInt_value -- test
            Method Entry: getString_value -- test
            Method Exit: getString_value -- test
            Method Entry: toString -- test
            Method Exit: toString -- test
            Method Exit: main -- test
            ====== main end ======
            -- The application exited --



            When I use my code the output should be the same, but it prints like this:
            -- VM Started --
            ======* main *======
            Method Entry :main -- test
            Method Entry :<init> -- test
            Method Exit :<init> -- test
            Method Entry :toString -- test
            Method Exit :toString -- test
            Method Entry :setInt_value -- test
            Method Exit :setInt_value -- test
            Method Entry :setString_value -- test
            Method Exit :setString_value -- test
            Method Entry :toString -- test
            Method Exit :toString -- test
            Method Entry :getInt_value -- test
            Method Exit :getInt_value -- test
            Method Entry :getString_value -- test
            Method Exit :getString_value -- test
            Method Entry :toString -- test
            Method Exit :toString -- test
            Method Exit :main -- test
            ====== main end ======
            -- The application exited --

            You can see the diff bettween 2 outputs, as I said that for some reason it does not access the following method, which prints that specific lines
            void fieldWatchEvent(ModificationWatchpointEvent event)  {
                    Field field = event.field();
                    Value value = event.valueToBe();
                     println("    " + field.name() + " = " + value);
                     TemplateApp.descriptionArea.append("    " + field.name() + " = " + value+"\n");
                 }
            • 3. Re: ModificationWatchpointEvent Problem
              800575
              Strange. Can you call VirtualMachine.setDebugTraceMode to get the trace of JDWP messages?
              That will allow us to verify that: the ModificationWatchpointRequest is really getting sent and
              whether or not the corresponding events are making it into the JDI front-end.