Class VirtualMachine.ForHotSpot

  • All Implemented Interfaces:
    VirtualMachine
    Enclosing interface:
    VirtualMachine

    public abstract static class VirtualMachine.ForHotSpot
    extends java.lang.Object
    implements VirtualMachine
    A virtual machine implementation for a HotSpot VM or any compatible VM.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String ARGUMENT_DELIMITER
      A delimiter to be used for attachment.
      private static byte[] BLANK
      A blank line argument.
      private static java.lang.String INSTRUMENT_COMMAND
      The instrument command.
      private static java.lang.String LOAD_COMMAND
      The load command.
      protected java.lang.String processId
      The target process's id.
      private static java.lang.String PROTOCOL_VERSION
      The protocol version to use for communication.
      private static java.lang.String UTF_8
      The UTF-8 charset name.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ForHotSpot​(java.lang.String processId)
      Creates a new HotSpot-compatible VM implementation.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void connect()
      Connects to the target VM.
      void loadAgent​(java.lang.String jarFile, java.lang.String argument)
      Loads an agent into the represented virtual machine.
      protected abstract int read​(byte[] buffer)
      Reads from the communication channel.
      protected abstract void write​(byte[] buffer)
      Writes to the communication channel.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UTF_8

        private static final java.lang.String UTF_8
        The UTF-8 charset name.
        See Also:
        Constant Field Values
      • PROTOCOL_VERSION

        private static final java.lang.String PROTOCOL_VERSION
        The protocol version to use for communication.
        See Also:
        Constant Field Values
      • LOAD_COMMAND

        private static final java.lang.String LOAD_COMMAND
        The load command.
        See Also:
        Constant Field Values
      • INSTRUMENT_COMMAND

        private static final java.lang.String INSTRUMENT_COMMAND
        The instrument command.
        See Also:
        Constant Field Values
      • ARGUMENT_DELIMITER

        private static final java.lang.String ARGUMENT_DELIMITER
        A delimiter to be used for attachment.
        See Also:
        Constant Field Values
      • BLANK

        private static final byte[] BLANK
        A blank line argument.
      • processId

        protected final java.lang.String processId
        The target process's id.
    • Constructor Detail

      • ForHotSpot

        protected ForHotSpot​(java.lang.String processId)
        Creates a new HotSpot-compatible VM implementation.
        Parameters:
        processId - The target process's id.
    • Method Detail

      • loadAgent

        public void loadAgent​(java.lang.String jarFile,
                              java.lang.String argument)
                       throws java.io.IOException
        Loads an agent into the represented virtual machine.
        Specified by:
        loadAgent in interface VirtualMachine
        Parameters:
        jarFile - The jar file to attach.
        argument - The argument to provide or null if no argument should be provided.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • connect

        protected abstract void connect()
                                 throws java.io.IOException
        Connects to the target VM.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • read

        protected abstract int read​(byte[] buffer)
                             throws java.io.IOException
        Reads from the communication channel.
        Parameters:
        buffer - The buffer to read into.
        Returns:
        The amount of bytes read.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • write

        protected abstract void write​(byte[] buffer)
                               throws java.io.IOException
        Writes to the communication channel.
        Parameters:
        buffer - The buffer to write from.
        Throws:
        java.io.IOException - If an I/O exception occurs.