arguments.cpp (11947:188971305167) arguments.cpp (11982:ca4cdb0cefb3)
1/*
2 * Copyright (c) 1997, 2016, 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 *

--- 1294 unchanged lines hidden (view full) ---

1303 // SystemProperty copy passed value, thus free previously allocated
1304 // memory
1305 FreeHeap((void *)key);
1306 }
1307
1308 return true;
1309}
1310
1/*
2 * Copyright (c) 1997, 2016, 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 *

--- 1294 unchanged lines hidden (view full) ---

1303 // SystemProperty copy passed value, thus free previously allocated
1304 // memory
1305 FreeHeap((void *)key);
1306 }
1307
1308 return true;
1309}
1310
1311// sets or adds a module name to the jdk.module.addmods property
1312bool Arguments::append_to_addmods_property(const char* module_name) {
1313 const char* key = "jdk.module.addmods";
1314 const char* old_value = Arguments::get_property(key);
1315 size_t buf_len = strlen(key) + strlen(module_name) + 2;
1316 if (old_value != NULL) {
1317 buf_len += strlen(old_value) + 1;
1318 }
1319 char* new_value = AllocateHeap(buf_len, mtArguments);
1320 if (new_value == NULL) {
1321 return false;
1322 }
1323 if (old_value == NULL) {
1324 jio_snprintf(new_value, buf_len, "%s=%s", key, module_name);
1325 } else {
1326 jio_snprintf(new_value, buf_len, "%s=%s,%s", key, old_value, module_name);
1327 }
1328 bool added = add_property(new_value, UnwriteableProperty, InternalProperty);
1329 FreeHeap(new_value);
1330 return added;
1331}
1332
1333#if INCLUDE_CDS
1334void Arguments::check_unsupported_dumping_properties() {
1335 assert(DumpSharedSpaces, "this function is only used with -Xshare:dump");
1336 const char* unsupported_properties[5] = { "jdk.module.main",
1337 "jdk.module.path",
1338 "jdk.module.upgrade.path",
1311#if INCLUDE_CDS
1312void Arguments::check_unsupported_dumping_properties() {
1313 assert(DumpSharedSpaces, "this function is only used with -Xshare:dump");
1314 const char* unsupported_properties[5] = { "jdk.module.main",
1315 "jdk.module.path",
1316 "jdk.module.upgrade.path",
1339 "jdk.module.addmods",
1317 "jdk.module.addmods.0",
1340 "jdk.module.limitmods" };
1341 const char* unsupported_options[5] = { "-m",
1342 "--module-path",
1343 "--upgrade-module-path",
1344 "--add-modules",
1345 "--limit-modules" };
1346 SystemProperty* sp = system_properties();
1347 while (sp != NULL) {

--- 1213 unchanged lines hidden (view full) ---

2561 }
2562 }
2563 }
2564 return false;
2565}
2566
2567unsigned int addreads_count = 0;
2568unsigned int addexports_count = 0;
1318 "jdk.module.limitmods" };
1319 const char* unsupported_options[5] = { "-m",
1320 "--module-path",
1321 "--upgrade-module-path",
1322 "--add-modules",
1323 "--limit-modules" };
1324 SystemProperty* sp = system_properties();
1325 while (sp != NULL) {

--- 1213 unchanged lines hidden (view full) ---

2539 }
2540 }
2541 }
2542 return false;
2543}
2544
2545unsigned int addreads_count = 0;
2546unsigned int addexports_count = 0;
2547unsigned int addmods_count = 0;
2569unsigned int patch_mod_count = 0;
2548unsigned int patch_mod_count = 0;
2570const char* add_modules_value = NULL;
2571
2572bool Arguments::create_property(const char* prop_name, const char* prop_value, PropertyInternal internal) {
2573 size_t prop_len = strlen(prop_name) + strlen(prop_value) + 2;
2574 char* property = AllocateHeap(prop_len, mtArguments);
2575 int ret = jio_snprintf(property, prop_len, "%s=%s", prop_name, prop_value);
2576 if (ret < 0 || ret >= (int)prop_len) {
2577 FreeHeap(property);
2578 return false;

--- 237 unchanged lines hidden (view full) ---

2816 if (!create_numbered_property("jdk.module.addreads", tail, addreads_count++)) {
2817 return JNI_ENOMEM;
2818 }
2819 } else if (match_option(option, "--add-exports=", &tail)) {
2820 if (!create_numbered_property("jdk.module.addexports", tail, addexports_count++)) {
2821 return JNI_ENOMEM;
2822 }
2823 } else if (match_option(option, "--add-modules=", &tail)) {
2549
2550bool Arguments::create_property(const char* prop_name, const char* prop_value, PropertyInternal internal) {
2551 size_t prop_len = strlen(prop_name) + strlen(prop_value) + 2;
2552 char* property = AllocateHeap(prop_len, mtArguments);
2553 int ret = jio_snprintf(property, prop_len, "%s=%s", prop_name, prop_value);
2554 if (ret < 0 || ret >= (int)prop_len) {
2555 FreeHeap(property);
2556 return false;

--- 237 unchanged lines hidden (view full) ---

2794 if (!create_numbered_property("jdk.module.addreads", tail, addreads_count++)) {
2795 return JNI_ENOMEM;
2796 }
2797 } else if (match_option(option, "--add-exports=", &tail)) {
2798 if (!create_numbered_property("jdk.module.addexports", tail, addexports_count++)) {
2799 return JNI_ENOMEM;
2800 }
2801 } else if (match_option(option, "--add-modules=", &tail)) {
2824 add_modules_value = tail;
2802 if (!create_numbered_property("jdk.module.addmods", tail, addmods_count++)) {
2803 return JNI_ENOMEM;
2804 }
2825 } else if (match_option(option, "--limit-modules=", &tail)) {
2826 if (!create_property("jdk.module.limitmods", tail, InternalProperty)) {
2827 return JNI_ENOMEM;
2828 }
2829 } else if (match_option(option, "--module-path=", &tail)) {
2830 if (!create_property("jdk.module.path", tail, ExternalProperty)) {
2831 return JNI_ENOMEM;
2832 }

--- 35 unchanged lines hidden (view full) ---

2868 jio_fprintf(defaultStream::error_stream(),
2869 "Instrumentation agents are not supported in this VM\n");
2870 return JNI_ERR;
2871#else
2872 if (tail != NULL) {
2873 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtArguments), tail);
2874 add_init_agent("instrument", options, false);
2875 // java agents need module java.instrument
2805 } else if (match_option(option, "--limit-modules=", &tail)) {
2806 if (!create_property("jdk.module.limitmods", tail, InternalProperty)) {
2807 return JNI_ENOMEM;
2808 }
2809 } else if (match_option(option, "--module-path=", &tail)) {
2810 if (!create_property("jdk.module.path", tail, ExternalProperty)) {
2811 return JNI_ENOMEM;
2812 }

--- 35 unchanged lines hidden (view full) ---

2848 jio_fprintf(defaultStream::error_stream(),
2849 "Instrumentation agents are not supported in this VM\n");
2850 return JNI_ERR;
2851#else
2852 if (tail != NULL) {
2853 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtArguments), tail);
2854 add_init_agent("instrument", options, false);
2855 // java agents need module java.instrument
2876 if (!Arguments::append_to_addmods_property("java.instrument")) {
2856 if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) {
2877 return JNI_ENOMEM;
2878 }
2879 }
2880#endif // !INCLUDE_JVMTI
2881 // -Xnoclassgc
2882 } else if (match_option(option, "-Xnoclassgc")) {
2883 if (FLAG_SET_CMDLINE(bool, ClassUnloading, false) != Flag::SUCCESS) {
2884 return JNI_EINVAL;

--- 259 unchanged lines hidden (view full) ---

3144 }
3145 // Out of the box management support
3146 if (match_option(option, "-Dcom.sun.management", &tail)) {
3147#if INCLUDE_MANAGEMENT
3148 if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != Flag::SUCCESS) {
3149 return JNI_EINVAL;
3150 }
3151 // management agent in module java.management
2857 return JNI_ENOMEM;
2858 }
2859 }
2860#endif // !INCLUDE_JVMTI
2861 // -Xnoclassgc
2862 } else if (match_option(option, "-Xnoclassgc")) {
2863 if (FLAG_SET_CMDLINE(bool, ClassUnloading, false) != Flag::SUCCESS) {
2864 return JNI_EINVAL;

--- 259 unchanged lines hidden (view full) ---

3124 }
3125 // Out of the box management support
3126 if (match_option(option, "-Dcom.sun.management", &tail)) {
3127#if INCLUDE_MANAGEMENT
3128 if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != Flag::SUCCESS) {
3129 return JNI_EINVAL;
3130 }
3131 // management agent in module java.management
3152 if (!Arguments::append_to_addmods_property("java.management")) {
3132 if (!create_numbered_property("jdk.module.addmods", "java.management", addmods_count++)) {
3153 return JNI_ENOMEM;
3154 }
3155#else
3156 jio_fprintf(defaultStream::output_stream(),
3157 "-Dcom.sun.management is not supported in this VM.\n");
3158 return JNI_ERR;
3159#endif
3160 }

--- 394 unchanged lines hidden (view full) ---

3555 if (dir != NULL) {
3556 jio_fprintf(defaultStream::output_stream(),
3557 "<JAVA_HOME>/lib/ext exists, extensions mechanism no longer supported; "
3558 "Use -classpath instead.\n.");
3559 os::closedir(dir);
3560 return JNI_ERR;
3561 }
3562
3133 return JNI_ENOMEM;
3134 }
3135#else
3136 jio_fprintf(defaultStream::output_stream(),
3137 "-Dcom.sun.management is not supported in this VM.\n");
3138 return JNI_ERR;
3139#endif
3140 }

--- 394 unchanged lines hidden (view full) ---

3535 if (dir != NULL) {
3536 jio_fprintf(defaultStream::output_stream(),
3537 "<JAVA_HOME>/lib/ext exists, extensions mechanism no longer supported; "
3538 "Use -classpath instead.\n.");
3539 os::closedir(dir);
3540 return JNI_ERR;
3541 }
3542
3563 // Append the value of the last --add-modules option specified on the command line.
3564 // This needs to be done here, to prevent overwriting possible values written
3565 // to the jdk.module.addmods property by -javaagent and other options.
3566 if (add_modules_value != NULL) {
3567 if (!append_to_addmods_property(add_modules_value)) {
3568 return JNI_ENOMEM;
3569 }
3570 }
3571
3572 // This must be done after all arguments have been processed.
3573 // java_compiler() true means set to "NONE" or empty.
3574 if (java_compiler() && !xdebug_mode()) {
3575 // For backwards compatibility, we switch to interpreted mode if
3576 // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3577 // not specified.
3578 set_mode_flags(_int);
3579 }

--- 32 unchanged lines hidden (view full) ---

3612#endif
3613
3614#ifndef TIERED
3615 // Tiered compilation is undefined.
3616 UNSUPPORTED_OPTION(TieredCompilation);
3617#endif
3618
3619#if INCLUDE_JVMCI
3543 // This must be done after all arguments have been processed.
3544 // java_compiler() true means set to "NONE" or empty.
3545 if (java_compiler() && !xdebug_mode()) {
3546 // For backwards compatibility, we switch to interpreted mode if
3547 // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3548 // not specified.
3549 set_mode_flags(_int);
3550 }

--- 32 unchanged lines hidden (view full) ---

3583#endif
3584
3585#ifndef TIERED
3586 // Tiered compilation is undefined.
3587 UNSUPPORTED_OPTION(TieredCompilation);
3588#endif
3589
3590#if INCLUDE_JVMCI
3620 if (EnableJVMCI && !append_to_addmods_property("jdk.vm.ci")) {
3591 if (EnableJVMCI &&
3592 !create_numbered_property("jdk.module.addmods", "jdk.vm.ci", addmods_count++)) {
3621 return JNI_ENOMEM;
3622 }
3623#endif
3624
3625 // If we are running in a headless jre, force java.awt.headless property
3626 // to be true unless the property has already been set.
3627 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3628 if (os::is_headless_jre()) {

--- 1089 unchanged lines hidden ---
3593 return JNI_ENOMEM;
3594 }
3595#endif
3596
3597 // If we are running in a headless jre, force java.awt.headless property
3598 // to be true unless the property has already been set.
3599 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3600 if (os::is_headless_jre()) {

--- 1089 unchanged lines hidden ---