changeset 5587:178c480998b1

7168110: Misleading jstack error message Reviewed-by: alanb, dsamersoff
author robm
date Thu, 17 May 2012 22:42:32 +0100
parents ce165aa48dcb
children 9fe6ebbe5895
files src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c	Thu May 17 06:26:05 2012 -0700
+++ b/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c	Thu May 17 22:42:32 2012 +0100
@@ -466,7 +466,17 @@
         }
         CloseHandle(hThread);
     } else {
-        JNU_ThrowIOExceptionWithLastError(env, "CreateRemoteThread failed");
+        if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
+            //
+            // This error will occur when attaching to a process belonging to
+            // another terminal session. See "Remarks":
+            // http://msdn.microsoft.com/en-us/library/ms682437%28VS.85%29.aspx
+            //
+            JNU_ThrowIOException(env,
+                "Insufficient memory or insufficient privileges to attach");
+        } else {
+            JNU_ThrowIOExceptionWithLastError(env, "CreateRemoteThread failed");
+        }
     }
 
     VirtualFreeEx(hProcess, pCode, 0, MEM_RELEASE);