src/share/vm/runtime/arguments.cpp

Print this page




1889   }
1890   jio_fprintf(defaultStream::error_stream(),
1891               "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
1892               name, value);
1893   return false;
1894 }
1895 
1896 #if !INCLUDE_ALL_GCS
1897 #ifdef ASSERT
1898 static bool verify_serial_gc_flags() {
1899   return (UseSerialGC &&
1900         !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1901           UseParallelGC || UseParallelOldGC));
1902 }
1903 #endif // ASSERT
1904 #endif // INCLUDE_ALL_GCS
1905 
1906 // check if do gclog rotation
1907 // +UseGCLogFileRotation is a must,
1908 // no gc log rotation when log file not supplied or
1909 // NumberOfGCLogFiles is 0, or GCLogFileSize is 0
1910 void check_gclog_consistency() {
1911   if (UseGCLogFileRotation) {
1912     if ((Arguments::gc_log_filename() == NULL) ||
1913         (NumberOfGCLogFiles == 0)  ||
1914         (GCLogFileSize == 0)) {
1915       jio_fprintf(defaultStream::output_stream(),
1916                   "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>[k|K|m|M|g|G]\n"
1917                   "where num_of_file > 0 and num_of_size > 0\n"
1918                   "GC log rotation is turned off\n");
1919       UseGCLogFileRotation = false;
1920     }
1921   }
1922 
1923   if (UseGCLogFileRotation && GCLogFileSize < 8*K) {
1924         FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
1925         jio_fprintf(defaultStream::output_stream(),
1926                     "GCLogFileSize changed to minimum 8K\n");
1927   }
1928 }
1929 
1930 // This function is called for -Xloggc:<filename>, it can be used
1931 // to check if a given file name(or string) conforms to the following
1932 // specification:
1933 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
1934 // %p and %t only allowed once. We only limit usage of filename not path
1935 bool is_filename_valid(const char *file_name) {
1936   const char* p = file_name;
1937   char file_sep = os::file_separator()[0];
1938   const char* cp;
1939   // skip prefix path
1940   for (cp = file_name; *cp != '\0'; cp++) {
1941     if (*cp == '/' || *cp == file_sep) {
1942       p = cp + 1;
1943     }




1889   }
1890   jio_fprintf(defaultStream::error_stream(),
1891               "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
1892               name, value);
1893   return false;
1894 }
1895 
1896 #if !INCLUDE_ALL_GCS
1897 #ifdef ASSERT
1898 static bool verify_serial_gc_flags() {
1899   return (UseSerialGC &&
1900         !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1901           UseParallelGC || UseParallelOldGC));
1902 }
1903 #endif // ASSERT
1904 #endif // INCLUDE_ALL_GCS
1905 
1906 // check if do gclog rotation
1907 // +UseGCLogFileRotation is a must,
1908 // no gc log rotation when log file not supplied or
1909 // NumberOfGCLogFiles is 0
1910 void check_gclog_consistency() {
1911   if (UseGCLogFileRotation) {
1912     if ((Arguments::gc_log_filename() == NULL) || (NumberOfGCLogFiles == 0)) {


1913       jio_fprintf(defaultStream::output_stream(),
1914                   "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files>\n"
1915                   "where num_of_file > 0\n"
1916                   "GC log rotation is turned off\n");
1917       UseGCLogFileRotation = false;
1918     }
1919   }
1920 
1921   if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) {
1922     FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
1923     jio_fprintf(defaultStream::output_stream(),
1924                 "GCLogFileSize changed to minimum 8K\n");
1925   }
1926 }
1927 
1928 // This function is called for -Xloggc:<filename>, it can be used
1929 // to check if a given file name(or string) conforms to the following
1930 // specification:
1931 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
1932 // %p and %t only allowed once. We only limit usage of filename not path
1933 bool is_filename_valid(const char *file_name) {
1934   const char* p = file_name;
1935   char file_sep = os::file_separator()[0];
1936   const char* cp;
1937   // skip prefix path
1938   for (cp = file_name; *cp != '\0'; cp++) {
1939     if (*cp == '/' || *cp == file_sep) {
1940       p = cp + 1;
1941     }