Package javax.tools.diagnostics.runtime.java

Examples of javax.tools.diagnostics.runtime.java.JavaMonitor


    assertNotNull("JavaMonitor.getID() for 1-0-1 is null.", monitor.getID());
  }

  public void testGetName_1_0_1() throws Exception {
    JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
    assertNotNull("JavaMonitor.getName() for 1-0-1 is null.", monitor
        .getName());
  }
View Full Code Here


    assertNotNull("JavaMonitor.getName() for 1-0-1 is null.", monitor
        .getName());
  }

  public void testCountWaiters_1_0_1() throws Exception {
    JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
    int count = 0;
    Iterator waiters = monitor.getNotifyWaiters().iterator();

    while (waiters.hasNext()) {
      Object next = waiters.next();
      count++;
    }
View Full Code Here

    }else if (cpckt.getCommand() == 5){
      // Monitor information, assume JNIEnv is the same as threadID...
      byte[] inData = cpckt.getByteData();
      long object = createLongFromBytes(inData, 0, 8);
      Vector<Byte> vctr = new Vector<Byte>();
      JavaMonitor jm = null;
      logr.log(JDILogger.LEVEL_VERBOSE,"ObjectReference.MonitorInfo("+object+")");
      if ((jm = monitorMap.get(objectMap))!= null){
        JavaThread owningThread = jm.getOwner();
       
        if (owningThread != null){
          addLongToVector(vctr, owningThread.getJNIEnv().getAddress());
        }else{
          addLongToVector(vctr, 0);
        }
        addIntToVector(vctr, 1);
        addIntToVector(vctr, jm.getEnterWaiters().size());
        for (JavaThread thr : jm.getEnterWaiters()){
          addLongToVector(vctr, thr.getJNIEnv().getAddress());
        }
        logr.log(JDILogger.LEVEL_VERYVERBOSE,"  "+jm.getEnterWaiters().size()+" waiting and owner is "+owningThread);
      }else{
        addLongToVector(vctr, 0);
        addIntToVector(vctr, 0);
        addIntToVector(vctr, 0);
        logr.log(JDILogger.LEVEL_VERYVERBOSE,"  no monitor information");
View Full Code Here

    }else if(cpckt.getCommand() == 9){
      // Monitor information
      byte[] inData = cpckt.getByteData();
      long threadID = createLongFromBytes(inData, 0, 8);
      logr.log(JDILogger.LEVEL_VERBOSE, "Thread.CurrentContendedMonitors(" + threadID + ")"); //$NON-NLS-1$ //$NON-NLS-2$
      JavaMonitor contended = null;
      for (JavaMonitor jm : monitorMap.values()){
        for (JavaThread thr: jm.getEnterWaiters()){
          if (thr.getJNIEnv().getAddress() == threadID){
            contended = jm;
          }
        }
      }
     
     
      Vector<Byte> vctr = new Vector<Byte>();
      if (contended == null){
        addLongToVector(vctr, 0);
      }else{
        addIntToVector(vctr, (byte)TAG_OBJECT);
        addLongToVector(vctr, contended.getObject().getID().getAddress());
        logr.log(JDILogger.LEVEL_VERYVERBOSE, "  Contended on "+contended.getObject().getID().getAddress()); //$NON-NLS-1$ //$NON-NLS-2$
      }
      ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
      rpckt.setData(vectorToByte(vctr));
      return rpckt;
     
View Full Code Here

  {
    Map monitors = new HashMap();
   
    Iterator itMonitor = jr.getMonitors().iterator();
    while (itMonitor.hasNext()) {
      JavaMonitor jm = (JavaMonitor)itMonitor.next();
      Iterator itEnterWaiter = jm.getEnterWaiters().iterator();
      while (itEnterWaiter.hasNext()) {
        JavaThread jt = (JavaThread)itEnterWaiter.next();
        monitors.put(jt, new MonitorState(jm, MonitorState.WAITING_TO_ENTER));
      }
      Iterator itNotifyWaiter = jm.getNotifyWaiters().iterator();
      while (itNotifyWaiter.hasNext()) {
        JavaThread jt = (JavaThread)itNotifyWaiter.next();
        monitors.put(jt, new MonitorState(jm, MonitorState.WAITING_TO_BE_NOTIFIED_ON));
      }
    }
View Full Code Here

      JavaRuntime jRuntime = (JavaRuntime)runtimes.next();
      Iterator monitors = jRuntime.getMonitors().iterator();
     
      out.println("\nSystem locks...");
      while (monitors.hasNext()){
        JavaMonitor jMonitor = (JavaMonitor)monitors.next();
        JavaObject jObject = jMonitor.getObject();
        try {
          String monitorName = jMonitor.getName().trim();
          if (monitorName.equalsIgnoreCase("")) {
            monitorName = "<un-named monitor>";
          }
          out.println("id: 0x" + jMonitor.getID() + " name: " + jMonitor.getName());

          JavaThread owner = jMonitor.getOwner();
          if (null != owner) {
            try {
              out.println("\towner thread id: " + owner.getImageThread().getID()
                  + " name: " + owner.getName());
            } catch (DataUnavailable e) {
              out.println("\towner thread id: " + Exceptions.getDataUnavailableString());
            }
          }
         
          // List any threads waiting on enter or notify for this monitor
          Iterator itEnterWaiter = jMonitor.getEnterWaiters().iterator();
          while (itEnterWaiter.hasNext()) {
            JavaThread jThread = (JavaThread)itEnterWaiter.next();
            try {
              out.println("\twaiting thread id: " + jThread.getImageThread().getID()
                  + " name: " + jThread.getName());
            } catch (DataUnavailable dae) {
              out.println("\twaiting thread id: <unknown>");
            }
          }
          Iterator itNotifyWaiter = jMonitor.getNotifyWaiters().iterator();
          while (itNotifyWaiter.hasNext()) {
            JavaThread jThread = (JavaThread)itNotifyWaiter.next();
            try {
              out.println("\twaiting thread id: " + jThread.getImageThread().getID()
                  + " name: " + jThread.getName());
            } catch (DataUnavailable dae) {
              out.println("\twaiting thread id: <unknown>");
            }
          }
         
        } catch(CorruptDataException cde) {
          out.println("\nwarning, corrupt data encountered during scan for system locks...");
        }
        if (null != jObject) {
          // Remember object monitors (flat or inflated) for later
          vMonitorsWithLockedObjects.add(jMonitor);
        }
      }
    }
   
    out.println("\nLocked objects...");
    if (0 == vMonitorsWithLockedObjects.size()){
      out.println("\t...None.");
      return;
    }
    Iterator lockedObjects = vMonitorsWithLockedObjects.iterator();
    while(lockedObjects.hasNext()){
      JavaMonitor jMonitor = (JavaMonitor)lockedObjects.next();
      JavaObject jObject = jMonitor.getObject();
      try{
        JavaThread owner = jMonitor.getOwner();
        String className = "<unknown class>";
        JavaClass jClass = jObject.getJavaClass()
        if (null != jClass) {
            className = jClass.getName();
        }
View Full Code Here

TOP

Related Classes of javax.tools.diagnostics.runtime.java.JavaMonitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.