--- old/src/share/vm/runtime/arguments.cpp 2019-02-15 19:02:39.798750504 +0300 +++ new/src/share/vm/runtime/arguments.cpp 2019-02-15 19:02:39.670754976 +0300 @@ -44,6 +44,9 @@ #include "utilities/macros.hpp" #include "utilities/stringUtils.hpp" #include "utilities/taskqueue.hpp" +#if INCLUDE_JFR +#include "jfr/jfr.hpp" +#endif #ifdef TARGET_OS_FAMILY_linux # include "os_linux.inline.hpp" #endif @@ -151,6 +154,20 @@ } } +#if INCLUDE_JFR +// return true on failure +static bool match_jfr_option(const JavaVMOption** option) { + assert((*option)->optionString != NULL, "invariant"); + char* tail = NULL; + if (match_option(*option, "-XX:StartFlightRecording", (const char**)&tail)) { + return Jfr::on_start_flight_recording_option(option, tail); + } else if (match_option(*option, "-XX:FlightRecorderOptions", (const char**)&tail)) { + return Jfr::on_flight_recorder_option(option, tail); + } + return false; +} +#endif + static void logOption(const char* opt) { if (PrintVMOptions) { jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt); @@ -552,8 +569,7 @@ /* Scan the directory for jars/zips, appending them to path. */ struct dirent *entry; - char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal); - while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { + while ((entry = os::readdir(dir)) != NULL) { const char* name = entry->d_name; const char* ext = name + strlen(name) - 4; bool isJarOrZip = ext > name && @@ -567,7 +583,6 @@ FREE_C_HEAP_ARRAY(char, jarpath, mtInternal); } } - FREE_C_HEAP_ARRAY(char, dbuf, mtInternal); os::closedir(dir); return path; } @@ -3397,6 +3412,10 @@ "ManagementServer is not supported in this VM.\n"); return JNI_ERR; #endif // INCLUDE_MANAGEMENT +#if INCLUDE_JFR + } else if (match_jfr_option(&option)) { + return JNI_EINVAL; +#endif } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx // Skip -XX:Flags= since that case has already been handled if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) { @@ -3481,14 +3500,12 @@ if (dir == NULL) return false; struct dirent *entry; - char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal); bool hasJarFile = false; - while (!hasJarFile && (entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { + while (!hasJarFile && (entry = os::readdir(dir)) != NULL) { const char* name = entry->d_name; const char* ext = name + strlen(name) - 4; hasJarFile = ext > name && (os::file_name_strcmp(ext, ".jar") == 0); } - FREE_C_HEAP_ARRAY(char, dbuf, mtInternal); os::closedir(dir); return hasJarFile ; } @@ -3570,8 +3587,7 @@ if (dir != NULL) { int num_ext_jars = 0; struct dirent *entry; - char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(extDir), mtInternal); - while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { + while ((entry = os::readdir(dir)) != NULL) { const char* name = entry->d_name; const char* ext = name + strlen(name) - 4; if (ext > name && (os::file_name_strcmp(ext, ".jar") == 0)) { @@ -3590,7 +3606,6 @@ } } } - FREE_C_HEAP_ARRAY(char, dbuf, mtInternal); os::closedir(dir); if (num_ext_jars > 0) { nonEmptyDirs += 1;