org-netbeans-lib-profiler

16:39:46.235 INFO  jd.cli.Main - Decompiling org-netbeans-lib-profiler.jar
package org.netbeans.lib.profiler;

import org.netbeans.lib.profiler.client.AppStatusHandler.AsyncDialog;

class ProfilerClient$1
  implements Runnable
{
  ProfilerClient$1(ProfilerClient paramProfilerClient, AppStatusHandler.AsyncDialog paramAsyncDialog) {}
  
  public void run()
  {
    val$dialog.close();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.lib.profiler.ProfilerClient.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.lib.profiler;

import org.netbeans.lib.profiler.results.EventBufferProcessor;
import org.netbeans.lib.profiler.results.EventBufferResultsProvider;
import org.netbeans.lib.profiler.results.memory.MemoryCCTProvider;
import org.netbeans.lib.profiler.utils.MiscUtils;
import org.netbeans.lib.profiler.wireprotocol.Command;
import org.netbeans.lib.profiler.wireprotocol.EventBufferDumpedCommand;
import org.netbeans.lib.profiler.wireprotocol.RootClassLoadedCommand;

class ProfilerClient$SeparateCmdExecutionThread
  extends Thread
{
  private ProfilerClient$SeparateCmdExecutionThread(ProfilerClient paramProfilerClient) {}
  
  public void run()
  {
    setName("*** JFluid Separate Command Execution Thread");
    synchronized (ProfilerClient.access$000(this$0))
    {
      try
      {
        ProfilerClient.access$000(this$0).wait();
      }
      catch (InterruptedException localInterruptedException)
      {
        MiscUtils.internalError("ProfilerClient.SpecialExecutionThread.run()");
      }
      if (ProfilerClient.access$100(this$0) == null) {
        return;
      }
      Command localCommand = ProfilerClient.access$100(this$0);
      ProfilerClient.access$102(this$0, null);
      switch (localCommand.getType())
      {
      case 17: 
        ProfilerClient.access$200(this$0, (RootClassLoadedCommand)localCommand);
        
        break;
      case 3: 
      case 22: 
      case 23: 
        ProfilerClient.access$300(this$0, localCommand);
        
        break;
      case 26: 
        EventBufferDumpedCommand localEventBufferDumpedCommand = (EventBufferDumpedCommand)localCommand;
        
        EventBufferProcessor.readDataAndPrepareForProcessing(localEventBufferDumpedCommand);
        EventBufferResultsProvider.getDefault().dataReady(localEventBufferDumpedCommand.getBufSize(), this$0.getCurrentInstrType());
        ProfilerClient.access$400(this$0, true, null);
        
        break;
      case 36: 
        synchronized (this$0)
        {
          synchronized (ProfilerClient.access$500(this$0))
          {
            if (ProfilerClient.access$600(this$0) != null) {
              ProfilerClient.access$600(this$0).updateInternals();
            }
            ProfilerClient.access$400(this$0, true, null);
          }
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.lib.profiler.ProfilerClient.SeparateCmdExecutionThread
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.lib.profiler;

import org.netbeans.lib.profiler.client.AppStatusHandler;
import org.netbeans.lib.profiler.client.ClientUtils.TargetAppOrVMTerminated;

class ProfilerClient$ServerListener$1
  extends Thread
{
  ProfilerClient$ServerListener$1(ProfilerClient.ServerListener paramServerListener) {}
  
  public void run()
  {
    try
    {
      int i = this$1.this$0.getCurrentInstrType();
      if ((this$1.this$0.currentInstrTypeIsRecursiveCPUProfiling()) || (this$1.this$0.currentInstrTypeIsMemoryProfiling())) {
        this$1.this$0.forceObtainedResultsDump(false, 15);
      }
      if (this$1.this$0.currentInstrTypeIsMemoryProfiling()) {
        ProfilerClient.access$1502(this$1.this$0, this$1.this$0.getAllocatedObjectsCountResults());
      }
      access$1400this$1.this$0).savedInternalStats = this$1.this$0.getInternalStats();
      
      ProfilerClient.access$1600(this$1.this$0).handleShutdown();
      
      ProfilerClient.access$1700(this$1.this$0, 15);
    }
    catch (ClientUtils.TargetAppOrVMTerminated localTargetAppOrVMTerminated) {}
  }
}

/* Location:
 * Qualified Name:     org.netbeans.lib.profiler.ProfilerClient.ServerListener.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.lib.profiler;

import java.io.IOException;
import org.netbeans.lib.profiler.client.AppStatusHandler;
import org.netbeans.lib.profiler.client.AppStatusHandler.ServerCommandHandler;
import org.netbeans.lib.profiler.client.ClientUtils.TargetAppOrVMTerminated;
import org.netbeans.lib.profiler.instrumentation.Instrumentor;
import org.netbeans.lib.profiler.results.EventBufferProcessor;
import org.netbeans.lib.profiler.utils.MiscUtils;
import org.netbeans.lib.profiler.wireprotocol.Command;
import org.netbeans.lib.profiler.wireprotocol.EventBufferDumpedCommand;
import org.netbeans.lib.profiler.wireprotocol.GetClassIdCommand;
import org.netbeans.lib.profiler.wireprotocol.GetClassIdResponse;
import org.netbeans.lib.profiler.wireprotocol.Response;
import org.netbeans.lib.profiler.wireprotocol.WireIO;

class ProfilerClient$ServerListener
  extends Thread
{
  private final Object startedFlagLock = new Object();
  private int startedFlag = 0;
  
  private ProfilerClient$ServerListener(ProfilerClient paramProfilerClient) {}
  
  public boolean isRunning()
  {
    synchronized (startedFlagLock)
    {
      return startedFlag == 1;
    }
  }
  
  public void cancel()
  {
    synchronized (startedFlagLock)
    {
      startedFlag = -1;
      startedFlagLock.notifyAll();
    }
  }
  
  public void run()
  {
    synchronized (startedFlagLock)
    {
      while (startedFlag == 0) {
        try
        {
          startedFlagLock.wait(500L);
        }
        catch (InterruptedException localInterruptedException)
        {
          startedFlag = -1;
        }
      }
      if (startedFlag == -1) {
        return;
      }
    }
    ProfilerClient.access$700(this$0);
    try
    {
      while (ProfilerClient.access$800(this$0)) {
        try
        {
          ??? = ProfilerClient.access$900(this$0).receiveCommandOrResponse();
          if (??? == null) {
            ProfilerClient.access$1000(this$0);
          } else if ((??? instanceof Command)) {
            handleServerCommand((Command)???);
          } else {
            ProfilerClient.access$1100(this$0, (Response)???);
          }
        }
        catch (IOException localIOException)
        {
          if ((ProfilerClient.access$800(this$0)) && (!ProfilerClient.access$1200(this$0))) {
            MiscUtils.printErrorMessage("exception while trying to get response from the target JVM:\n" + localIOException);
          }
        }
      }
    }
    finally
    {
      ProfilerClient.access$1300(this$0);
    }
  }
  
  public void shutdown()
  {
    synchronized (startedFlagLock)
    {
      startedFlag = 0;
      startedFlagLock.notifyAll();
    }
  }
  
  public void startRunning()
  {
    synchronized (startedFlagLock)
    {
      startedFlag = 1;
      startedFlagLock.notifyAll();
    }
  }
  
  private void handleServerCommand(Command paramCommand)
  {
    switch (paramCommand.getType())
    {
    case 18: 
      access$1400this$0).targetAppRunning = false;
      
      new Thread()
      {
        public void run()
        {
          try
          {
            int i = this$0.getCurrentInstrType();
            if ((this$0.currentInstrTypeIsRecursiveCPUProfiling()) || (this$0.currentInstrTypeIsMemoryProfiling())) {
              this$0.forceObtainedResultsDump(false, 15);
            }
            if (this$0.currentInstrTypeIsMemoryProfiling()) {
              ProfilerClient.access$1502(this$0, this$0.getAllocatedObjectsCountResults());
            }
            access$1400this$0).savedInternalStats = this$0.getInternalStats();
            
            ProfilerClient.access$1600(this$0).handleShutdown();
            
            ProfilerClient.access$1700(this$0, 15);
          }
          catch (ClientUtils.TargetAppOrVMTerminated localTargetAppOrVMTerminated) {}
        }
      }.start();
      break;
    case 19: 
      ProfilerClient.access$802(this$0, false);
      access$1400this$0).targetAppRunning = false;
      EventBufferProcessor.removeEventBufferFile();
      
      break;
    case 17: 
      ProfilerClient.access$1800(this$0, paramCommand);
      
      break;
    case 3: 
    case 22: 
    case 23: 
      ProfilerClient.access$1800(this$0, paramCommand);
      
      break;
    case 26: 
      ProfilerClient.access$1900(this$0, (EventBufferDumpedCommand)paramCommand);
      
      break;
    case 36: 
      ProfilerClient.access$1800(this$0, paramCommand);
      
      break;
    case 38: 
      ProfilerClient.access$2002(this$0, System.currentTimeMillis());
      
      break;
    case 42: 
      GetClassIdCommand localGetClassIdCommand = (GetClassIdCommand)paramCommand;
      int i = ProfilerClient.access$2100(this$0).getClassId(localGetClassIdCommand.getClassName(), localGetClassIdCommand.getClassLoaderId());
      ProfilerClient.access$2200(this$0, new GetClassIdResponse(i != -1, i));
      
      break;
    }
    if (!ProfilerClient.access$800(this$0)) {
      ProfilerClient.access$1000(this$0);
    }
    ProfilerClient.access$2300(this$0).handleServerCommand(paramCommand);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.lib.profiler.ProfilerClient.ServerListener
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.lib.profiler;

import java.awt.EventQueue;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
import java.net.ConnectException;
import java.net.Socket;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.ResourceBundle;
import org.netbeans.lib.profiler.classfile.ClassRepository;
import org.netbeans.lib.profiler.client.AppStatusHandler;
import org.netbeans.lib.profiler.client.AppStatusHandler.AsyncDialog;
import org.netbeans.lib.profiler.client.AppStatusHandler.ServerCommandHandler;
import org.netbeans.lib.profiler.client.ClientUtils.SourceCodeSelection;
import org.netbeans.lib.profiler.client.ClientUtils.TargetAppFailedToStart;
import org.netbeans.lib.profiler.client.ClientUtils.TargetAppOrVMTerminated;
import org.netbeans.lib.profiler.client.MonitoredData;
import org.netbeans.lib.profiler.client.RuntimeProfilingPoint;
import org.netbeans.lib.profiler.global.CalibrationDataFileIO;
import org.netbeans.lib.profiler.global.CommonConstants;
import org.netbeans.lib.profiler.global.Platform;
import org.netbeans.lib.profiler.global.ProfilingSessionStatus;
import org.netbeans.lib.profiler.instrumentation.BadLocationException;
import org.netbeans.lib.profiler.instrumentation.InstrumentationException;
import org.netbeans.lib.profiler.instrumentation.Instrumentor;
import org.netbeans.lib.profiler.marker.Marker;
import org.netbeans.lib.profiler.results.EventBufferProcessor;
import org.netbeans.lib.profiler.results.EventBufferResultsProvider;
import org.netbeans.lib.profiler.results.ProfilingResultsDispatcher;
import org.netbeans.lib.profiler.results.coderegion.CodeRegionResultsSnapshot;
import org.netbeans.lib.profiler.results.cpu.CPUCCTProvider;
import org.netbeans.lib.profiler.results.cpu.CPUResultsSnapshot;
import org.netbeans.lib.profiler.results.cpu.CPUResultsSnapshot.NoDataAvailableException;
import org.netbeans.lib.profiler.results.cpu.FlatProfileProvider;
import org.netbeans.lib.profiler.results.memory.AllocMemoryResultsSnapshot;
import org.netbeans.lib.profiler.results.memory.JMethodIdTable;
import org.netbeans.lib.profiler.results.memory.LivenessMemoryResultsSnapshot;
import org.netbeans.lib.profiler.results.memory.MemoryCCTProvider;
import org.netbeans.lib.profiler.results.memory.MemoryResultsSnapshot;
import org.netbeans.lib.profiler.utils.MiscUtils;
import org.netbeans.lib.profiler.utils.StringUtils;
import org.netbeans.lib.profiler.wireprotocol.CalibrationDataResponse;
import org.netbeans.lib.profiler.wireprotocol.CodeRegionCPUResultsResponse;
import org.netbeans.lib.profiler.wireprotocol.Command;
import org.netbeans.lib.profiler.wireprotocol.DefiningLoaderResponse;
import org.netbeans.lib.profiler.wireprotocol.DumpResultsResponse;
import org.netbeans.lib.profiler.wireprotocol.EventBufferDumpedCommand;
import org.netbeans.lib.profiler.wireprotocol.GetClassIdCommand;
import org.netbeans.lib.profiler.wireprotocol.GetClassIdResponse;
import org.netbeans.lib.profiler.wireprotocol.GetDefiningClassLoaderCommand;
import org.netbeans.lib.profiler.wireprotocol.GetMethodNamesForJMethodIdsCommand;
import org.netbeans.lib.profiler.wireprotocol.InitiateInstrumentationCommand;
import org.netbeans.lib.profiler.wireprotocol.InstrumentMethodGroupCommand;
import org.netbeans.lib.profiler.wireprotocol.InstrumentMethodGroupResponse;
import org.netbeans.lib.profiler.wireprotocol.InternalStatsResponse;
import org.netbeans.lib.profiler.wireprotocol.MethodNamesResponse;
import org.netbeans.lib.profiler.wireprotocol.MonitoredNumbersResponse;
import org.netbeans.lib.profiler.wireprotocol.ObjectAllocationResultsResponse;
import org.netbeans.lib.profiler.wireprotocol.Response;
import org.netbeans.lib.profiler.wireprotocol.RootClassLoadedCommand;
import org.netbeans.lib.profiler.wireprotocol.SetChangeableInstrParamsCommand;
import org.netbeans.lib.profiler.wireprotocol.SetUnchangeableInstrParamsCommand;
import org.netbeans.lib.profiler.wireprotocol.TakeHeapDumpCommand;
import org.netbeans.lib.profiler.wireprotocol.ThreadLivenessStatusResponse;
import org.netbeans.lib.profiler.wireprotocol.VMPropertiesResponse;
import org.netbeans.lib.profiler.wireprotocol.WireIO;

public class ProfilerClient
  implements CommonConstants
{
  private class SeparateCmdExecutionThread
    extends Thread
  {
    private SeparateCmdExecutionThread() {}
    
    public void run()
    {
      setName("*** JFluid Separate Command Execution Thread");
      synchronized (execInSeparateThreadLock)
      {
        try
        {
          execInSeparateThreadLock.wait();
        }
        catch (InterruptedException localInterruptedException)
        {
          MiscUtils.internalError("ProfilerClient.SpecialExecutionThread.run()");
        }
        if (execInSeparateThreadCmd == null) {
          return;
        }
        Command localCommand = execInSeparateThreadCmd;
        execInSeparateThreadCmd = null;
        switch (localCommand.getType())
        {
        case 17: 
          ProfilerClient.this.instrumentMethodGroupFromRoot((RootClassLoadedCommand)localCommand);
          
          break;
        case 3: 
        case 22: 
        case 23: 
          ProfilerClient.this.instrumentMethodGroupFollowUp(localCommand);
          
          break;
        case 26: 
          EventBufferDumpedCommand localEventBufferDumpedCommand = (EventBufferDumpedCommand)localCommand;
          
          EventBufferProcessor.readDataAndPrepareForProcessing(localEventBufferDumpedCommand);
          EventBufferResultsProvider.getDefault().dataReady(localEventBufferDumpedCommand.getBufSize(), getCurrentInstrType());
          ProfilerClient.this.sendSimpleRespToServer(true, null);
          
          break;
        case 36: 
          synchronized (ProfilerClient.this)
          {
            synchronized (forceObtainedResultsDumpLock)
            {
              if (memCctProvider != null) {
                memCctProvider.updateInternals();
              }
              ProfilerClient.this.sendSimpleRespToServer(true, null);
            }
          }
        }
      }
    }
  }
  
  private class ServerListener
    extends Thread
  {
    private final Object startedFlagLock = new Object();
    private int startedFlag = 0;
    
    private ServerListener() {}
    
    public boolean isRunning()
    {
      synchronized (startedFlagLock)
      {
        return startedFlag == 1;
      }
    }
    
    public void cancel()
    {
      synchronized (startedFlagLock)
      {
        startedFlag = -1;
        startedFlagLock.notifyAll();
      }
    }
    
    public void run()
    {
      synchronized (startedFlagLock)
      {
        while (startedFlag == 0) {
          try
          {
            startedFlagLock.wait(500L);
          }
          catch (InterruptedException localInterruptedException)
          {
            startedFlag = -1;
          }
        }
        if (startedFlag == -1) {
          return;
        }
      }
      ProfilerClient.this.startSeparateCmdExecThread();
      try
      {
        while (targetVMAlive) {
          try
          {
            ??? = wireIO.receiveCommandOrResponse();
            if (??? == null) {
              ProfilerClient.this.closeConnection();
            } else if ((??? instanceof Command)) {
              handleServerCommand((Command)???);
            } else {
              ProfilerClient.this.setLastResponse((Response)???);
            }
          }
          catch (IOException localIOException)
          {
            if ((targetVMAlive) && (!terminateOrDetachCommandIssued)) {
              MiscUtils.printErrorMessage("exception while trying to get response from the target JVM:\n" + localIOException);
            }
          }
        }
      }
      finally
      {
        ProfilerClient.this.stopSeparateCmdExecThread();
      }
    }
    
    public void shutdown()
    {
      synchronized (startedFlagLock)
      {
        startedFlag = 0;
        startedFlagLock.notifyAll();
      }
    }
    
    public void startRunning()
    {
      synchronized (startedFlagLock)
      {
        startedFlag = 1;
        startedFlagLock.notifyAll();
      }
    }
    
    private void handleServerCommand(Command paramCommand)
    {
      switch (paramCommand.getType())
      {
      case 18: 
        status.targetAppRunning = false;
        
        new Thread()
        {
          public void run()
          {
            try
            {
              int i = getCurrentInstrType();
              if ((currentInstrTypeIsRecursiveCPUProfiling()) || (currentInstrTypeIsMemoryProfiling())) {
                forceObtainedResultsDump(false, 15);
              }
              if (currentInstrTypeIsMemoryProfiling()) {
                savedAllocatedObjectsCountResults = getAllocatedObjectsCountResults();
              }
              status.savedInternalStats = getInternalStats();
              
              appStatusHandler.handleShutdown();
              
              ProfilerClient.this.sendSimpleCmdToServer(15);
            }
            catch (ClientUtils.TargetAppOrVMTerminated localTargetAppOrVMTerminated) {}
          }
        }.start();
        break;
      case 19: 
        targetVMAlive = false;
        status.targetAppRunning = false;
        EventBufferProcessor.removeEventBufferFile();
        
        break;
      case 17: 
        ProfilerClient.this.executeInSeparateThread(paramCommand);
        
        break;
      case 3: 
      case 22: 
      case 23: 
        ProfilerClient.this.executeInSeparateThread(paramCommand);
        
        break;
      case 26: 
        ProfilerClient.this.readAndProcessProfilingResults((EventBufferDumpedCommand)paramCommand);
        
        break;
      case 36: 
        ProfilerClient.this.executeInSeparateThread(paramCommand);
        
        break;
      case 38: 
        resultsStart = System.currentTimeMillis();
        
        break;
      case 42: 
        GetClassIdCommand localGetClassIdCommand = (GetClassIdCommand)paramCommand;
        int i = instrumentor.getClassId(localGetClassIdCommand.getClassName(), localGetClassIdCommand.getClassLoaderId());
        ProfilerClient.this.sendComplexRespToServer(new GetClassIdResponse(i != -1, i));
        
        break;
      }
      if (!targetVMAlive) {
        ProfilerClient.this.closeConnection();
      }
      serverCommandHandler.handleServerCommand(paramCommand);
    }
  }
  
  private static final ResourceBundle messages = ResourceBundle.getBundle("org.netbeans.lib.profiler.Bundle");
  private static final String CANNOT_OPEN_SERVER_TEMPFILE_MSG = messages.getString("ProfilerClient_CannotOpenServerTempFileMsg");
  private static final String PERFORMING_INSTRUMENTATION_STRING = messages.getString("ProfilerClient_PerformingInstrumentationString");
  private static final String INVALID_CODE_REGION_MSG = messages.getString("ProfilerClient_InvalidCodeRegionMsg");
  private static final String CLASS_NOT_FOUND_MSG = messages.getString("ProfilerClient_ClassNotFoundMsg");
  private static final String OUT_OF_MEMORY_MSG = messages.getString("ProfilerClient_OutOfMemoryMsg");
  private static final String INCORRECT_AGENT_VERSION_MSG = messages.getString("ProfilerClient_IncorrectAgentVersionMsg");
  private static final String ERROR_GETTING_CALIBRATION_DATA_MSG = messages.getString("ProfilerClient_ErrorGettingCalibrationDataMsg");
  private static final String MUST_CALIBRATE_FIRST_MSG = messages.getString("ProfilerClient_MustCalibrateFirstMsg");
  private static final String MUST_CALIBRATE_FIRST_SHORT_MSG = messages.getString("ProfilerClient_MustCalibrateFirstShortMsg");
  private static final String INSTRUMENTATION_LIMIT_REACHED_MSG = messages.getString("ProfilerClient_InstrumentationLimitReachedMsg");
  private static final String CORRUPTED_TARGET_CALIBRATION_DATA_MSG = messages.getString("ProfilerClient_CorruptedTargetCalibrationDataMsg");
  private static final String CONNECT_VM_MSG = messages.getString("ProfilerClient_ConnectVmMsg");
  private static final String TARGET_JVM_ERROR_MSG = messages.getString("ProfilerClient_TargetJvmErrorMsg");
  private static final String UNSUPPORTED_JVM_MSG = messages.getString("ProfilerClient_UnsupportedJvmMsg");
  private AppStatusHandler.ServerCommandHandler serverCommandHandler;
  private AppStatusHandler appStatusHandler;
  private CPUCCTProvider cpuCctProvider;
  private Command execInSeparateThreadCmd;
  private FlatProfileProvider flatProvider;
  private InitiateInstrumentationCommand commandOnStartup = null;
  private Instrumentor instrumentor;
  private MemoryCCTProvider memCctProvider;
  private Object execInSeparateThreadLock = new Object();
  private Object forceObtainedResultsDumpLock = new Object();
  private Object instrumentationLock = new Object();
  private Object responseLock = new Object();
  private ObjectInputStream socketIn;
  private ObjectOutputStream socketOut;
  private ProfilerEngineSettings settings;
  private ProfilingSessionStatus status;
  private volatile Response lastResponse;
  private SeparateCmdExecutionThread separateCmdExecThread;
  private ServerListener serverListener;
  private Socket clientSocket;
  private WireIO wireIO;
  private int[] savedAllocatedObjectsCountResults;
  private volatile boolean connectionWithServerOpen;
  private volatile boolean forceObtainedResultsDumpCalled;
  private volatile boolean handlingEventBufferDump;
  private volatile boolean instrMethodsLimitReported;
  private boolean serverClassesInitialized;
  private volatile boolean targetVMAlive;
  private volatile boolean terminateOrDetachCommandIssued;
  private int currentAgentId = -1;
  private long instrProcessingTime;
  private long resultsStart;
  
  public ProfilerClient(ProfilerEngineSettings paramProfilerEngineSettings, ProfilingSessionStatus paramProfilingSessionStatus, AppStatusHandler paramAppStatusHandler, AppStatusHandler.ServerCommandHandler paramServerCommandHandler)
  {
    settings = paramProfilerEngineSettings;
    status = paramProfilingSessionStatus;
    appStatusHandler = paramAppStatusHandler;
    serverCommandHandler = paramServerCommandHandler;
    instrumentor = new Instrumentor(paramProfilingSessionStatus, paramProfilerEngineSettings);
    EventBufferProcessor.initialize(this);
    EventBufferResultsProvider.getDefault().addDispatcher(ProfilingResultsDispatcher.getDefault());
  }
  
  public synchronized int[] getAllocatedObjectsCountResults()
    throws ClientUtils.TargetAppOrVMTerminated
  {
    if (!targetVMAlive)
    {
      if (savedAllocatedObjectsCountResults != null) {
        return savedAllocatedObjectsCountResults;
      }
      throw new ClientUtils.TargetAppOrVMTerminated(1);
    }
    savedAllocatedObjectsCountResults = null;
    checkForTargetVMAlive();
    sendSimpleCmdToServer(30);
    
    ObjectAllocationResultsResponse localObjectAllocationResultsResponse = (ObjectAllocationResultsResponse)getAndCheckLastResponse("Unknown problem when trying to get allocated object count results.");
    
    return localObjectAllocationResultsResponse.getResults();
  }
  
  public synchronized CPUResultsSnapshot getCPUProfilingResultsSnapshot()
    throws ClientUtils.TargetAppOrVMTerminated, CPUResultsSnapshot.NoDataAvailableException
  {
    return getCPUProfilingResultsSnapshot(true);
  }
  
  public synchronized CPUResultsSnapshot getCPUProfilingResultsSnapshot(boolean paramBoolean)
    throws ClientUtils.TargetAppOrVMTerminated, CPUResultsSnapshot.NoDataAvailableException
  {
    checkForTargetVMAlive();
    if ((paramBoolean) && 
      (!forceObtainedResultsDump(false, 5))) {
      return null;
    }
    int i = 0;
    boolean bool = false;
    String[] arrayOfString1;
    String[] arrayOfString2;
    String[] arrayOfString3;
    try
    {
      status.beginTrans(false);
      bool = status.collectingTwoTimeStamps();
      i = status.getNInstrMethods();
      arrayOfString1 = new String[i];
      System.arraycopy(status.getInstrMethodClasses(), 0, arrayOfString1, 0, i);
      arrayOfString2 = new String[i];
      System.arraycopy(status.getInstrMethodNames(), 0, arrayOfString2, 0, i);
      arrayOfString3 = new String[i];
      System.arraycopy(status.getInstrMethodSignatures(), 0, arrayOfString3, 0, i);
    }
    finally
    {
      status.endTrans();
    }
    return new CPUResultsSnapshot(resultsStart, System.currentTimeMillis(), cpuCctProvider, bool, arrayOfString1, arrayOfString2, arrayOfString3, i);
  }
  
  public synchronized CodeRegionResultsSnapshot getCodeRegionProfilingResultsSnapshot()
    throws ClientUtils.TargetAppOrVMTerminated
  {
    checkForTargetVMAlive();
    sendSimpleCmdToServer(8);
    
    CodeRegionCPUResultsResponse localCodeRegionCPUResultsResponse = (CodeRegionCPUResultsResponse)getAndCheckLastResponse("Unknown problem when trying to get code region CPU results.");
    
    return new CodeRegionResultsSnapshot(resultsStart, System.currentTimeMillis(), localCodeRegionCPUResultsResponse.getResults(), status.timerCountsInSecond[0]);
  }
  
  public int getCurrentAgentId()
  {
    return currentAgentId;
  }
  
  public void setCurrentInstrType(int paramInt)
  {
    status.currentInstrType = paramInt;
  }
  
  public int getCurrentInstrType()
  {
    return status.currentInstrType;
  }
  
  public synchronized byte[] getCurrentThreadsLivenessStatus()
  {
    try
    {
      checkForTargetVMAlive();
      sendSimpleCmdToServer(16);
      
      ThreadLivenessStatusResponse localThreadLivenessStatusResponse = (ThreadLivenessStatusResponse)getAndCheckLastResponse("Unknown problem when trying to get thread liveness information.");
      
      return localThreadLivenessStatusResponse.getStatus();
    }
    catch (ClientUtils.TargetAppOrVMTerminated localTargetAppOrVMTerminated)
    {
      if (serverListener.isRunning()) {
        MiscUtils.printErrorMessage("in getCurrentThreadLivenessStatus(), caught exception: " + localTargetAppOrVMTerminated);
      }
    }
    return null;
  }
  
  public synchronized int getDefiningClassLoaderId(String paramString, int paramInt)
    throws ClientUtils.TargetAppOrVMTerminated
  {
    checkForTargetVMAlive();
    
    GetDefiningClassLoaderCommand localGetDefiningClassLoaderCommand = new GetDefiningClassLoaderCommand(paramString, paramInt);
    sendComplexCmdToServer(localGetDefiningClassLoaderCommand);
    
    DefiningLoaderResponse localDefiningLoaderResponse = (DefiningLoaderResponse)getAndCheckLastResponse("Unknown problem when trying to get a defining loader for class");
    
    return localDefiningLoaderResponse.getLoaderId();
  }
  
  public FlatProfileProvider getFlatProfileProvider()
  {
    return flatProvider;
  }
  
  public long getInstrProcessingTime()
  {
    return instrProcessingTime;
  }
  
  public synchronized InternalStatsResponse getInternalStats()
    throws ClientUtils.TargetAppOrVMTerminated
  {
    checkForTargetVMAlive();
    sendSimpleCmdToServer(24);
    
    InternalStatsResponse localInternalStatsResponse = (InternalStatsResponse)getLastResponse();
    
    return localInternalStatsResponse;
  }
  
  public MemoryCCTProvider getMemoryCCTProvider()
  {
    return memCctProvider;
  }
  
  public synchronized MemoryResultsSnapshot getMemoryProfilingResultsSnapshot()
    throws ClientUtils.TargetAppOrVMTerminated
  {
    return getMemoryProfilingResultsSnapshot(true);
  }
  
  public synchronized MemoryResultsSnapshot getMemoryProfilingResultsSnapshot(boolean paramBoolean)
    throws ClientUtils.TargetAppOrVMTerminated
  {
    checkForTargetVMAlive();
    if ((paramBoolean) && 
      (!forceObtainedResultsDump(false, 5))) {
      return null;
    }
    memCctProvider.beginTrans(false);
    try
    {
      memCctProvider.updateInternals();
      Object localObject1;
      if (getCurrentInstrType() == 4) {
        return new AllocMemoryResultsSnapshot(resultsStart, System.currentTimeMillis(), memCctProvider, this);
      }
      return new LivenessMemoryResultsSnapshot(resultsStart, System.currentTimeMillis(), memCctProvider, this);
    }
    finally
    {
      memCctProvider.endTrans();
    }
  }
  
  public Marker getMethodMarker()
  {
    return settings.getMethodMarker();
  }
  
  public synchronized String[][] getMethodNamesForJMethodIds(int[] paramArrayOfInt)
    throws ClientUtils.TargetAppOrVMTerminated
  {
    checkForTargetVMAlive();
    
    GetMethodNamesForJMethodIdsCommand localGetMethodNamesForJMethodIdsCommand = new GetMethodNamesForJMethodIdsCommand(paramArrayOfInt);
    sendComplexCmdToServer(localGetMethodNamesForJMethodIdsCommand);
    
    MethodNamesResponse localMethodNamesResponse = (MethodNamesResponse)getAndCheckLastResponse("Unknown problem when trying to get method names for jmethodIds");
    
    return StringUtils.convertPackedStringsIntoStringArrays(localMethodNamesResponse.getPackedData(), localMethodNamesResponse.getPackedArrayOffsets(), 3);
  }
  
  public synchronized MonitoredData getMonitoredData()
  {
    try
    {
      checkForTargetVMAlive();
      sendSimpleCmdToServer(32);
      
      Response localResponse = getAndCheckLastResponse("Unknown problem when trying to get memory numbers.");
      try
      {
        MonitoredNumbersResponse localMonitoredNumbersResponse = (MonitoredNumbersResponse)localResponse;
        
        return MonitoredData.getMonitoredData(localMonitoredNumbersResponse);
      }
      catch (ClassCastException localClassCastException)
      {
        MiscUtils.printErrorMessage("caught ClassCastException in getMonitoredNumbers. The real class of resp is " + localResponse.getClass().getName() + ", resp = " + localResponse);
        
        throw localClassCastException;
      }
      return null;
    }
    catch (ClientUtils.TargetAppOrVMTerminated localTargetAppOrVMTerminated)
    {
      if (serverListener.isRunning()) {
        MiscUtils.printErrorMessage("in getMonitoredData(), caught exception: " + localTargetAppOrVMTerminated);
      }
    }
  }
  
  public ProfilerEngineSettings getSettings()
  {
    return settings;
  }
  
  public ObjectInputStream getSocketInputStream()
  {
    return socketIn;
  }
  
  public ProfilingSessionStatus getStatus()
  {
    return status;
  }
  
  public synchronized boolean cpuResultsExist()
    throws ClientUtils.TargetAppOrVMTerminated
  {
    checkForTargetVMAlive();
    sendSimpleCmdToServer(6);
    
    Response localResponse = getAndCheckLastResponse("Unknown problem when trying to check for CPU profiling results.");
    
    return localResponse.yes();
  }
  
  public boolean currentInstrTypeIsMemoryProfiling()
  {
    return (status.currentInstrType == 4) || (status.currentInstrType == 5);
  }
  
  public boolean currentInstrTypeIsRecursiveCPUProfiling()
  {
    return (status.currentInstrType == 2) || (status.currentInstrType == 3);
  }
  
  public void deinstrumentMemoryProfiledClasses(boolean[] paramArrayOfBoolean)
    throws InstrumentationException, ClientUtils.TargetAppOrVMTerminated
  {
    synchronized (instrumentationLock)
    {
      if (getCurrentInstrType() == 0) {
        return;
      }
      Response localResponse = null;
      checkForTargetAppRunning();
      
      long l = System.currentTimeMillis();
      InstrumentMethodGroupCommand localInstrumentMethodGroupCommand = instrumentor.getCommandToUnprofileClasses(paramArrayOfBoolean);
      if (!localInstrumentMethodGroupCommand.isEmpty())
      {
        synchronized (this)
        {
          sendComplexCmdToServer(localInstrumentMethodGroupCommand);
          instrProcessingTime += System.currentTimeMillis() - l;
          localResponse = getLastResponse();
        }
        if (!localResponse.isOK()) {
          throw new InstrumentationException(localResponse.getErrorMessage());
        }
      }
    }
  }
  
  public synchronized void detachFromTargetJVM()
    throws ClientUtils.TargetAppOrVMTerminated
  {
    checkForTargetVMAlive();
    terminateOrDetachCommandIssued = true;
    sendSimpleCmdToServer(25);
    try
    {
      getLastResponse();
    }
    finally
    {
      closeConnection();
      EventBufferProcessor.removeEventBufferFile();
    }
  }
  
  public boolean establishConnectionWithServer(int paramInt, boolean paramBoolean)
  {
    status.targetJDKVersionString = settings.getTargetJDKVersionString();
    
    return connectToServer(paramInt, paramBoolean);
  }
  
  public boolean forceObtainedResultsDump()
    throws ClientUtils.TargetAppOrVMTerminated
  {
    return forceObtainedResultsDump(false, 0);
  }
  
  public boolean forceObtainedResultsDump(boolean paramBoolean, int paramInt)
    throws ClientUtils.TargetAppOrVMTerminated
  {
    boolean bool = false;
    int i = paramInt;
    do
    {
      bool = forceObtainedResultsDump(paramBoolean);
      if (!bool) {
        try
        {
          Thread.sleep(200L);
        }
        catch (InterruptedException localInterruptedException1)
        {
          break;
        }
      }
      if (bool) {
        break;
      }
      i--;
    } while (i > 0);
    if (bool) {
      try
      {
        Thread.sleep(200L);
      }
      catch (InterruptedException localInterruptedException2) {}
    }
    return bool;
  }
  
  public boolean forceObtainedResultsDump(boolean paramBoolean)
    throws ClientUtils.TargetAppOrVMTerminated
  {
    synchronized (this)
    {
      synchronized (forceObtainedResultsDumpLock)
      {
        if (handlingEventBufferDump) {
          return true;
        }
        checkForTargetVMAlive();
        forceObtainedResultsDumpCalled = true;
        sendSimpleCmdToServer(paramBoolean ? 40 : 27);
        
        DumpResultsResponse localDumpResultsResponse = (DumpResultsResponse)getLastResponse();
        if (localDumpResultsResponse.yes()) {
          status.dumpAbsTimeStamp = localDumpResultsResponse.getDumpAbsTimeStamp();
        } else if (ProfilerLogger.isDebug()) {
          ProfilerLogger.debug("Force Obtained Results - Received Dump Error ");
        }
        forceObtainedResultsDumpCalled = false;
        
        return localDumpResultsResponse.yes();
      }
    }
  }
  
  public void initiateCodeRegionInstrumentation(ClientUtils.SourceCodeSelection[] paramArrayOfSourceCodeSelection)
    throws ClassNotFoundException, BadLocationException, InstrumentationException, IOException, ClassFormatError, ClientUtils.TargetAppOrVMTerminated
  {
    synchronized (instrumentationLock)
    {
      removeAllInstrumentation();
      if ((status.targetAppRunning) && (status.remoteProfiling) && 
        (!getCalibrationData(true))) {
        return;
      }
      instrumentor.setStatusInfoFromSourceCodeSelection(paramArrayOfSourceCodeSelection);
      instrumentor.setSavedSourceCodeSelection(paramArrayOfSourceCodeSelection);
      
      String str1 = instrumentor.getRootClassNames()[0].replace('/', '.');
      InitiateInstrumentationCommand localInitiateInstrumentationCommand = new InitiateInstrumentationCommand(1, str1, false, status.startProfilingPointsActive);
      
      commandOnStartup = localInitiateInstrumentationCommand;
      
      setCurrentInstrType(1);
      if (status.targetAppRunning)
      {
        sendSetInstrumentationParamsCmd(false);
        
        String str2 = sendCommandAndGetResponse(commandOnStartup);
        if (str2 != null) {
          appStatusHandler.displayWarning(str2);
        }
      }
    }
  }
  
  public void initiateMemoryProfInstrumentation(int paramInt)
    throws ClientUtils.TargetAppOrVMTerminated, InstrumentationException
  {
    synchronized (instrumentationLock)
    {
      removeAllInstrumentation();
      
      String[] arrayOfString = { settings.getMainClassName() };
      InitiateInstrumentationCommand localInitiateInstrumentationCommand = createInitiateInstrumnetation(paramInt, arrayOfString, false, status.startProfilingPointsActive);
      
      commandOnStartup = localInitiateInstrumentationCommand;
      
      setCurrentInstrType(paramInt);
      if (status.targetAppRunning)
      {
        sendSetInstrumentationParamsCmd(false);
        
        String str = sendCommandAndGetResponse(commandOnStartup);
        if (str != null) {
          appStatusHandler.displayWarning(str);
        }
      }
    }
  }
  
  public void initiateRecursiveCPUProfInstrumentation(ClientUtils.SourceCodeSelection[] paramArrayOfSourceCodeSelection)
    throws ClassNotFoundException, BadLocationException, InstrumentationException, IOException, ClassFormatError, ClientUtils.TargetAppOrVMTerminated
  {
    synchronized (instrumentationLock)
    {
      removeAllInstrumentation();
      if ((status.targetAppRunning) && (status.remoteProfiling) && 
        (!getCalibrationData(true))) {
        return;
      }
      instrumentor.setStatusInfoFromSourceCodeSelection(paramArrayOfSourceCodeSelection);
      
      boolean bool = settings.getInstrumentSpawnedThreads();
      
      String[] arrayOfString = instrumentor.getRootClassNames();
      int i = settings.getCPUProfilingType() == 0 ? 2 : 3;
      InitiateInstrumentationCommand localInitiateInstrumentationCommand = createInitiateInstrumnetation(i, arrayOfString, bool, status.startProfilingPointsActive);
      
      commandOnStartup = localInitiateInstrumentationCommand;
      status.setTimerTypes(settings.getAbsoluteTimerOn(), settings.getThreadCPUTimerOn());
      
      setCurrentInstrType(i);
      if (status.targetAppRunning)
      {
        sendSetInstrumentationParamsCmd(false);
        
        String str = sendCommandAndGetResponse(commandOnStartup);
        if (str != null) {
          appStatusHandler.displayWarning(str);
        }
      }
    }
  }
  
  public synchronized boolean memoryResultsExist()
  {
    return (getMemoryCCTProvider() != null) && (getMemoryCCTProvider().getStacksForClasses() != null);
  }
  
  public void registerCPUCCTProvider(CPUCCTProvider paramCPUCCTProvider)
  {
    cpuCctProvider = paramCPUCCTProvider;
  }
  
  public void registerFlatProfileProvider(FlatProfileProvider paramFlatProfileProvider)
  {
    flatProvider = paramFlatProfileProvider;
  }
  
  public void registerMemoryCCTProvider(MemoryCCTProvider paramMemoryCCTProvider)
  {
    memCctProvider = paramMemoryCCTProvider;
  }
  
  public void removeAllInstrumentation(boolean paramBoolean)
    throws InstrumentationException
  {
    synchronized (instrumentationLock)
    {
      if (getCurrentInstrType() == 0) {
        return;
      }
      commandOnStartup = null;
      if (paramBoolean) {
        status.resetInstrClas
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd