Class VirtualMachine.ForOpenJ9

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String IBM_TEMPORARY_FOLDER
      The temporary folder for attachment files for OpenJ9 VMs.
      private static java.security.SecureRandom SECURE_RANDOM
      A secure random for generating randomized ids.
      private java.net.Socket socket
      The socket on which this VM and the target VM communicate.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ForOpenJ9​(java.net.Socket socket)
      Creates a new virtual machine connection for OpenJ9.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static VirtualMachine attach​(java.lang.String processId)
      Attaches to the supplied process id using the default JNA implementation.
      static VirtualMachine attach​(java.lang.String processId, int timeout, VirtualMachine.ForOpenJ9.Dispatcher dispatcher)
      Attaches to the supplied process id.
      void detach()
      Detaches this virtual machine representation.
      java.util.Properties getAgentProperties()
      Loads the target VMs agent properties.
      java.util.Properties getSystemProperties()
      Loads the target VMs system properties.
      void loadAgent​(java.lang.String jarFile, java.lang.String argument)
      Loads an agent into the represented virtual machine.
      void loadAgentLibrary​(java.lang.String library, java.lang.String argument)
      Loads a native agent library into the represented virtual machine.
      void loadAgentPath​(java.lang.String path, java.lang.String argument)
      Loads a native agent into the represented virtual machine.
      private static byte[] read​(java.net.Socket socket)
      Reads a '\0'-terminated value from the target socket.
      java.lang.String startLocalManagementAgent()
      Starts a local management agent.
      void startManagementAgent​(java.util.Properties properties)
      Starts a JMX management agent.
      private static void write​(java.net.Socket socket, byte[] value)
      Writes the supplied value to the target socket.
      • Methods inherited from class java.lang.Object

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

      • IBM_TEMPORARY_FOLDER

        private static final java.lang.String IBM_TEMPORARY_FOLDER
        The temporary folder for attachment files for OpenJ9 VMs.
        See Also:
        Constant Field Values
      • SECURE_RANDOM

        private static final java.security.SecureRandom SECURE_RANDOM
        A secure random for generating randomized ids.
      • socket

        private final java.net.Socket socket
        The socket on which this VM and the target VM communicate.
    • Constructor Detail

      • ForOpenJ9

        protected ForOpenJ9​(java.net.Socket socket)
        Creates a new virtual machine connection for OpenJ9.
        Parameters:
        socket - The socket on which this VM and the target VM communicate.
    • Method Detail

      • attach

        public static VirtualMachine attach​(java.lang.String processId)
                                     throws java.io.IOException
        Attaches to the supplied process id using the default JNA implementation. This method will not consider attaching to VMs owned by different users than the current user.
        Parameters:
        processId - The process id.
        Returns:
        A suitable virtual machine implementation.
        Throws:
        java.io.IOException - If an IO exception occurs during establishing the connection.
      • attach

        public static VirtualMachine attach​(java.lang.String processId,
                                            int timeout,
                                            VirtualMachine.ForOpenJ9.Dispatcher dispatcher)
                                     throws java.io.IOException
        Attaches to the supplied process id.
        Parameters:
        processId - The process id.
        timeout - The timeout for establishing the socket connection.
        dispatcher - The connector to use to communicate with the target VM.
        Returns:
        A suitable virtual machine implementation.
        Throws:
        java.io.IOException - If an IO exception occurs during establishing the connection.
      • getSystemProperties

        public java.util.Properties getSystemProperties()
                                                 throws java.io.IOException
        Loads the target VMs system properties.
        Returns:
        The target VM properties.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • getAgentProperties

        public java.util.Properties getAgentProperties()
                                                throws java.io.IOException
        Loads the target VMs agent properties.
        Returns:
        The target VM properties.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • loadAgent

        public void loadAgent​(java.lang.String jarFile,
                              @MaybeNull
                              java.lang.String argument)
                       throws java.io.IOException
        Loads an agent into the represented virtual machine.
        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.
      • loadAgentPath

        public void loadAgentPath​(java.lang.String path,
                                  @MaybeNull
                                  java.lang.String argument)
                           throws java.io.IOException
        Loads a native agent into the represented virtual machine.
        Parameters:
        path - The agent path.
        argument - The argument to provide or null if no argument should be provided.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • loadAgentLibrary

        public void loadAgentLibrary​(java.lang.String library,
                                     @MaybeNull
                                     java.lang.String argument)
                              throws java.io.IOException
        Loads a native agent library into the represented virtual machine.
        Parameters:
        library - The agent library.
        argument - The argument to provide or null if no argument should be provided.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • startManagementAgent

        public void startManagementAgent​(java.util.Properties properties)
                                  throws java.io.IOException
        Starts a JMX management agent.
        Parameters:
        properties - The properties to transfer to the JMX agent.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • startLocalManagementAgent

        public java.lang.String startLocalManagementAgent()
                                                   throws java.io.IOException
        Starts a local management agent.
        Returns:
        The local connector address.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • detach

        public void detach()
                    throws java.io.IOException
        Detaches this virtual machine representation.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • write

        private static void write​(java.net.Socket socket,
                                  byte[] value)
                           throws java.io.IOException
        Writes the supplied value to the target socket.
        Parameters:
        socket - The socket to write to.
        value - The value being written.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • read

        private static byte[] read​(java.net.Socket socket)
                            throws java.io.IOException
        Reads a '\0'-terminated value from the target socket.
        Parameters:
        socket - The socket to read from.
        Returns:
        The value that was read.
        Throws:
        java.io.IOException - If an I/O exception occurs.