< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/symbolTable.hpp"
  29 #include "compiler/compilerOracle.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "memory/cardTableRS.hpp"
  32 #include "memory/genCollectedHeap.hpp"
  33 #include "memory/referenceProcessor.hpp"
  34 #include "memory/universe.inline.hpp"
  35 #include "oops/oop.inline.hpp"
  36 #include "prims/jvmtiExport.hpp"
  37 #include "runtime/arguments.hpp"
  38 #include "runtime/arguments_ext.hpp"
  39 #include "runtime/globals_extension.hpp"
  40 #include "runtime/java.hpp"
  41 #include "services/management.hpp"
  42 #include "services/memTracker.hpp"
  43 #include "utilities/defaultStream.hpp"
  44 #include "utilities/macros.hpp"
  45 #include "utilities/stringUtils.hpp"
  46 #include "utilities/taskqueue.hpp"



  47 #ifdef TARGET_OS_FAMILY_linux
  48 # include "os_linux.inline.hpp"
  49 #endif
  50 #ifdef TARGET_OS_FAMILY_solaris
  51 # include "os_solaris.inline.hpp"
  52 #endif
  53 #ifdef TARGET_OS_FAMILY_windows
  54 # include "os_windows.inline.hpp"
  55 #endif
  56 #ifdef TARGET_OS_FAMILY_aix
  57 # include "os_aix.inline.hpp"
  58 #endif
  59 #ifdef TARGET_OS_FAMILY_bsd
  60 # include "os_bsd.inline.hpp"
  61 #endif
  62 #if INCLUDE_ALL_GCS
  63 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
  64 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  65 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
  66 #endif // INCLUDE_ALL_GCS


 138 SystemProperty *Arguments::_java_home = NULL;
 139 SystemProperty *Arguments::_java_class_path = NULL;
 140 SystemProperty *Arguments::_sun_boot_class_path = NULL;
 141 
 142 char* Arguments::_meta_index_path = NULL;
 143 char* Arguments::_meta_index_dir = NULL;
 144 
 145 // Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string
 146 
 147 static bool match_option(const JavaVMOption *option, const char* name,
 148                          const char** tail) {
 149   int len = (int)strlen(name);
 150   if (strncmp(option->optionString, name, len) == 0) {
 151     *tail = option->optionString + len;
 152     return true;
 153   } else {
 154     return false;
 155   }
 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 // Process java launcher properties.
 165 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
 166   // See if sun.java.launcher or sun.java.launcher.pid is defined.
 167   // Must do this before setting up other system properties,
 168   // as some of them may depend on launcher type.
 169   for (int index = 0; index < args->nOptions; index++) {
 170     const JavaVMOption* option = args->options + index;
 171     const char* tail;
 172 
 173     if (match_option(option, "-Dsun.java.launcher=", &tail)) {
 174       process_java_launcher_argument(tail, option->extraInfo);
 175       continue;
 176     }
 177     if (match_option(option, "-Dsun.java.launcher.pid=", &tail)) {


3382       ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3383       if (errcode != arg_in_range) {
3384         jio_fprintf(defaultStream::error_stream(),
3385                     "Invalid maximum direct memory size: %s\n",
3386                     option->optionString);
3387         describe_range_error(errcode);
3388         return JNI_EINVAL;
3389       }
3390       FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3391     } else if (match_option(option, "-XX:+UseVMInterruptibleIO", &tail)) {
3392       // NOTE! In JDK 9, the UseVMInterruptibleIO flag will completely go
3393       //       away and will cause VM initialization failures!
3394       warning("-XX:+UseVMInterruptibleIO is obsolete and will be removed in a future release.");
3395       FLAG_SET_CMDLINE(bool, UseVMInterruptibleIO, true);
3396 #if !INCLUDE_MANAGEMENT
3397     } else if (match_option(option, "-XX:+ManagementServer", &tail)) {
3398         jio_fprintf(defaultStream::error_stream(),
3399           "ManagementServer is not supported in this VM.\n");
3400         return JNI_ERR;
3401 #endif // INCLUDE_MANAGEMENT




3402     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3403       // Skip -XX:Flags= since that case has already been handled
3404       if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
3405         if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3406           return JNI_EINVAL;
3407         }
3408       }
3409     // Unknown option
3410     } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3411       return JNI_ERR;
3412     }
3413   }
3414 
3415   // PrintSharedArchiveAndExit will turn on
3416   //   -Xshare:on
3417   //   -XX:+TraceClassPaths
3418   if (PrintSharedArchiveAndExit) {
3419     FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
3420     FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
3421     FLAG_SET_CMDLINE(bool, TraceClassPaths, true);




  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/symbolTable.hpp"
  29 #include "compiler/compilerOracle.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "memory/cardTableRS.hpp"
  32 #include "memory/genCollectedHeap.hpp"
  33 #include "memory/referenceProcessor.hpp"
  34 #include "memory/universe.inline.hpp"
  35 #include "oops/oop.inline.hpp"
  36 #include "prims/jvmtiExport.hpp"
  37 #include "runtime/arguments.hpp"
  38 #include "runtime/arguments_ext.hpp"
  39 #include "runtime/globals_extension.hpp"
  40 #include "runtime/java.hpp"
  41 #include "services/management.hpp"
  42 #include "services/memTracker.hpp"
  43 #include "utilities/defaultStream.hpp"
  44 #include "utilities/macros.hpp"
  45 #include "utilities/stringUtils.hpp"
  46 #include "utilities/taskqueue.hpp"
  47 #if INCLUDE_JFR
  48 #include "jfr/jfr.hpp"
  49 #endif
  50 #ifdef TARGET_OS_FAMILY_linux
  51 # include "os_linux.inline.hpp"
  52 #endif
  53 #ifdef TARGET_OS_FAMILY_solaris
  54 # include "os_solaris.inline.hpp"
  55 #endif
  56 #ifdef TARGET_OS_FAMILY_windows
  57 # include "os_windows.inline.hpp"
  58 #endif
  59 #ifdef TARGET_OS_FAMILY_aix
  60 # include "os_aix.inline.hpp"
  61 #endif
  62 #ifdef TARGET_OS_FAMILY_bsd
  63 # include "os_bsd.inline.hpp"
  64 #endif
  65 #if INCLUDE_ALL_GCS
  66 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
  67 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  68 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
  69 #endif // INCLUDE_ALL_GCS


 141 SystemProperty *Arguments::_java_home = NULL;
 142 SystemProperty *Arguments::_java_class_path = NULL;
 143 SystemProperty *Arguments::_sun_boot_class_path = NULL;
 144 
 145 char* Arguments::_meta_index_path = NULL;
 146 char* Arguments::_meta_index_dir = NULL;
 147 
 148 // Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string
 149 
 150 static bool match_option(const JavaVMOption *option, const char* name,
 151                          const char** tail) {
 152   int len = (int)strlen(name);
 153   if (strncmp(option->optionString, name, len) == 0) {
 154     *tail = option->optionString + len;
 155     return true;
 156   } else {
 157     return false;
 158   }
 159 }
 160 
 161 #if INCLUDE_JFR
 162 // return true on failure
 163 static bool match_jfr_option(const JavaVMOption** option) {
 164   assert((*option)->optionString != NULL, "invariant");
 165   char* tail = NULL;
 166   if (match_option(*option, "-XX:StartFlightRecording", (const char**)&tail)) {
 167     return Jfr::on_start_flight_recording_option(option, tail);
 168   } else if (match_option(*option, "-XX:FlightRecorderOptions", (const char**)&tail)) {
 169     return Jfr::on_flight_recorder_option(option, tail);
 170   }
 171   return false;
 172 }
 173 #endif
 174 
 175 static void logOption(const char* opt) {
 176   if (PrintVMOptions) {
 177     jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt);
 178   }
 179 }
 180 
 181 // Process java launcher properties.
 182 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
 183   // See if sun.java.launcher or sun.java.launcher.pid is defined.
 184   // Must do this before setting up other system properties,
 185   // as some of them may depend on launcher type.
 186   for (int index = 0; index < args->nOptions; index++) {
 187     const JavaVMOption* option = args->options + index;
 188     const char* tail;
 189 
 190     if (match_option(option, "-Dsun.java.launcher=", &tail)) {
 191       process_java_launcher_argument(tail, option->extraInfo);
 192       continue;
 193     }
 194     if (match_option(option, "-Dsun.java.launcher.pid=", &tail)) {


3399       ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3400       if (errcode != arg_in_range) {
3401         jio_fprintf(defaultStream::error_stream(),
3402                     "Invalid maximum direct memory size: %s\n",
3403                     option->optionString);
3404         describe_range_error(errcode);
3405         return JNI_EINVAL;
3406       }
3407       FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3408     } else if (match_option(option, "-XX:+UseVMInterruptibleIO", &tail)) {
3409       // NOTE! In JDK 9, the UseVMInterruptibleIO flag will completely go
3410       //       away and will cause VM initialization failures!
3411       warning("-XX:+UseVMInterruptibleIO is obsolete and will be removed in a future release.");
3412       FLAG_SET_CMDLINE(bool, UseVMInterruptibleIO, true);
3413 #if !INCLUDE_MANAGEMENT
3414     } else if (match_option(option, "-XX:+ManagementServer", &tail)) {
3415         jio_fprintf(defaultStream::error_stream(),
3416           "ManagementServer is not supported in this VM.\n");
3417         return JNI_ERR;
3418 #endif // INCLUDE_MANAGEMENT
3419 #if INCLUDE_JFR
3420     } else if (match_jfr_option(&option)) {
3421       return JNI_EINVAL;
3422 #endif
3423     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3424       // Skip -XX:Flags= since that case has already been handled
3425       if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
3426         if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3427           return JNI_EINVAL;
3428         }
3429       }
3430     // Unknown option
3431     } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3432       return JNI_ERR;
3433     }
3434   }
3435 
3436   // PrintSharedArchiveAndExit will turn on
3437   //   -Xshare:on
3438   //   -XX:+TraceClassPaths
3439   if (PrintSharedArchiveAndExit) {
3440     FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
3441     FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
3442     FLAG_SET_CMDLINE(bool, TraceClassPaths, true);


< prev index next >