Thu, 05 Jan 2012 17:16:13 -0500
Merge
1.1 --- a/src/os/posix/vm/os_posix.cpp Thu Jan 05 17:14:52 2012 -0500 1.2 +++ b/src/os/posix/vm/os_posix.cpp Thu Jan 05 17:16:13 2012 -0500 1.3 @@ -59,6 +59,10 @@ 1.4 VMError::report_coredump_status(buffer, success); 1.5 } 1.6 1.7 +int os::get_last_error() { 1.8 + return errno; 1.9 +} 1.10 + 1.11 bool os::is_debugger_attached() { 1.12 // not implemented 1.13 return false;
2.1 --- a/src/os/windows/vm/os_windows.cpp Thu Jan 05 17:14:52 2012 -0500 2.2 +++ b/src/os/windows/vm/os_windows.cpp Thu Jan 05 17:16:13 2012 -0500 2.3 @@ -132,7 +132,6 @@ 2.4 // save DLL module handle, used by GetModuleFileName 2.5 2.6 HINSTANCE vm_lib_handle; 2.7 -static int getLastErrorString(char *buf, size_t len); 2.8 2.9 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { 2.10 switch (reason) { 2.11 @@ -1452,7 +1451,7 @@ 2.12 return result; 2.13 } 2.14 2.15 - long errcode = GetLastError(); 2.16 + DWORD errcode = GetLastError(); 2.17 if (errcode == ERROR_MOD_NOT_FOUND) { 2.18 strncpy(ebuf, "Can't find dependent libraries", ebuflen-1); 2.19 ebuf[ebuflen-1]='\0'; 2.20 @@ -1463,11 +1462,11 @@ 2.21 // If we can read dll-info and find that dll was built 2.22 // for an architecture other than Hotspot is running in 2.23 // - then print to buffer "DLL was built for a different architecture" 2.24 - // else call getLastErrorString to obtain system error message 2.25 + // else call os::lasterror to obtain system error message 2.26 2.27 // Read system error message into ebuf 2.28 // It may or may not be overwritten below (in the for loop and just above) 2.29 - getLastErrorString(ebuf, (size_t) ebuflen); 2.30 + lasterror(ebuf, (size_t) ebuflen); 2.31 ebuf[ebuflen-1]='\0'; 2.32 int file_descriptor=::open(name, O_RDONLY | O_BINARY, 0); 2.33 if (file_descriptor<0) 2.34 @@ -1500,7 +1499,7 @@ 2.35 ::close(file_descriptor); 2.36 if (failed_to_get_lib_arch) 2.37 { 2.38 - // file i/o error - report getLastErrorString(...) msg 2.39 + // file i/o error - report os::lasterror(...) msg 2.40 return NULL; 2.41 } 2.42 2.43 @@ -1543,7 +1542,7 @@ 2.44 "Didn't find runing architecture code in arch_array"); 2.45 2.46 // If the architure is right 2.47 - // but some other error took place - report getLastErrorString(...) msg 2.48 + // but some other error took place - report os::lasterror(...) msg 2.49 if (lib_arch == running_arch) 2.50 { 2.51 return NULL; 2.52 @@ -1775,12 +1774,12 @@ 2.53 // This method is a copy of JDK's sysGetLastErrorString 2.54 // from src/windows/hpi/src/system_md.c 2.55 2.56 -size_t os::lasterror(char *buf, size_t len) { 2.57 - long errval; 2.58 +size_t os::lasterror(char* buf, size_t len) { 2.59 + DWORD errval; 2.60 2.61 if ((errval = GetLastError()) != 0) { 2.62 - /* DOS error */ 2.63 - int n = (int)FormatMessage( 2.64 + // DOS error 2.65 + size_t n = (size_t)FormatMessage( 2.66 FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, 2.67 NULL, 2.68 errval, 2.69 @@ -1789,7 +1788,7 @@ 2.70 (DWORD)len, 2.71 NULL); 2.72 if (n > 3) { 2.73 - /* Drop final '.', CR, LF */ 2.74 + // Drop final '.', CR, LF 2.75 if (buf[n - 1] == '\n') n--; 2.76 if (buf[n - 1] == '\r') n--; 2.77 if (buf[n - 1] == '.') n--; 2.78 @@ -1799,17 +1798,25 @@ 2.79 } 2.80 2.81 if (errno != 0) { 2.82 - /* C runtime error that has no corresponding DOS error code */ 2.83 - const char *s = strerror(errno); 2.84 + // C runtime error that has no corresponding DOS error code 2.85 + const char* s = strerror(errno); 2.86 size_t n = strlen(s); 2.87 if (n >= len) n = len - 1; 2.88 strncpy(buf, s, n); 2.89 buf[n] = '\0'; 2.90 return n; 2.91 } 2.92 + 2.93 return 0; 2.94 } 2.95 2.96 +int os::get_last_error() { 2.97 + DWORD error = GetLastError(); 2.98 + if (error == 0) 2.99 + error = errno; 2.100 + return (int)error; 2.101 +} 2.102 + 2.103 // sun.misc.Signal 2.104 // NOTE that this is a workaround for an apparent kernel bug where if 2.105 // a signal handler for SIGBREAK is installed then that signal handler 2.106 @@ -4746,7 +4753,7 @@ 2.107 fatal("corrupted C heap"); 2.108 } 2.109 } 2.110 - int err = GetLastError(); 2.111 + DWORD err = GetLastError(); 2.112 if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) { 2.113 fatal(err_msg("heap walk aborted with error %d", err)); 2.114 } 2.115 @@ -4778,45 +4785,6 @@ 2.116 return EXCEPTION_CONTINUE_SEARCH; 2.117 } 2.118 2.119 -static int getLastErrorString(char *buf, size_t len) 2.120 -{ 2.121 - long errval; 2.122 - 2.123 - if ((errval = GetLastError()) != 0) 2.124 - { 2.125 - /* DOS error */ 2.126 - size_t n = (size_t)FormatMessage( 2.127 - FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, 2.128 - NULL, 2.129 - errval, 2.130 - 0, 2.131 - buf, 2.132 - (DWORD)len, 2.133 - NULL); 2.134 - if (n > 3) { 2.135 - /* Drop final '.', CR, LF */ 2.136 - if (buf[n - 1] == '\n') n--; 2.137 - if (buf[n - 1] == '\r') n--; 2.138 - if (buf[n - 1] == '.') n--; 2.139 - buf[n] = '\0'; 2.140 - } 2.141 - return (int)n; 2.142 - } 2.143 - 2.144 - if (errno != 0) 2.145 - { 2.146 - /* C runtime error that has no corresponding DOS error code */ 2.147 - const char *s = strerror(errno); 2.148 - size_t n = strlen(s); 2.149 - if (n >= len) n = len - 1; 2.150 - strncpy(buf, s, n); 2.151 - buf[n] = '\0'; 2.152 - return (int)n; 2.153 - } 2.154 - return 0; 2.155 -} 2.156 - 2.157 - 2.158 // We don't build a headless jre for Windows 2.159 bool os::is_headless_jre() { return false; } 2.160
3.1 --- a/src/share/vm/classfile/classFileParser.cpp Thu Jan 05 17:14:52 2012 -0500 3.2 +++ b/src/share/vm/classfile/classFileParser.cpp Thu Jan 05 17:16:13 2012 -0500 3.3 @@ -2664,18 +2664,23 @@ 3.4 _max_bootstrap_specifier_index = -1; 3.5 3.6 if (JvmtiExport::should_post_class_file_load_hook()) { 3.7 - // Get the cached class file bytes (if any) from the 3.8 - // class that is being redefined. 3.9 - JvmtiThreadState *state = JvmtiThreadState::state_for(jt); 3.10 - KlassHandle *h_class_being_redefined = 3.11 - state->get_class_being_redefined(); 3.12 - if (h_class_being_redefined != NULL) { 3.13 - instanceKlassHandle ikh_class_being_redefined = 3.14 - instanceKlassHandle(THREAD, (*h_class_being_redefined)()); 3.15 - cached_class_file_bytes = 3.16 - ikh_class_being_redefined->get_cached_class_file_bytes(); 3.17 - cached_class_file_length = 3.18 - ikh_class_being_redefined->get_cached_class_file_len(); 3.19 + // Get the cached class file bytes (if any) from the class that 3.20 + // is being redefined or retransformed. We use jvmti_thread_state() 3.21 + // instead of JvmtiThreadState::state_for(jt) so we don't allocate 3.22 + // a JvmtiThreadState any earlier than necessary. This will help 3.23 + // avoid the bug described by 7126851. 3.24 + JvmtiThreadState *state = jt->jvmti_thread_state(); 3.25 + if (state != NULL) { 3.26 + KlassHandle *h_class_being_redefined = 3.27 + state->get_class_being_redefined(); 3.28 + if (h_class_being_redefined != NULL) { 3.29 + instanceKlassHandle ikh_class_being_redefined = 3.30 + instanceKlassHandle(THREAD, (*h_class_being_redefined)()); 3.31 + cached_class_file_bytes = 3.32 + ikh_class_being_redefined->get_cached_class_file_bytes(); 3.33 + cached_class_file_length = 3.34 + ikh_class_being_redefined->get_cached_class_file_len(); 3.35 + } 3.36 } 3.37 3.38 unsigned char* ptr = cfs->buffer();
4.1 --- a/src/share/vm/runtime/os.hpp Thu Jan 05 17:14:52 2012 -0500 4.2 +++ b/src/share/vm/runtime/os.hpp Thu Jan 05 17:16:13 2012 -0500 4.3 @@ -502,6 +502,7 @@ 4.4 4.5 static void print_location(outputStream* st, intptr_t x, bool verbose = false); 4.6 static size_t lasterror(char *buf, size_t len); 4.7 + static int get_last_error(); 4.8 4.9 // Determines whether the calling process is being debugged by a user-mode debugger. 4.10 static bool is_debugger_attached();
5.1 --- a/src/share/vm/services/threadService.cpp Thu Jan 05 17:14:52 2012 -0500 5.2 +++ b/src/share/vm/services/threadService.cpp Thu Jan 05 17:16:13 2012 -0500 5.3 @@ -377,7 +377,7 @@ 5.4 } 5.5 5.6 } 5.7 - 5.8 + delete cycle; 5.9 return deadlocks; 5.10 } 5.11