123 size_t len = strlen(name);
124 if (strncmp(option->optionString, name, len) == 0) {
125 *tail = option->optionString + len;
126 return true;
127 } else {
128 return false;
129 }
130 }
131
132 // Check if 'option' matches 'name'. No "tail" is allowed.
133 static bool match_option(const JavaVMOption *option, const char* name) {
134 const char* tail = NULL;
135 bool result = match_option(option, name, &tail);
136 if (tail != NULL && *tail == '\0') {
137 return result;
138 } else {
139 return false;
140 }
141 }
142
143 #define MODULE_PROPERTY_PREFIX "jdk.module"
144 #define MODULE_PROPERTY_PREFIX_LEN 10
145 #define ADDEXPORTS "addexports"
146 #define ADDEXPORTS_LEN 10
147 #define ADDREADS "addreads"
148 #define ADDREADS_LEN 8
149 #define PATCH "patch"
150 #define PATCH_LEN 5
151 #define ADDMODS "addmods"
152 #define ADDMODS_LEN 7
153 #define LIMITMODS "limitmods"
154 #define LIMITMODS_LEN 9
155 #define PATH "path"
156 #define PATH_LEN 4
157 #define UPGRADE_PATH "upgrade.path"
158 #define UPGRADE_PATH_LEN 12
159
160 // Return TRUE if option matches property.<digits> or matches property.<digits>=.
161 static bool is_matching_numbered_property(const char* option, const char* property, size_t len) {
162 if (strncmp(option, property, len) == 0) {
163 // Check for digits.
164 const char* sptr = option + len;
165 if (isdigit(*sptr)) { // Make sure next char is a digit.
166 while (isdigit(*sptr)) {
167 sptr++;
168 if (*sptr == '=' || *sptr == '\0') {
169 return true;
170 }
171 }
172 }
173 }
174 return false;
175 }
176
177 // Return TRUE if option matches property or matches property=.
178 static bool is_matching_property(const char* option, const char* property, size_t len) {
179 return (strncmp(option, property, len) == 0) && (option[len] == '=' || option[len] == '\0');
180 }
181
182 // Return true if option_end is the name of a module-related java property
183 // with "-Djdk.module." removed.
184 static bool is_internal_module_property_end(const char* option_end) {
185 // For the repeating properties such as (-Djdk.module.patch.0
186 // -Djdk.module.patch.1, etc) return true for "<property_name>.<digit>[=]".
187 if (is_matching_numbered_property(option_end, ADDEXPORTS ".", ADDEXPORTS_LEN + 1) ||
188 is_matching_numbered_property(option_end, ADDREADS ".", ADDREADS_LEN + 1) ||
189 is_matching_numbered_property(option_end, PATCH ".", PATCH_LEN + 1)) {
190 return true;
191 }
192 return (is_matching_property(option_end, ADDMODS, ADDMODS_LEN) ||
193 is_matching_property(option_end, LIMITMODS, LIMITMODS_LEN));
194 }
195
196 // Return true if the option is one of the module-related java properties
197 // that can only be set using the proper module-related option.
198 static bool is_module_property(const JavaVMOption *option) {
199 if (strncmp(option->optionString, "-D" MODULE_PROPERTY_PREFIX ".", MODULE_PROPERTY_PREFIX_LEN + 3) == 0) {
200 const char* option_end = option->optionString + MODULE_PROPERTY_PREFIX_LEN + 3;
201 return (is_internal_module_property_end(option_end) ||
202 is_matching_property(option_end, PATH, PATH_LEN) ||
203 is_matching_property(option_end, UPGRADE_PATH, UPGRADE_PATH_LEN));
204 }
205 return false;
206 }
207
208 // Return true if the option is one of the module-related java properties
209 // that can only be set using the proper module-related option and cannot
210 // be read by jvmti.
211 // It's expected that the caller removed the leading "-D" from 'option'.
212 bool Arguments::is_internal_module_property(const char* option) {
213 assert((strncmp(option, "-D", 2) != 0), "Unexpected leading -D");
214 if (strncmp(option, MODULE_PROPERTY_PREFIX ".", MODULE_PROPERTY_PREFIX_LEN + 1) == 0) {
215 return is_internal_module_property_end(option + MODULE_PROPERTY_PREFIX_LEN + 1);
216 }
217 return false;
218 }
219
220 // Return true if any of the strings in null-terminated array 'names' matches.
221 // If tail_allowed is true, then the tail must begin with a colon; otherwise,
222 // the option must match exactly.
223 static bool match_option(const JavaVMOption* option, const char** names, const char** tail,
224 bool tail_allowed) {
225 for (/* empty */; *names != NULL; ++names) {
226 if (match_option(option, *names, tail)) {
227 if (**tail == '\0' || tail_allowed && **tail == ':') {
228 return true;
229 }
230 }
231 }
232 return false;
233 }
234
235 static void logOption(const char* opt) {
236 if (PrintVMOptions) {
237 jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt);
238 }
239 }
240
241 // Process java launcher properties.
242 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
243 // See if sun.java.launcher, sun.java.launcher.is_altjvm or
244 // sun.java.launcher.pid is defined.
245 // Must do this before setting up other system properties,
246 // as some of them may depend on launcher type.
247 for (int index = 0; index < args->nOptions; index++) {
248 const JavaVMOption* option = args->options + index;
249 const char* tail;
250
251 if (match_option(option, "-Dsun.java.launcher=", &tail)) {
252 process_java_launcher_argument(tail, option->extraInfo);
253 continue;
254 }
255 if (match_option(option, "-Dsun.java.launcher.is_altjvm=", &tail)) {
256 if (strcmp(tail, "true") == 0) {
257 _sun_java_launcher_is_altjvm = true;
258 }
259 continue;
260 }
3149 vm_exit(0);
3150 #endif
3151 // -D
3152 } else if (match_option(option, "-D", &tail)) {
3153 const char* value;
3154 if (match_option(option, "-Djava.endorsed.dirs=", &value) &&
3155 *value!= '\0' && strcmp(value, "\"\"") != 0) {
3156 // abort if -Djava.endorsed.dirs is set
3157 jio_fprintf(defaultStream::output_stream(),
3158 "-Djava.endorsed.dirs=%s is not supported. Endorsed standards and standalone APIs\n"
3159 "in modular form will be supported via the concept of upgradeable modules.\n", value);
3160 return JNI_EINVAL;
3161 }
3162 if (match_option(option, "-Djava.ext.dirs=", &value) &&
3163 *value != '\0' && strcmp(value, "\"\"") != 0) {
3164 // abort if -Djava.ext.dirs is set
3165 jio_fprintf(defaultStream::output_stream(),
3166 "-Djava.ext.dirs=%s is not supported. Use -classpath instead.\n", value);
3167 return JNI_EINVAL;
3168 }
3169 // Silently ignore module related properties. They must be set using the modules
3170 // options. For example: use "--add-modules java.sql", not "-Djdk.module.addmods=java.sql"
3171 if (is_module_property(option)) {
3172 continue;
3173 }
3174
3175 if (!add_property(tail)) {
3176 return JNI_ENOMEM;
3177 }
3178 // Out of the box management support
3179 if (match_option(option, "-Dcom.sun.management", &tail)) {
3180 #if INCLUDE_MANAGEMENT
3181 if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != Flag::SUCCESS) {
3182 return JNI_EINVAL;
3183 }
3184 // management agent in module java.management
3185 if (!Arguments::append_to_addmods_property("java.management")) {
3186 return JNI_ENOMEM;
3187 }
3188 #else
3189 jio_fprintf(defaultStream::output_stream(),
3190 "-Dcom.sun.management is not supported in this VM.\n");
3191 return JNI_ERR;
3592 "<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
3593 "in modular form will be supported via the concept of upgradeable modules.\n");
3594 os::closedir(dir);
3595 return JNI_ERR;
3596 }
3597
3598 sprintf(path, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
3599 dir = os::opendir(path);
3600 if (dir != NULL) {
3601 jio_fprintf(defaultStream::output_stream(),
3602 "<JAVA_HOME>/lib/ext exists, extensions mechanism no longer supported; "
3603 "Use -classpath instead.\n.");
3604 os::closedir(dir);
3605 return JNI_ERR;
3606 }
3607
3608 // Append the value of the last --add-modules option specified on the command line.
3609 // This needs to be done here, to prevent overwriting possible values written
3610 // to the jdk.module.addmods property by -javaagent and other options.
3611 if (add_modules_value != NULL) {
3612 append_to_addmods_property(add_modules_value);
3613 }
3614
3615 Arguments::set_bootclassloader_append_index(((int)strlen(Arguments::get_sysclasspath()))+1);
3616
3617 // This must be done after all arguments have been processed.
3618 // java_compiler() true means set to "NONE" or empty.
3619 if (java_compiler() && !xdebug_mode()) {
3620 // For backwards compatibility, we switch to interpreted mode if
3621 // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3622 // not specified.
3623 set_mode_flags(_int);
3624 }
3625
3626 // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
3627 // but like -Xint, leave compilation thresholds unaffected.
3628 // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
3629 if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
3630 set_mode_flags(_int);
3631 }
3632
4336
4337 // Call get_shared_archive_path() here, after possible SharedArchiveFile option got parsed.
4338 SharedArchivePath = get_shared_archive_path();
4339 if (SharedArchivePath == NULL) {
4340 return JNI_ENOMEM;
4341 }
4342
4343 // Set up VerifySharedSpaces
4344 if (FLAG_IS_DEFAULT(VerifySharedSpaces) && SharedArchiveFile != NULL) {
4345 VerifySharedSpaces = true;
4346 }
4347
4348 // Delay warning until here so that we've had a chance to process
4349 // the -XX:-PrintWarnings flag
4350 if (needs_hotspotrc_warning) {
4351 warning("%s file is present but has been ignored. "
4352 "Run with -XX:Flags=%s to load the file.",
4353 hotspotrc, hotspotrc);
4354 }
4355
4356 #if defined(_ALLBSD_SOURCE) || defined(AIX) // UseLargePages is not yet supported on BSD and AIX.
4357 UNSUPPORTED_OPTION(UseLargePages);
4358 #endif
4359
4360 ArgumentsExt::report_unsupported_options();
4361
4362 #ifndef PRODUCT
4363 if (TraceBytecodesAt != 0) {
4364 TraceBytecodes = true;
4365 }
4366 if (CountCompiledCalls) {
4367 if (UseCounterDecay) {
4368 warning("UseCounterDecay disabled because CountCalls is set");
4369 UseCounterDecay = false;
4370 }
4371 }
4372 #endif // PRODUCT
4373
4374 if (ScavengeRootsInCode == 0) {
4375 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
4560 // allocation policy for the eden space.
4561 // Non NUMA-aware collectors such as CMS, G1 and Serial-GC on
4562 // all platforms and ParallelGC on Windows will interleave all
4563 // of the heap spaces across NUMA nodes.
4564 if (FLAG_IS_DEFAULT(UseNUMAInterleaving)) {
4565 FLAG_SET_ERGO(bool, UseNUMAInterleaving, true);
4566 }
4567 }
4568 return JNI_OK;
4569 }
4570
4571 int Arguments::PropertyList_count(SystemProperty* pl) {
4572 int count = 0;
4573 while(pl != NULL) {
4574 count++;
4575 pl = pl->next();
4576 }
4577 return count;
4578 }
4579
4580 const char* Arguments::PropertyList_get_value(SystemProperty *pl, const char* key) {
4581 assert(key != NULL, "just checking");
4582 SystemProperty* prop;
4583 for (prop = pl; prop != NULL; prop = prop->next()) {
4584 if (strcmp(key, prop->key()) == 0) return prop->value();
4585 }
4586 return NULL;
4587 }
4588
4589 const char* Arguments::PropertyList_get_key_at(SystemProperty *pl, int index) {
4590 int count = 0;
4591 const char* ret_val = NULL;
4592
4593 while(pl != NULL) {
4594 if(count >= index) {
4595 ret_val = pl->key();
4596 break;
4597 }
4598 count++;
4599 pl = pl->next();
4600 }
4601
4602 return ret_val;
4603 }
4604
|
123 size_t len = strlen(name);
124 if (strncmp(option->optionString, name, len) == 0) {
125 *tail = option->optionString + len;
126 return true;
127 } else {
128 return false;
129 }
130 }
131
132 // Check if 'option' matches 'name'. No "tail" is allowed.
133 static bool match_option(const JavaVMOption *option, const char* name) {
134 const char* tail = NULL;
135 bool result = match_option(option, name, &tail);
136 if (tail != NULL && *tail == '\0') {
137 return result;
138 } else {
139 return false;
140 }
141 }
142
143 // Return true if any of the strings in null-terminated array 'names' matches.
144 // If tail_allowed is true, then the tail must begin with a colon; otherwise,
145 // the option must match exactly.
146 static bool match_option(const JavaVMOption* option, const char** names, const char** tail,
147 bool tail_allowed) {
148 for (/* empty */; *names != NULL; ++names) {
149 if (match_option(option, *names, tail)) {
150 if (**tail == '\0' || tail_allowed && **tail == ':') {
151 return true;
152 }
153 }
154 }
155 return false;
156 }
157
158 static void logOption(const char* opt) {
159 if (PrintVMOptions) {
160 jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt);
161 }
162 }
163
164 bool needs_module_property_warning = false;
165
166 #define MODULE_PROPERTY_PREFIX "jdk.module"
167 #define MODULE_PROPERTY_PREFIX_LEN 10
168 #define MODULE_MAIN_PROPERTY "jdk.module.main"
169 #define MODULE_MAIN_PROPERTY_LEN 15
170
171 // Return TRUE if option matches property, or property=, or property..
172 static bool matches_property_prefix(const char* option, const char* property, size_t len) {
173 return (strncmp(option, property, len) == 0) &&
174 (option[len] == '=' || option[len] == '.' || option[len] == '\0');
175 }
176
177 // Return true if the property is either "jdk.module" or starts with "jdk.module.",
178 // but does not start with "jdk.module.main".
179 // Return false if jdk.module.main because jdk.module.main and jdk.module.main.class
180 // are valid non-internal system properties.
181 // "property" should be passed without the leading "-D".
182 bool Arguments::is_internal_module_property(const char* property) {
183 assert((strncmp(property, "-D", 2) != 0), "Unexpected leading -D");
184 return (matches_property_prefix(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) &&
185 !matches_property_prefix(property, MODULE_MAIN_PROPERTY, MODULE_MAIN_PROPERTY_LEN));
186 }
187
188 // Process java launcher properties.
189 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
190 // See if sun.java.launcher, sun.java.launcher.is_altjvm or
191 // sun.java.launcher.pid is defined.
192 // Must do this before setting up other system properties,
193 // as some of them may depend on launcher type.
194 for (int index = 0; index < args->nOptions; index++) {
195 const JavaVMOption* option = args->options + index;
196 const char* tail;
197
198 if (match_option(option, "-Dsun.java.launcher=", &tail)) {
199 process_java_launcher_argument(tail, option->extraInfo);
200 continue;
201 }
202 if (match_option(option, "-Dsun.java.launcher.is_altjvm=", &tail)) {
203 if (strcmp(tail, "true") == 0) {
204 _sun_java_launcher_is_altjvm = true;
205 }
206 continue;
207 }
3096 vm_exit(0);
3097 #endif
3098 // -D
3099 } else if (match_option(option, "-D", &tail)) {
3100 const char* value;
3101 if (match_option(option, "-Djava.endorsed.dirs=", &value) &&
3102 *value!= '\0' && strcmp(value, "\"\"") != 0) {
3103 // abort if -Djava.endorsed.dirs is set
3104 jio_fprintf(defaultStream::output_stream(),
3105 "-Djava.endorsed.dirs=%s is not supported. Endorsed standards and standalone APIs\n"
3106 "in modular form will be supported via the concept of upgradeable modules.\n", value);
3107 return JNI_EINVAL;
3108 }
3109 if (match_option(option, "-Djava.ext.dirs=", &value) &&
3110 *value != '\0' && strcmp(value, "\"\"") != 0) {
3111 // abort if -Djava.ext.dirs is set
3112 jio_fprintf(defaultStream::output_stream(),
3113 "-Djava.ext.dirs=%s is not supported. Use -classpath instead.\n", value);
3114 return JNI_EINVAL;
3115 }
3116 // Check for module related properties. They must be set using the modules
3117 // options. For example: use "--add-modules=java.sql", not
3118 // "-Djdk.module.addmods=java.sql"
3119 if (is_internal_module_property(option->optionString + 2)) {
3120 needs_module_property_warning = true;
3121 continue;
3122 }
3123
3124 if (!add_property(tail)) {
3125 return JNI_ENOMEM;
3126 }
3127 // Out of the box management support
3128 if (match_option(option, "-Dcom.sun.management", &tail)) {
3129 #if INCLUDE_MANAGEMENT
3130 if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != Flag::SUCCESS) {
3131 return JNI_EINVAL;
3132 }
3133 // management agent in module java.management
3134 if (!Arguments::append_to_addmods_property("java.management")) {
3135 return JNI_ENOMEM;
3136 }
3137 #else
3138 jio_fprintf(defaultStream::output_stream(),
3139 "-Dcom.sun.management is not supported in this VM.\n");
3140 return JNI_ERR;
3541 "<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
3542 "in modular form will be supported via the concept of upgradeable modules.\n");
3543 os::closedir(dir);
3544 return JNI_ERR;
3545 }
3546
3547 sprintf(path, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
3548 dir = os::opendir(path);
3549 if (dir != NULL) {
3550 jio_fprintf(defaultStream::output_stream(),
3551 "<JAVA_HOME>/lib/ext exists, extensions mechanism no longer supported; "
3552 "Use -classpath instead.\n.");
3553 os::closedir(dir);
3554 return JNI_ERR;
3555 }
3556
3557 // Append the value of the last --add-modules option specified on the command line.
3558 // This needs to be done here, to prevent overwriting possible values written
3559 // to the jdk.module.addmods property by -javaagent and other options.
3560 if (add_modules_value != NULL) {
3561 if (!append_to_addmods_property(add_modules_value)) {
3562 return JNI_ENOMEM;
3563 }
3564 }
3565
3566 Arguments::set_bootclassloader_append_index(((int)strlen(Arguments::get_sysclasspath()))+1);
3567
3568 // This must be done after all arguments have been processed.
3569 // java_compiler() true means set to "NONE" or empty.
3570 if (java_compiler() && !xdebug_mode()) {
3571 // For backwards compatibility, we switch to interpreted mode if
3572 // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3573 // not specified.
3574 set_mode_flags(_int);
3575 }
3576
3577 // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
3578 // but like -Xint, leave compilation thresholds unaffected.
3579 // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
3580 if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
3581 set_mode_flags(_int);
3582 }
3583
4287
4288 // Call get_shared_archive_path() here, after possible SharedArchiveFile option got parsed.
4289 SharedArchivePath = get_shared_archive_path();
4290 if (SharedArchivePath == NULL) {
4291 return JNI_ENOMEM;
4292 }
4293
4294 // Set up VerifySharedSpaces
4295 if (FLAG_IS_DEFAULT(VerifySharedSpaces) && SharedArchiveFile != NULL) {
4296 VerifySharedSpaces = true;
4297 }
4298
4299 // Delay warning until here so that we've had a chance to process
4300 // the -XX:-PrintWarnings flag
4301 if (needs_hotspotrc_warning) {
4302 warning("%s file is present but has been ignored. "
4303 "Run with -XX:Flags=%s to load the file.",
4304 hotspotrc, hotspotrc);
4305 }
4306
4307 if (needs_module_property_warning) {
4308 warning("Ignoring system property options whose names start with '-Djdk.module'."
4309 " They are reserved for internal use.");
4310 }
4311
4312 #if defined(_ALLBSD_SOURCE) || defined(AIX) // UseLargePages is not yet supported on BSD and AIX.
4313 UNSUPPORTED_OPTION(UseLargePages);
4314 #endif
4315
4316 ArgumentsExt::report_unsupported_options();
4317
4318 #ifndef PRODUCT
4319 if (TraceBytecodesAt != 0) {
4320 TraceBytecodes = true;
4321 }
4322 if (CountCompiledCalls) {
4323 if (UseCounterDecay) {
4324 warning("UseCounterDecay disabled because CountCalls is set");
4325 UseCounterDecay = false;
4326 }
4327 }
4328 #endif // PRODUCT
4329
4330 if (ScavengeRootsInCode == 0) {
4331 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
4516 // allocation policy for the eden space.
4517 // Non NUMA-aware collectors such as CMS, G1 and Serial-GC on
4518 // all platforms and ParallelGC on Windows will interleave all
4519 // of the heap spaces across NUMA nodes.
4520 if (FLAG_IS_DEFAULT(UseNUMAInterleaving)) {
4521 FLAG_SET_ERGO(bool, UseNUMAInterleaving, true);
4522 }
4523 }
4524 return JNI_OK;
4525 }
4526
4527 int Arguments::PropertyList_count(SystemProperty* pl) {
4528 int count = 0;
4529 while(pl != NULL) {
4530 count++;
4531 pl = pl->next();
4532 }
4533 return count;
4534 }
4535
4536 // Return the number of readable properties.
4537 int Arguments::PropertyList_readable_count(SystemProperty* pl) {
4538 int count = 0;
4539 while(pl != NULL) {
4540 if (pl->is_readable()) {
4541 count++;
4542 }
4543 pl = pl->next();
4544 }
4545 return count;
4546 }
4547
4548 const char* Arguments::PropertyList_get_value(SystemProperty *pl, const char* key) {
4549 assert(key != NULL, "just checking");
4550 SystemProperty* prop;
4551 for (prop = pl; prop != NULL; prop = prop->next()) {
4552 if (strcmp(key, prop->key()) == 0) return prop->value();
4553 }
4554 return NULL;
4555 }
4556
4557 // Return the value of the requested property provided that it is a readable property.
4558 const char* Arguments::PropertyList_get_readable_value(SystemProperty *pl, const char* key) {
4559 assert(key != NULL, "just checking");
4560 SystemProperty* prop;
4561 // Return the property value if the keys match and the property is not internal or
4562 // it's the special internal property "jdk.boot.class.path.append".
4563 for (prop = pl; prop != NULL; prop = prop->next()) {
4564 if (strcmp(key, prop->key()) == 0) {
4565 if (!prop->internal()) {
4566 return prop->value();
4567 } else if (strcmp(key, "jdk.boot.class.path.append") == 0) {
4568 return prop->value();
4569 } else {
4570 // Property is internal and not jdk.boot.class.path.append so return NULL.
4571 return NULL;
4572 }
4573 }
4574 }
4575 return NULL;
4576 }
4577
4578 const char* Arguments::PropertyList_get_key_at(SystemProperty *pl, int index) {
4579 int count = 0;
4580 const char* ret_val = NULL;
4581
4582 while(pl != NULL) {
4583 if(count >= index) {
4584 ret_val = pl->key();
4585 break;
4586 }
4587 count++;
4588 pl = pl->next();
4589 }
4590
4591 return ret_val;
4592 }
4593
|