src/java.base/share/classes/jdk/internal/vm/VMSupport.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff src/java.base/share/classes/jdk/internal/vm

src/java.base/share/classes/jdk/internal/vm/VMSupport.java

Print this page


   1 /*
   2  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package jdk.internal.vm;
  26 
  27 import java.io.ByteArrayOutputStream;
  28 import java.io.IOException;

  29 import java.util.Properties;
  30 import java.util.Set;
  31 import java.util.jar.JarFile;
  32 import java.util.jar.Manifest;
  33 import java.util.jar.Attributes;
  34 
  35 /*
  36  * Support class used by JVMTI and VM attach mechanism.
  37  */
  38 public class VMSupport {
  39 
  40     private static Properties agentProps = null;
  41     /**
  42      * Returns the agent properties.
  43      */
  44     public static synchronized Properties getAgentProperties() {
  45         if (agentProps == null) {
  46             agentProps = new Properties();
  47             initAgentProperties(agentProps);
  48         }


  90             if (man != null) {
  91                 if (man.getMainAttributes().getValue(Attributes.Name.CLASS_PATH) != null) {
  92                     return true;
  93                 }
  94             }
  95             return false;
  96         } catch (IOException ioe) {
  97             throw new RuntimeException(ioe.getMessage());
  98         }
  99     }
 100 
 101     /*
 102      * Return the temporary directory that the VM uses for the attach
 103      * and perf data files.
 104      *
 105      * It is important that this directory is well-known and the
 106      * same for all VM instances. It cannot be affected by configuration
 107      * variables such as java.io.tmpdir.
 108      */
 109     public static native String getVMTemporaryDirectory();






























 110 }
   1 /*
   2  * Copyright (c) 2005, 2018 Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package jdk.internal.vm;
  26 
  27 import java.io.ByteArrayOutputStream;
  28 import java.io.IOException;
  29 import java.io.File;
  30 import java.util.Properties;
  31 import java.util.Set;
  32 import java.util.jar.JarFile;
  33 import java.util.jar.Manifest;
  34 import java.util.jar.Attributes;
  35 
  36 /*
  37  * Support class used by JVMTI and VM attach mechanism.
  38  */
  39 public class VMSupport {
  40 
  41     private static Properties agentProps = null;
  42     /**
  43      * Returns the agent properties.
  44      */
  45     public static synchronized Properties getAgentProperties() {
  46         if (agentProps == null) {
  47             agentProps = new Properties();
  48             initAgentProperties(agentProps);
  49         }


  91             if (man != null) {
  92                 if (man.getMainAttributes().getValue(Attributes.Name.CLASS_PATH) != null) {
  93                     return true;
  94                 }
  95             }
  96             return false;
  97         } catch (IOException ioe) {
  98             throw new RuntimeException(ioe.getMessage());
  99         }
 100     }
 101 
 102     /*
 103      * Return the temporary directory that the VM uses for the attach
 104      * and perf data files.
 105      *
 106      * It is important that this directory is well-known and the
 107      * same for all VM instances. It cannot be affected by configuration
 108      * variables such as java.io.tmpdir.
 109      */
 110     public static native String getVMTemporaryDirectory();
 111 
 112     /*
 113      * Return a list of the temporary directories that the VM uses for
 114      * the attach and perf data files.
 115      *
 116      * This method returns the traditional host temp directory but also
 117      * includes a list of temp directories used by containers.
 118      *
 119      * It is important that the returned directories are well-known and the
 120      * same for all VM instances. It cannot be affected by configuration
 121      * variables such as java.io.tmpdir.
 122      */
 123     public static String[] getVMTemporaryDirectories(int vmid) {
 124         return VMSupportImpl.getTemporaryDirectories(vmid);
 125     }
 126 
 127     /*
 128      * Extract the host PID from a file path.
 129      */
 130     public static int getLocalVmId(File file) throws NumberFormatException {
 131         return VMSupportImpl.getLocalVmId(file);
 132     }
 133 
 134     /*
 135      * Return the inner most namespaced PID if there is one,
 136      * otherwise return the original PID.
 137      */
 138     public static int getNamespaceVmId(int pid) {
 139         return VMSupportImpl.getNamespaceVmId(pid);
 140     }
 141 }
src/java.base/share/classes/jdk/internal/vm/VMSupport.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File