8159799: Tests using jcmd fails intermittently with Could not open PerfMemory on Windows
authorctornqvi
Tue, 18 Oct 2016 06:17:10 -0400
changeset 41721 cfcaf7b4d7ac
parent 41720 93c64aa0b62f
child 41722 07042d1b3876
8159799: Tests using jcmd fails intermittently with Could not open PerfMemory on Windows Reviewed-by: gtriantafill, dholmes, sla, fparain
hotspot/src/os/windows/vm/perfMemory_windows.cpp
--- a/hotspot/src/os/windows/vm/perfMemory_windows.cpp	Tue Oct 18 06:14:10 2016 -0400
+++ b/hotspot/src/os/windows/vm/perfMemory_windows.cpp	Tue Oct 18 06:17:10 2016 -0400
@@ -1404,12 +1404,14 @@
                objectname);      /* name for object */
 
   if (fmh == NULL) {
+    DWORD lasterror = GetLastError();
     if (PrintMiscellaneous && Verbose) {
       warning("OpenFileMapping failed for shared memory object %s:"
-              " lasterror = %d\n", objectname, GetLastError());
+              " lasterror = %d\n", objectname, lasterror);
     }
-    THROW_MSG_(vmSymbols::java_lang_Exception(),
-               "Could not open PerfMemory", INVALID_HANDLE_VALUE);
+    THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+               err_msg("Could not open PerfMemory, error %d", lasterror),
+               INVALID_HANDLE_VALUE);
   }
 
   return fmh;;