112 PathString *Arguments::_system_boot_class_path = NULL; |
112 PathString *Arguments::_system_boot_class_path = NULL; |
113 bool Arguments::_has_jimage = false; |
113 bool Arguments::_has_jimage = false; |
114 |
114 |
115 char* Arguments::_ext_dirs = NULL; |
115 char* Arguments::_ext_dirs = NULL; |
116 |
116 |
|
117 bool PathString::set_value(const char *value) { |
|
118 if (_value != NULL) { |
|
119 FreeHeap(_value); |
|
120 } |
|
121 _value = AllocateHeap(strlen(value)+1, mtArguments); |
|
122 assert(_value != NULL, "Unable to allocate space for new path value"); |
|
123 if (_value != NULL) { |
|
124 strcpy(_value, value); |
|
125 } else { |
|
126 // not able to allocate |
|
127 return false; |
|
128 } |
|
129 return true; |
|
130 } |
|
131 |
|
132 void PathString::append_value(const char *value) { |
|
133 char *sp; |
|
134 size_t len = 0; |
|
135 if (value != NULL) { |
|
136 len = strlen(value); |
|
137 if (_value != NULL) { |
|
138 len += strlen(_value); |
|
139 } |
|
140 sp = AllocateHeap(len+2, mtArguments); |
|
141 assert(sp != NULL, "Unable to allocate space for new append path value"); |
|
142 if (sp != NULL) { |
|
143 if (_value != NULL) { |
|
144 strcpy(sp, _value); |
|
145 strcat(sp, os::path_separator()); |
|
146 strcat(sp, value); |
|
147 FreeHeap(_value); |
|
148 } else { |
|
149 strcpy(sp, value); |
|
150 } |
|
151 _value = sp; |
|
152 } |
|
153 } |
|
154 } |
|
155 |
|
156 PathString::PathString(const char* value) { |
|
157 if (value == NULL) { |
|
158 _value = NULL; |
|
159 } else { |
|
160 _value = AllocateHeap(strlen(value)+1, mtArguments); |
|
161 strcpy(_value, value); |
|
162 } |
|
163 } |
|
164 |
|
165 PathString::~PathString() { |
|
166 if (_value != NULL) { |
|
167 FreeHeap(_value); |
|
168 _value = NULL; |
|
169 } |
|
170 } |
|
171 |
|
172 ModulePatchPath::ModulePatchPath(const char* module_name, const char* path) { |
|
173 assert(module_name != NULL && path != NULL, "Invalid module name or path value"); |
|
174 size_t len = strlen(module_name) + 1; |
|
175 _module_name = AllocateHeap(len, mtInternal); |
|
176 strncpy(_module_name, module_name, len); // copy the trailing null |
|
177 _path = new PathString(path); |
|
178 } |
|
179 |
|
180 ModulePatchPath::~ModulePatchPath() { |
|
181 if (_module_name != NULL) { |
|
182 FreeHeap(_module_name); |
|
183 _module_name = NULL; |
|
184 } |
|
185 if (_path != NULL) { |
|
186 delete _path; |
|
187 _path = NULL; |
|
188 } |
|
189 } |
|
190 |
|
191 SystemProperty::SystemProperty(const char* key, const char* value, bool writeable, bool internal) : PathString(value) { |
|
192 if (key == NULL) { |
|
193 _key = NULL; |
|
194 } else { |
|
195 _key = AllocateHeap(strlen(key)+1, mtArguments); |
|
196 strcpy(_key, key); |
|
197 } |
|
198 _next = NULL; |
|
199 _internal = internal; |
|
200 _writeable = writeable; |
|
201 } |
|
202 |
|
203 AgentLibrary::AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) { |
|
204 _name = AllocateHeap(strlen(name)+1, mtArguments); |
|
205 strcpy(_name, name); |
|
206 if (options == NULL) { |
|
207 _options = NULL; |
|
208 } else { |
|
209 _options = AllocateHeap(strlen(options)+1, mtArguments); |
|
210 strcpy(_options, options); |
|
211 } |
|
212 _is_absolute_path = is_absolute_path; |
|
213 _os_lib = os_lib; |
|
214 _next = NULL; |
|
215 _state = agent_invalid; |
|
216 _is_static_lib = false; |
|
217 } |
|
218 |
117 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining |
219 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining |
118 // part of the option string. |
220 // part of the option string. |
119 static bool match_option(const JavaVMOption *option, const char* name, |
221 static bool match_option(const JavaVMOption *option, const char* name, |
120 const char** tail) { |
222 const char** tail) { |
121 size_t len = strlen(name); |
223 size_t len = strlen(name); |
177 #define LIMITMODS_LEN 9 |
279 #define LIMITMODS_LEN 9 |
178 #define PATH "path" |
280 #define PATH "path" |
179 #define PATH_LEN 4 |
281 #define PATH_LEN 4 |
180 #define UPGRADE_PATH "upgrade.path" |
282 #define UPGRADE_PATH "upgrade.path" |
181 #define UPGRADE_PATH_LEN 12 |
283 #define UPGRADE_PATH_LEN 12 |
|
284 |
|
285 void Arguments::add_init_library(const char* name, char* options) { |
|
286 _libraryList.add(new AgentLibrary(name, options, false, NULL)); |
|
287 } |
|
288 |
|
289 void Arguments::add_init_agent(const char* name, char* options, bool absolute_path) { |
|
290 _agentList.add(new AgentLibrary(name, options, absolute_path, NULL)); |
|
291 } |
|
292 |
|
293 // Late-binding agents not started via arguments |
|
294 void Arguments::add_loaded_agent(AgentLibrary *agentLib) { |
|
295 _agentList.add(agentLib); |
|
296 } |
|
297 |
|
298 void Arguments::add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib) { |
|
299 _agentList.add(new AgentLibrary(name, options, absolute_path, os_lib)); |
|
300 } |
182 |
301 |
183 // Return TRUE if option matches 'property', or 'property=', or 'property.'. |
302 // Return TRUE if option matches 'property', or 'property=', or 'property.'. |
184 static bool matches_property_suffix(const char* option, const char* property, size_t len) { |
303 static bool matches_property_suffix(const char* option, const char* property, size_t len) { |
185 return ((strncmp(option, property, len) == 0) && |
304 return ((strncmp(option, property, len) == 0) && |
186 (option[len] == '=' || option[len] == '.' || option[len] == '\0')); |
305 (option[len] == '=' || option[len] == '.' || option[len] == '\0')); |