< prev index next >

src/share/vm/runtime/arguments.hpp

Print this page
rev 8910 : full patch for jfr
   1 /*
   2  * Copyright (c) 1997, 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  33 // Arguments parses the command line and recognizes options
  34 
  35 // Invocation API hook typedefs (these should really be defined in jni.hpp)
  36 extern "C" {
  37   typedef void (JNICALL *abort_hook_t)(void);
  38   typedef void (JNICALL *exit_hook_t)(jint code);
  39   typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args)  ATTRIBUTE_PRINTF(2, 0);
  40 }
  41 
  42 // Forward declarations
  43 
  44 class SysClassPath;
  45 
  46 // Element describing System and User (-Dkey=value flags) defined property.
  47 
  48 class SystemProperty: public CHeapObj<mtInternal> {
  49  private:
  50   char*           _key;
  51   char*           _value;
  52   SystemProperty* _next;


  53   bool            _writeable;
  54   bool writeable()   { return _writeable; }
  55 
  56  public:
  57   // Accessors
  58   const char* key() const                   { return _key; }

  59   char* value() const                       { return _value; }
  60   SystemProperty* next() const              { return _next; }
  61   void set_next(SystemProperty* next)       { _next = next; }
  62   bool set_value(char *value) {
  63     if (writeable()) {
  64       if (_value != NULL) {
  65         FreeHeap(_value);
  66       }
  67       _value = AllocateHeap(strlen(value)+1, mtInternal);
  68       if (_value != NULL) {
  69         strcpy(_value, value);
  70       }
  71       return true;
  72     }
  73     return false;
  74   }
  75 
  76   void append_value(const char *value) {
  77     char *sp;
  78     size_t len = 0;


  80       len = strlen(value);
  81       if (_value != NULL) {
  82         len += strlen(_value);
  83       }
  84       sp = AllocateHeap(len+2, mtInternal);
  85       if (sp != NULL) {
  86         if (_value != NULL) {
  87           strcpy(sp, _value);
  88           strcat(sp, os::path_separator());
  89           strcat(sp, value);
  90           FreeHeap(_value);
  91         } else {
  92           strcpy(sp, value);
  93         }
  94         _value = sp;
  95       }
  96     }
  97   }
  98 
  99   // Constructor
 100   SystemProperty(const char* key, const char* value, bool writeable) {
 101     if (key == NULL) {
 102       _key = NULL;
 103     } else {
 104       _key = AllocateHeap(strlen(key)+1, mtInternal);
 105       strcpy(_key, key);
 106     }
 107     if (value == NULL) {
 108       _value = NULL;
 109     } else {
 110       _value = AllocateHeap(strlen(value)+1, mtInternal);
 111       strcpy(_value, value);
 112     }
 113     _next = NULL;
 114     _writeable = writeable;

 115   }
 116 };
 117 
 118 
 119 // For use by -agentlib, -agentpath and -Xrun
 120 class AgentLibrary : public CHeapObj<mtInternal> {
 121   friend class AgentLibraryList;
 122 public:
 123   // Is this library valid or not. Don't rely on os_lib == NULL as statically
 124   // linked lib could have handle of RTLD_DEFAULT which == 0 on some platforms
 125   enum AgentState {
 126     agent_invalid = 0,
 127     agent_valid   = 1
 128   };
 129 
 130  private:
 131   char*           _name;
 132   char*           _options;
 133   void*           _os_lib;
 134   bool            _is_absolute_path;


   1 /*
   2  * Copyright (c) 1997, 2019, 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  33 // Arguments parses the command line and recognizes options
  34 
  35 // Invocation API hook typedefs (these should really be defined in jni.hpp)
  36 extern "C" {
  37   typedef void (JNICALL *abort_hook_t)(void);
  38   typedef void (JNICALL *exit_hook_t)(jint code);
  39   typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args)  ATTRIBUTE_PRINTF(2, 0);
  40 }
  41 
  42 // Forward declarations
  43 
  44 class SysClassPath;
  45 
  46 // Element describing System and User (-Dkey=value flags) defined property.
  47 
  48 class SystemProperty: public CHeapObj<mtInternal> {
  49  private:
  50   char*           _key;
  51   char*           _value;
  52   SystemProperty* _next;
  53   bool            _internal;
  54 
  55   bool            _writeable;
  56   bool writeable()   { return _writeable; }
  57 
  58  public:
  59   // Accessors
  60   const char* key() const                   { return _key; }
  61   bool internal() const                     { return _internal; }
  62   char* value() const                       { return _value; }
  63   SystemProperty* next() const              { return _next; }
  64   void set_next(SystemProperty* next)       { _next = next; }
  65   bool set_value(char *value) {
  66     if (writeable()) {
  67       if (_value != NULL) {
  68         FreeHeap(_value);
  69       }
  70       _value = AllocateHeap(strlen(value)+1, mtInternal);
  71       if (_value != NULL) {
  72         strcpy(_value, value);
  73       }
  74       return true;
  75     }
  76     return false;
  77   }
  78 
  79   void append_value(const char *value) {
  80     char *sp;
  81     size_t len = 0;


  83       len = strlen(value);
  84       if (_value != NULL) {
  85         len += strlen(_value);
  86       }
  87       sp = AllocateHeap(len+2, mtInternal);
  88       if (sp != NULL) {
  89         if (_value != NULL) {
  90           strcpy(sp, _value);
  91           strcat(sp, os::path_separator());
  92           strcat(sp, value);
  93           FreeHeap(_value);
  94         } else {
  95           strcpy(sp, value);
  96         }
  97         _value = sp;
  98       }
  99     }
 100   }
 101 
 102   // Constructor
 103   SystemProperty(const char* key, const char* value, bool writeable, bool internal = false) {
 104     if (key == NULL) {
 105       _key = NULL;
 106     } else {
 107       _key = AllocateHeap(strlen(key)+1, mtInternal);
 108       strcpy(_key, key);
 109     }
 110     if (value == NULL) {
 111       _value = NULL;
 112     } else {
 113       _value = AllocateHeap(strlen(value)+1, mtInternal);
 114       strcpy(_value, value);
 115     }
 116     _next = NULL;
 117     _writeable = writeable;
 118     _internal = internal;
 119   }
 120 };
 121 
 122 
 123 // For use by -agentlib, -agentpath and -Xrun
 124 class AgentLibrary : public CHeapObj<mtInternal> {
 125   friend class AgentLibraryList;
 126 public:
 127   // Is this library valid or not. Don't rely on os_lib == NULL as statically
 128   // linked lib could have handle of RTLD_DEFAULT which == 0 on some platforms
 129   enum AgentState {
 130     agent_invalid = 0,
 131     agent_valid   = 1
 132   };
 133 
 134  private:
 135   char*           _name;
 136   char*           _options;
 137   void*           _os_lib;
 138   bool            _is_absolute_path;


< prev index next >