src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java
changeset 58265 577e17cab93f
parent 53707 67537bbafd7f
equal deleted inserted replaced
58264:4e96939a5746 58265:577e17cab93f
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package sun.tools.common;
    26 package sun.tools.common;
    27 
    27 
    28 import java.lang.reflect.Method;
       
    29 
       
    30 /**
    28 /**
    31  * A helper class to retrieve the main class name for a running
    29  * A helper class to retrieve the main class name for a running
    32  * Java process.
    30  * Java process. Default implementation returns null. Platform specific
       
    31  * implementation currently available for Linux only.
    33  */
    32  */
    34 
    33 final class ProcessHelper {
    35 public interface ProcessHelper {
       
    36 
       
    37     /**
       
    38      * Returns an instance of the ProcessHelper class.
       
    39      *
       
    40      * @return ProcessHelper object or null if not supported on this platform.
       
    41      */
       
    42     public static ProcessHelper platformProcessHelper() {
       
    43         try {
       
    44             Class<?> c = Class.forName("sun.tools.ProcessHelper");
       
    45             @SuppressWarnings("unchecked")
       
    46             Method m = c.getMethod("getInstance");
       
    47             return (ProcessHelper) m.invoke(null);
       
    48         } catch (ClassNotFoundException e) {
       
    49             return null;
       
    50         } catch (ReflectiveOperationException e) {
       
    51             throw new InternalError(e);
       
    52         }
       
    53     }
       
    54 
       
    55 
    34 
    56     /**
    35     /**
    57      * Returns the main class name for the given Java process
    36      * Returns the main class name for the given Java process
    58      *
    37      *
    59      * @param pid - process ID (pid)
    38      * @param pid - process ID (pid)
    60      * @return main class name or null if the main class could not be retrieved
    39      * @return main class name or null if the main class could not be retrieved
    61      */
    40      */
    62 
    41     static String getMainClass(String pid) {
    63     String getMainClass(String pid);
    42         return null;
       
    43     }
    64 }
    44 }