Changeset 195
- Timestamp:
- Dec 7, 2010, 7:57:56 PM (15 years ago)
- Location:
- trunk/openjdk/jdk/src/windows
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/openjdk/jdk/src/windows/javavm/export/jni_md.h
r66 r195 39 39 typedef signed char jbyte; 40 40 41 #ifdef __cplusplus 42 43 /* template for safe type casting: the generic version lets the compiler 44 * decide (as if no template was used); specific instantiations deal with 45 * special cases which are guaranteed to be safe */ 46 template<typename TR, typename TS> 47 inline TR jsafe_cast(TS ts) { return ts; } 48 49 #ifdef __EMX__ 50 /* sizeof(jchar) = sizeof(wchar_t) in GCC but the types are not relative 51 * (as opposed to MSVC) so an explicit cast is required */ 52 typedef unsigned short jchar; 53 template<> 54 inline jchar *jsafe_cast<jchar *, wchar_t *>(wchar_t *ts) { return reinterpret_cast<jchar*>(ts); } 55 template<> 56 inline const jchar *jsafe_cast<const jchar *, wchar_t *>(wchar_t *ts) { return reinterpret_cast<const jchar*>(ts); } 57 template<> 58 inline const jchar *jsafe_cast<const jchar *, const wchar_t *>(const wchar_t *ts) { return reinterpret_cast<const jchar*>(ts); } 59 template<> 60 inline wchar_t *jsafe_cast<wchar_t *, jchar *>(jchar *ts) { return reinterpret_cast<wchar_t*>(ts); } 61 template<> 62 inline const wchar_t *jsafe_cast<const wchar_t *, jchar *>(jchar *ts) { return reinterpret_cast<const wchar_t*>(ts); } 63 template<> 64 inline const wchar_t *jsafe_cast<const wchar_t *, const jchar *>(const jchar *ts) { return reinterpret_cast<const wchar_t*>(ts); } 65 #endif 66 67 #endif /* __cplusplus */ 68 41 69 #endif /* !_JAVASOFT_JNI_MD_H_ */ -
trunk/openjdk/jdk/src/windows/native/sun/windows/ShellFolder2.cpp
r193 r195 181 181 (CHAR*)pidl + pStrret->uOffset); 182 182 case STRRET_WSTR : 183 return env->NewString( reinterpret_cast<const jchar*>(pStrret->pOleStr),183 return env->NewString(jsafe_cast<const jchar*>(pStrret->pOleStr), 184 184 static_cast<jsize>(wcslen(pStrret->pOleStr))); 185 185 } … … 188 188 // restoring the original definition 189 189 #define JNU_NewStringPlatform(env, x) \ 190 env->NewString( reinterpret_cast<const jchar*>(x), \191 static_cast<jsize>(_tcslen( reinterpret_cast<const WCHAR*>(x))))190 env->NewString(jsafe_cast<const jchar*>(x), \ 191 static_cast<jsize>(_tcslen(jsafe_cast<const WCHAR*>(x)))) 192 192 193 193 /* … … 729 729 jchar* wszPath = new jchar[nLength + 1]; 730 730 const jchar* strPath = env->GetStringChars(jname, NULL); 731 wcsncpy( reinterpret_cast<wchar_t*>(wszPath), reinterpret_cast<const wchar_t*>(strPath), nLength);731 wcsncpy(jsafe_cast<wchar_t*>(wszPath), jsafe_cast<const wchar_t*>(strPath), nLength); 732 732 wszPath[nLength] = 0; 733 733 HRESULT res = pIShellFolder->ParseDisplayName(NULL, NULL, 734 reinterpret_cast<WCHAR*>(wszPath), NULL, &pIDL, NULL);734 jsafe_cast<WCHAR*>(wszPath), NULL, &pIDL, NULL); 735 735 if (res != S_OK) { 736 736 JNU_ThrowIOException(env, "Could not parse name"); … … 775 775 { 776 776 SHFILEINFO fileInfo; 777 if (fn_SHGetFileInfo( (LPCTSTR)pIDL, 0L, &fileInfo, sizeof(fileInfo),777 if (fn_SHGetFileInfo(reinterpret_cast<LPCTSTR>(pIDL), 0L, &fileInfo, sizeof(fileInfo), 778 778 SHGFI_TYPENAME | SHGFI_PIDL) == 0) { 779 779 return NULL; … … 791 791 { 792 792 TCHAR szBuf[MAX_PATH]; 793 LPCTSTR szPath = (LPCTSTR)JNU_GetStringPlatformChars(env, path, NULL);793 LPCTSTR szPath = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, path, NULL)); 794 794 if (szPath == NULL) { 795 795 return NULL; … … 814 814 HICON hIcon = NULL; 815 815 SHFILEINFO fileInfo; 816 LPCTSTR pathStr = (LPCTSTR)JNU_GetStringPlatformChars(env, absolutePath, NULL);816 LPCTSTR pathStr = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, absolutePath, NULL)); 817 817 if (fn_SHGetFileInfo(pathStr, 0L, &fileInfo, sizeof(fileInfo), 818 818 SHGFI_ICON | (getLargeIcon ? 0 : SHGFI_SMALLICON)) != 0) { … … 1018 1018 if (libShell32 != NULL) { 1019 1019 hBitmap = (HBITMAP)LoadImage(libShell32, 1020 isVista ? TEXT("IDB_TB_SH_DEF_16") : (LPCTSTR)MAKEINTRESOURCE(216),1020 isVista ? TEXT("IDB_TB_SH_DEF_16") : MAKEINTRESOURCE(216), 1021 1021 IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); 1022 1022 } … … 1024 1024 libComCtl32 = LoadLibrary(TEXT("comctl32.dll")); 1025 1025 if (libComCtl32 != NULL) { 1026 hBitmap = (HBITMAP)LoadImage(libComCtl32, (LPCTSTR)MAKEINTRESOURCE(124),1026 hBitmap = (HBITMAP)LoadImage(libComCtl32, MAKEINTRESOURCE(124), 1027 1027 IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); 1028 1028 } … … 1032 1032 } 1033 1033 1034 GetObject(hBitmap, sizeof(bm), (LPSTR)&bm);1034 GetObject(hBitmap, sizeof(bm), reinterpret_cast<LPSTR>(&bm)); 1035 1035 1036 1036 // Get the screen DC … … 1088 1088 (JNIEnv* env, jclass cls, jint iconID) 1089 1089 { 1090 return (jlong)LoadIcon(NULL, (LPCTSTR)MAKEINTRESOURCE(iconID));1090 return (jlong)LoadIcon(NULL, MAKEINTRESOURCE(iconID)); 1091 1091 } 1092 1092 … … 1101 1101 jint cxDesired, jint cyDesired, jboolean useVGAColors) 1102 1102 { 1103 HINSTANCE libHandle = LoadLibrary( reinterpret_cast<const WCHAR*>(env->GetStringChars(libName, NULL)));1103 HINSTANCE libHandle = LoadLibrary(jsafe_cast<const WCHAR*>(env->GetStringChars(libName, NULL))); 1104 1104 if (libHandle != NULL) { 1105 1105 UINT fuLoad = (useVGAColors && !isXP) ? LR_VGACOLOR : 0; 1106 return ptr_to_jlong(LoadImage(libHandle, (LPCTSTR)MAKEINTRESOURCE(iconID),1106 return ptr_to_jlong(LoadImage(libHandle, MAKEINTRESOURCE(iconID), 1107 1107 IMAGE_ICON, cxDesired, cyDesired, 1108 1108 fuLoad)); -
trunk/openjdk/jdk/src/windows/native/sun/windows/ThemeReader.cpp
r2 r195 251 251 lastError, 252 252 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 253 (LPSTR)&msgBuffer,253 reinterpret_cast<LPSTR>(&msgBuffer), 254 254 // it's an output parameter when allocate buffer is used 255 255 0, … … 271 271 (JNIEnv *env, jclass klass, jstring widget) { 272 272 273 LPCTSTR str = (LPCTSTR) JNU_GetStringPlatformChars(env, widget, NULL);273 LPCTSTR str = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, widget, NULL)); 274 274 // We need to open the Theme on a Window that will stick around. 275 275 // The best one for that purpose is the Toolkit window. … … 289 289 LPCTSTR str = NULL; 290 290 if (subAppName != NULL) { 291 str = (LPCTSTR) JNU_GetStringPlatformChars(env, subAppName, NULL);291 str = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, subAppName, NULL)); 292 292 } 293 293 // We need to set the Window theme on the same theme that we opened it with. -
trunk/openjdk/jdk/src/windows/native/sun/windows/UnicowsLoader.cpp
r193 r195 78 78 // initialization. 79 79 HMODULE hmodAWT = GetModuleHandleA("awt"); 80 LPSTR abspath = (LPSTR)safe_Malloc(MAX_PATH);80 LPSTR abspath = static_cast<LPSTR>(safe_Malloc(MAX_PATH)); 81 81 if (abspath != NULL) { 82 82 GetModuleFileNameA(hmodAWT, abspath, MAX_PATH); … … 161 161 const DWORD num) 162 162 { 163 LPWSTR pwstrbuf = (LPWSTR)(pi1W + num);163 LPWSTR pwstrbuf = reinterpret_cast<LPWSTR>(pi1W + num); 164 164 DWORD current; 165 165 … … 223 223 const DWORD num) 224 224 { 225 LPWSTR pbuf = (LPWSTR)(pi5W + num);225 LPWSTR pbuf = reinterpret_cast<LPWSTR>(pi5W + num); 226 226 DWORD current; 227 227 … … 337 337 if (Name != NULL) { 338 338 DWORD len = static_cast<DWORD>(wcslen(Name)) + 1; 339 pNameA = (LPSTR)safe_Malloc(len);339 pNameA = static_cast<LPSTR>(safe_Malloc(len)); 340 340 ::WideCharToMultiByte(CP_ACP, 0, Name, -1, pNameA, len, NULL, NULL); 341 341 } -
trunk/openjdk/jdk/src/windows/native/sun/windows/UnicowsLoader.h
r187 r195 77 77 // to proper JNI functions. 78 78 #ifdef __WIN32OS2__ 79 #define JNU_NewStringPlatform(env, x) env->NewString( reinterpret_cast<const jchar*>(x), static_cast<jsize>(_tcslen(reinterpret_cast<LPCTSTR>(x))))80 #define JNU_GetStringPlatformChars(env, x, y) (LPWSTR)env->GetStringChars(x, y)81 #define JNU_ReleaseStringPlatformChars(env, x, y) env->ReleaseStringChars(x, reinterpret_cast<const jchar*>(y))79 #define JNU_NewStringPlatform(env, x) env->NewString(jsafe_cast<const jchar*>(x), static_cast<jsize>(_tcslen(jsafe_cast<LPCWSTR>(x)))) 80 #define JNU_GetStringPlatformChars(env, x, y) jsafe_cast<LPCWSTR>(env->GetStringChars(x, y)) 81 #define JNU_ReleaseStringPlatformChars(env, x, y) env->ReleaseStringChars(x, jsafe_cast<const jchar*>(y)) 82 82 #else 83 83 #define JNU_NewStringPlatform(env, x) env->NewString(x, static_cast<jsize>(_tcslen(x))) 84 #define JNU_GetStringPlatformChars(env, x, y) (LPWSTR)env->GetStringChars(x, y)84 #define JNU_GetStringPlatformChars(env, x, y) jsafe_cast<LPWSTR>(env->GetStringChars(x, y)) 85 85 #define JNU_ReleaseStringPlatformChars(env, x, y) env->ReleaseStringChars(x, y) 86 86 #endif -
trunk/openjdk/jdk/src/windows/native/sun/windows/WPrinterJob.cpp
r184 r195 141 141 } 142 142 143 pPrinterName = (LPTSTR)GlobalAlloc(GPTR, (index+1)*sizeof(TCHAR));143 pPrinterName = static_cast<LPTSTR>(GlobalAlloc(GPTR, (index+1)*sizeof(TCHAR))); 144 144 lstrcpyn(pPrinterName, cBuffer, index+1); 145 145 jPrinterName = JNU_NewStringPlatform(env, pPrinterName); … … 244 244 HANDLE hPrinter; 245 245 246 LP TSTR printerName = NULL;246 LPCTSTR printerName = NULL; 247 247 if (printer != NULL) { 248 printerName = (LPTSTR)JNU_GetStringPlatformChars(env,248 printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, 249 249 printer, 250 NULL) ;250 NULL)); 251 251 JNU_ReleaseStringPlatformChars(env, printer, printerName); 252 252 } … … 254 254 // printerName - "Win NT/2K/XP: If NULL, it indicates the local printer 255 255 // server" - MSDN. Win9x : OpenPrinter returns 0. 256 BOOL ret = OpenPrinter( printerName, &hPrinter, NULL);256 BOOL ret = OpenPrinter(const_cast<LPTSTR>(printerName), &hPrinter, NULL); 257 257 if (!ret) { 258 258 return (jlong)-1; … … 304 304 TRY; 305 305 306 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,307 printer, NULL) ;306 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, 307 printer, NULL)); 308 308 309 309 jfloatArray printableArray = NULL; … … 315 315 HANDLE hPrinter; 316 316 /* Start by opening the printer */ 317 if (!::OpenPrinter( printerName, &hPrinter, NULL)) {317 if (!::OpenPrinter(const_cast<LPTSTR>(printerName), &hPrinter, NULL)) { 318 318 JNU_ReleaseStringPlatformChars(env, printer, printerName); 319 319 return printableArray; … … 322 322 PDEVMODE pDevMode; 323 323 324 if (!AwtPrintControl::getDevmode(hPrinter, printerName, &pDevMode)) { 324 if (!AwtPrintControl::getDevmode(hPrinter, const_cast<LPTSTR>(printerName), 325 &pDevMode)) { 325 326 /* if failure, cleanup and return failure */ 326 327 … … 384 385 TRY; 385 386 386 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);387 LP TSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);387 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, printer, NULL)); 388 LPCTSTR printerPort = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, port, NULL)); 388 389 jintArray mediasizeArray = NULL; 389 390 … … 403 404 jint *jpcIndices = env->GetIntArrayElements(mediasizeArray, 404 405 &isCopy), *saveFormats = jpcIndices; 405 LPTSTR papersBuf = (LPTSTR)new char[numSizes * sizeof(WORD)];406 LPTSTR papersBuf = reinterpret_cast<LPTSTR>(new char[numSizes * sizeof(WORD)]); 406 407 if (::DeviceCapabilities(printerName, printerPort, 407 408 DC_PAPERS, papersBuf, NULL) != -1) { … … 432 433 TRY; 433 434 434 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,435 printer, NULL) ;436 LP TSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);435 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, 436 printer, NULL)); 437 LPCTSTR printerPort = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, port, NULL)); 437 438 438 439 jintArray mediaTrayArray = NULL; … … 452 453 &isCopy), *saveFormats = jpcIndices; 453 454 454 LPTSTR buf = (LPTSTR)new char[nBins * sizeof(WORD)];455 LPTSTR buf = reinterpret_cast<LPTSTR>(new char[nBins * sizeof(WORD)]); 455 456 456 457 if (::DeviceCapabilities(printerName, printerPort, … … 482 483 TRY; 483 484 484 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,485 printer, NULL) ;486 LP TSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);485 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, 486 printer, NULL)); 487 LPCTSTR printerPort = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, port, NULL)); 487 488 488 489 jintArray mediaArray = NULL; … … 502 503 &isCopy), *saveFormats = jpcIndices; 503 504 504 LPTSTR buf = (LPTSTR)new char[nPapers * sizeof(POINT)]; // array of POINTs505 LPTSTR buf = reinterpret_cast<LPTSTR>(new char[nPapers * sizeof(POINT)]); // array of POINTs 505 506 506 507 if (::DeviceCapabilities(printerName, printerPort, … … 531 532 TRY; 532 533 533 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,534 printer, NULL) ;535 LP TSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);534 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, 535 printer, NULL)); 536 LPCTSTR printerPort = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, port, NULL)); 536 537 537 538 jstring utf_str; … … 545 546 if (cReturned > 0) { 546 547 547 buf = (LPTSTR)new char[cReturned * buf_len * sizeof(TCHAR)];548 buf = reinterpret_cast<LPTSTR>(new char[cReturned * buf_len * sizeof(TCHAR)]); 548 549 if (buf == NULL) { 549 550 throw std::bad_alloc(); … … 603 604 jstring port) 604 605 { 605 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);606 LP TSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);606 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, printer, NULL)); 607 LPCTSTR printerPort = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, port, NULL)); 607 608 608 609 SAVE_CONTROLWORD … … 641 642 TRY; 642 643 643 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);644 LP TSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);644 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, printer, NULL)); 645 LPCTSTR printerPort = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, port, NULL)); 645 646 646 647 jintArray resolutionArray = NULL; … … 660 661 &isCopy), *saveFormats = jpcIndices; 661 662 662 LPTSTR resBuf = (LPTSTR)new char[nResolutions * sizeof(LONG) * 2]; // pairs of long663 LPTSTR resBuf = reinterpret_cast<LPTSTR>(new char[nResolutions * sizeof(LONG) * 2]); // pairs of long 663 664 664 665 if (::DeviceCapabilities(printerName, printerPort, … … 692 693 nEscapeCode = POSTSCRIPT_PASSTHROUGH; 693 694 if( ::ExtEscape( hDC, QUERYESCSUPPORT, sizeof(int), 694 (LPCSTR)&nEscapeCode, 0, NULL ) > 0 )695 reinterpret_cast<LPCSTR>(&nEscapeCode), 0, NULL ) > 0 ) 695 696 return TRUE; 696 697 … … 698 699 nEscapeCode = GETTECHNOLOGY; 699 700 if( ::ExtEscape( hDC, QUERYESCSUPPORT, sizeof(int), 700 (LPCSTR)&nEscapeCode, 0, NULL ) <= 0 )701 reinterpret_cast<LPCSTR>(&nEscapeCode), 0, NULL ) <= 0 ) 701 702 return FALSE; 702 703 703 704 // Get the technology string and check if the word "postscript" is in it. 704 705 if( ::ExtEscape( hDC, GETTECHNOLOGY, 0, NULL, MAX_PATH, 705 (LPSTR)szTechnology) <= 0 )706 reinterpret_cast<LPSTR>(szTechnology) ) <= 0 ) 706 707 return FALSE; 707 708 strupr( szTechnology ); … … 756 757 jstring port) 757 758 { 758 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);759 LP TSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);759 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, printer, NULL)); 760 LPCTSTR printerPort = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, port, NULL)); 760 761 // 0x1000 is a flag to indicate that getCapabilities has already been called. 761 762 // 0x0001 is a flag for color support and supported is the default. … … 829 830 TRY; 830 831 831 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);832 LP TSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);832 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, printer, NULL)); 833 LPCTSTR printerPort = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, port, NULL)); 833 834 834 835 jintArray defaultArray = env->NewIntArray(NDEFAULT); … … 846 847 847 848 /* Start by opening the printer */ 848 if (!::OpenPrinter( printerName, &hPrinter, NULL)) {849 if (!::OpenPrinter(const_cast<LPTSTR>(printerName), &hPrinter, NULL)) { 849 850 env->ReleaseIntArrayElements(defaultArray, saveFormats, 0); 850 851 JNU_ReleaseStringPlatformChars(env, printer, printerName); … … 852 853 } 853 854 854 if (!AwtPrintControl::getDevmode(hPrinter, printerName, &pDevMode)) {855 if (!AwtPrintControl::getDevmode(hPrinter, const_cast<LPTSTR>(printerName), &pDevMode)) { 855 856 /* if failure, cleanup and return failure */ 856 857 if (pDevMode != NULL) { … … 876 877 DC_PAPERS, NULL, NULL); 877 878 if (numSizes > 0) { 878 LPWORD papers = (LPWORD)safe_Malloc(numSizes * sizeof(WORD));879 LPWORD papers = static_cast<LPWORD>(safe_Malloc(numSizes * sizeof(WORD))); 879 880 if (papers != NULL && 880 881 ::DeviceCapabilities(printerName, printerPort, 881 DC_PAPERS, (LPTSTR)papers, NULL) != -1) {882 DC_PAPERS, reinterpret_cast<LPTSTR>(papers), NULL) != -1) { 882 883 int present = 0; 883 884 for (int i=0;i<numSizes;i++) { … … 951 952 int ret=0; 952 953 953 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);954 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, printer, NULL)); 954 955 955 956 // Start by opening the printer 956 if (!::OpenPrinter( printerName, &hPrinter, NULL)) {957 if (!::OpenPrinter(const_cast<LPTSTR>(printerName), &hPrinter, NULL)) { 957 958 JNU_ReleaseStringPlatformChars(env, printer, printerName); 958 959 return -1; … … 1039 1040 HANDLE hPrinter; 1040 1041 DOC_INFO_1 DocInfo; 1041 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);1042 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, printer, NULL)); 1042 1043 DASSERT(jobname != NULL); 1043 LP TSTR lpJobName = (LPTSTR)JNU_GetStringPlatformChars(env, jobname, NULL);1044 LPCTSTR lpJobName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, jobname, NULL)); 1044 1045 LPTSTR jname = _tcsdup(lpJobName); 1045 1046 JNU_ReleaseStringPlatformChars(env, jobname, lpJobName); 1046 1047 1047 1048 // Start by opening the printer 1048 if (!::OpenPrinter( printerName, &hPrinter, NULL)) {1049 if (!::OpenPrinter(const_cast<LPTSTR>(printerName), &hPrinter, NULL)) { 1049 1050 JNU_ReleaseStringPlatformChars(env, printer, printerName); 1050 free( (LPTSTR)jname);1051 free(jname); 1051 1052 return false; 1052 1053 } … … 1062 1063 if( (::StartDocPrinter(hPrinter, 1, (LPBYTE)&DocInfo)) == 0 ) { 1063 1064 ::ClosePrinter( hPrinter ); 1064 free( (LPTSTR)jname);1065 free(jname); 1065 1066 return false; 1066 1067 } 1067 1068 1068 free( (LPTSTR)jname);1069 free(jname); 1069 1070 1070 1071 // Start a page. -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Button.cpp
r187 r195 107 107 labelStr = L""; 108 108 } else { 109 labelStr = (LPCWSTR)env->GetStringChars(label, JNI_FALSE);109 labelStr = jsafe_cast<LPCWSTR>(env->GetStringChars(label, JNI_FALSE)); 110 110 } 111 111 style = 0; … … 129 129 c->UpdateBackground(env, target); 130 130 if (label != NULL) 131 env->ReleaseStringChars(label, (jchar*)labelStr);131 env->ReleaseStringChars(label, jsafe_cast<const jchar*>(labelStr)); 132 132 } catch (...) { 133 133 env->DeleteLocalRef(target); -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Checkbox.cpp
r187 r195 107 107 label = (jstring)env->GetObjectField(target, AwtCheckbox::labelID); 108 108 if (label != NULL) { 109 labelStr = (LPCWSTR)env->GetStringChars(label, 0);109 labelStr = jsafe_cast<LPCWSTR>(env->GetStringChars(label, 0)); 110 110 } 111 111 if (labelStr != 0) { … … 124 124 125 125 if (labelStr != defaultLabelStr) { 126 env->ReleaseStringChars(label, (jchar*)labelStr);126 env->ReleaseStringChars(label, jsafe_cast<const jchar*>(labelStr)); 127 127 } 128 128 } else { -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Component.cpp
r187 r195 553 553 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 554 554 NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 555 (LPTSTR)&buf, 0, NULL);555 reinterpret_cast<LPTSTR>(&buf), 0, NULL); 556 556 jstring s = JNU_NewStringPlatform(env, buf); 557 557 createError = JNU_NewObjectByName(env, "java/lang/InternalError", … … 1884 1884 case WM_SETTINGCHANGE: 1885 1885 CheckFontSmoothingSettings(NULL); 1886 mr = WmSettingChange(static_cast<UINT>(wParam), (LPCTSTR)lParam);1886 mr = WmSettingChange(static_cast<UINT>(wParam), reinterpret_cast<LPCTSTR>(lParam)); 1887 1887 break; 1888 1888 case WM_CONTEXTMENU: … … 3617 3617 WCHAR unicodeChar[2]; 3618 3618 VERIFY(::MultiByteToWideChar(GetCodePage(), MB_PRECOMPOSED, 3619 (LPCSTR)&mbChar, 1, unicodeChar, 1));3619 reinterpret_cast<LPCSTR>(&mbChar), 1, unicodeChar, 1)); 3620 3620 3621 3621 translation = unicodeChar[0]; -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_DataTransferer.cpp
r190 r195 289 289 290 290 UINT bufsize = 512; // in characters, not in bytes 291 buffer = (LPTSTR)safe_Malloc(bufsize*sizeof(TCHAR));291 buffer = static_cast<LPTSTR>(safe_Malloc(bufsize*sizeof(TCHAR))); 292 292 293 293 for (UINT i = 0; i < nFilenames; i++) { … … 295 295 if (size > bufsize) { 296 296 bufsize = size; 297 buffer = (LPTSTR)safe_Realloc(buffer, bufsize*sizeof(TCHAR));297 buffer = static_cast<LPTSTR>(safe_Realloc(buffer, bufsize*sizeof(TCHAR))); 298 298 } 299 299 (*do_drag_query_file)(hdrop, i, buffer, bufsize); … … 391 391 case CF_DIB: 392 392 393 pSrcBmi = (BITMAPINFO*)( (LPSTR)bBytes+ uOffset);393 pSrcBmi = (BITMAPINFO*)(reinterpret_cast<LPSTR>(bBytes) + uOffset); 394 394 pSrcBmih = &pSrcBmi->bmiHeader; 395 395 … … 429 429 } 430 430 431 pSrcBits = (LPSTR)pSrcBmi+ pSrcBmih->biSize431 pSrcBits = reinterpret_cast<LPSTR>(pSrcBmi) + pSrcBmih->biSize 432 432 + nColorEntries * sizeof(RGBQUAD); 433 433 } … … 666 666 pinfo->bmiHeader.biSizeImage = size + pad; 667 667 668 jbyte *array = (jbyte*)( (LPSTR)pinfo+ sizeof(BITMAPINFOHEADER));668 jbyte *array = (jbyte*)(reinterpret_cast<LPSTR>(pinfo) + sizeof(BITMAPINFOHEADER)); 669 669 env->GetByteArrayRegion(imageData, 0, size, array); 670 670 HRESULT hr = S_OK; -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Debug.cpp
r2 r195 158 158 lastError, 159 159 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 160 (LPSTR)&msgBuffer, // it's an output parameter when allocate buffer is used160 reinterpret_cast<LPSTR>(&msgBuffer), // it's an output parameter when allocate buffer is used 161 161 0, 162 162 NULL); -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Desktop.cpp
r187 r195 41 41 (JNIEnv *env, jclass cls, jstring uri_j, jstring verb_j) 42 42 { 43 const WCHAR* uri_c = (const WCHAR*)env->GetStringChars(uri_j, JNI_FALSE);44 const WCHAR* verb_c = (const WCHAR*)env->GetStringChars(verb_j, JNI_FALSE);43 const WCHAR* uri_c = jsafe_cast<const WCHAR*>(env->GetStringChars(uri_j, JNI_FALSE)); 44 const WCHAR* verb_c = jsafe_cast<const WCHAR*>(env->GetStringChars(verb_j, JNI_FALSE)); 45 45 46 46 // 6457572: ShellExecute possibly changes FPU control word - saving it here … … 49 49 _control87(oldcontrol87, 0xffffffff); 50 50 51 env->ReleaseStringChars(uri_j, (jchar*)uri_c);52 env->ReleaseStringChars(verb_j, (jchar*)verb_c);51 env->ReleaseStringChars(uri_j, jsafe_cast<const jchar*>(uri_c)); 52 env->ReleaseStringChars(verb_j, jsafe_cast<const jchar*>(verb_c)); 53 53 54 54 if ((int)retval <= 32) { 55 55 // ShellExecute failed. 56 LP VOIDbuffer;56 LPWSTR buffer; 57 57 int len = FormatMessageW( 58 58 FORMAT_MESSAGE_ALLOCATE_BUFFER | … … 62 62 GetLastError(), 63 63 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 64 (LPWSTR) &buffer,64 reinterpret_cast<LPWSTR>(&buffer), 65 65 0, 66 66 NULL ); 67 67 68 jstring errmsg = env->NewString( (jchar*)buffer, len);68 jstring errmsg = env->NewString(jsafe_cast<const jchar*>(buffer), len); 69 69 LocalFree(buffer); 70 70 return errmsg; -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp
r190 r195 121 121 return NULL; 122 122 } 123 LPTSTR buffer = (LPTSTR)safe_Malloc(valueSize);123 LPTSTR buffer = static_cast<LPTSTR>(safe_Malloc(valueSize)); 124 124 if (RegQueryValueEx((HKEY)handle, fontName, NULL, 125 125 &valueType, (unsigned char *)buffer, &valueSize) != 0) { … … 167 167 return NULL; 168 168 } 169 LPTSTR buffer = (LPTSTR)safe_Malloc(valueSize);169 LPTSTR buffer = static_cast<LPTSTR>(safe_Malloc(valueSize)); 170 170 if (RegQueryValueEx((HKEY)handle, valueName, NULL, 171 171 valueType, (unsigned char *)buffer, &valueSize) != 0) { … … 179 179 // Pending: buffer must be null-terminated at this point 180 180 valueChar = ExpandEnvironmentStrings(buffer, NULL, 0); 181 LPTSTR buffer2 = (LPTSTR)safe_Malloc(valueChar*sizeof(TCHAR));181 LPTSTR buffer2 = static_cast<LPTSTR>(safe_Malloc(valueChar*sizeof(TCHAR))); 182 182 ExpandEnvironmentStrings(buffer, buffer2, valueChar); 183 183 free(buffer); … … 609 609 610 610 LPTSTR valueName = TEXT("PlaceN"); 611 LPTSTR valueNameBuf = (LPTSTR)safe_Malloc((lstrlen(valueName) + 1) * sizeof(TCHAR));611 LPTSTR valueNameBuf = static_cast<LPTSTR>(safe_Malloc((lstrlen(valueName) + 1) * sizeof(TCHAR))); 612 612 lstrcpy(valueNameBuf, valueName); 613 613 614 614 LPTSTR propKey = TEXT("win.comdlg.placesBarPlaceN"); 615 LPTSTR propKeyBuf = (LPTSTR)safe_Malloc((lstrlen(propKey) + 1) * sizeof(TCHAR));615 LPTSTR propKeyBuf = static_cast<LPTSTR>(safe_Malloc((lstrlen(propKey) + 1) * sizeof(TCHAR))); 616 616 lstrcpy(propKeyBuf, propKey); 617 617 … … 672 672 673 673 void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) { 674 jstring key = JNU_NewStringPlatform(GetEnv(), (const jchar*)propName);674 jstring key = JNU_NewStringPlatform(GetEnv(), jsafe_cast<const jchar*>(propName)); 675 675 GetEnv()->CallVoidMethod(self, 676 676 AwtDesktopProperties::setStringPropertyID, … … 680 680 681 681 void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) { 682 jstring key = JNU_NewStringPlatform(GetEnv(), (const jchar*)propName);682 jstring key = JNU_NewStringPlatform(GetEnv(), jsafe_cast<const jchar*>(propName)); 683 683 GetEnv()->CallVoidMethod(self, 684 684 AwtDesktopProperties::setIntegerPropertyID, … … 688 688 689 689 void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) { 690 jstring key = JNU_NewStringPlatform(GetEnv(), (const jchar*)propName);690 jstring key = JNU_NewStringPlatform(GetEnv(), jsafe_cast<const jchar*>(propName)); 691 691 GetEnv()->CallVoidMethod(self, 692 692 AwtDesktopProperties::setBooleanPropertyID, … … 696 696 697 697 void AwtDesktopProperties::SetColorProperty(LPCTSTR propName, DWORD value) { 698 jstring key = JNU_NewStringPlatform(GetEnv(), (const jchar*)propName);698 jstring key = JNU_NewStringPlatform(GetEnv(), jsafe_cast<const jchar*>(propName)); 699 699 GetEnv()->CallVoidMethod(self, 700 700 AwtDesktopProperties::setColorPropertyID, … … 731 731 // fall back to Microsoft Sans Serif 732 732 fontName = JNU_NewStringPlatform(GetEnv(), 733 (const jchar*)L"Microsoft Sans Serif");733 jsafe_cast<const jchar*>(L"Microsoft Sans Serif")); 734 734 } 735 735 } … … 748 748 } 749 749 750 jstring key = JNU_NewStringPlatform(GetEnv(), (const jchar*)propName);750 jstring key = JNU_NewStringPlatform(GetEnv(), jsafe_cast<const jchar*>(propName)); 751 751 GetEnv()->CallVoidMethod(self, 752 752 AwtDesktopProperties::setFontPropertyID, … … 789 789 } 790 790 791 jstring key = JNU_NewStringPlatform(GetEnv(), (const jchar*)propName);791 jstring key = JNU_NewStringPlatform(GetEnv(), jsafe_cast<const jchar*>(propName)); 792 792 GetEnv()->CallVoidMethod(self, AwtDesktopProperties::setFontPropertyID, 793 793 key, fontName, style, pointSize); … … 798 798 799 799 void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventName) { 800 jstring key = JNU_NewStringPlatform(GetEnv(), (const jchar*)propName);801 jstring event = JNU_NewStringPlatform(GetEnv(), (const jchar*)winEventName);800 jstring key = JNU_NewStringPlatform(GetEnv(), jsafe_cast<const jchar*>(propName)); 801 jstring event = JNU_NewStringPlatform(GetEnv(), jsafe_cast<const jchar*>(winEventName)); 802 802 GetEnv()->CallVoidMethod(self, 803 803 AwtDesktopProperties::setSoundPropertyID, -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp
r190 r195 1194 1194 ::CoFileTimeNow(&now); 1195 1195 1196 m_statstg.pwcsName = (LPWSTR)NULL;1196 m_statstg.pwcsName = NULL; 1197 1197 m_statstg.type = STGTY_STREAM; 1198 1198 m_statstg.cbSize.HighPart = 0; -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_DnDDT.cpp
r2 r195 556 556 } 557 557 case TYMED_FILE: { 558 jobject local = JNU_NewStringPlatform(env, (LPCTSTR)559 stgmedium.lpszFileName) ;558 jobject local = JNU_NewStringPlatform(env, jsafe_cast<LPCTSTR>( 559 stgmedium.lpszFileName)); 560 560 jstring fileName = (jstring)env->NewGlobalRef(local); 561 561 env->DeleteLocalRef(local); -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp
r190 r195 66 66 int length = env->GetStringLength(filterDescription); 67 67 DASSERT(length + 1 < MAX_FILTER_STRING); 68 LPCTSTR tmp = (LPTSTR)JNU_GetStringPlatformChars(env, filterDescription, NULL);68 LPCTSTR tmp = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, filterDescription, NULL)); 69 69 _tcscpy(s_fileFilterString, tmp); 70 70 JNU_ReleaseStringPlatformChars(env, filterDescription, tmp); … … 237 237 238 238 if (title == NULL || env->GetStringLength(title)==0) { 239 title = env->NewString( (const jchar*)&unicodeChar, 1);239 title = env->NewString(jsafe_cast<const jchar*>(&unicodeChar), 1); 240 240 } 241 241 -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Font.cpp
r190 r195 366 366 NEWTEXTMETRICEX *lpntme, int FontType, LPARAM lParam) 367 367 { 368 if(_tcsstr( (LPTSTR)lParam, lpelfe->elfLogFont.lfFaceName)) {369 _tcscpy( (LPTSTR)lParam, lpelfe->elfLogFont.lfFaceName);368 if(_tcsstr(reinterpret_cast<LPTSTR>(lParam), lpelfe->elfLogFont.lfFaceName)) { 369 _tcscpy(reinterpret_cast<LPTSTR>(lParam), lpelfe->elfLogFont.lfFaceName); 370 370 return 0; 371 371 } else { … … 694 694 // Start of conversion Code to fix arabic shaping problems 695 695 // with unicode support in win 95 696 LPSTR buffer = (LPSTR) alloca((wcslen(string) + 1) * 2);696 LPSTR buffer = static_cast<LPSTR>(alloca((wcslen(string) + 1) * 2)); 697 697 int count = ::WideCharToMultiByte(codePage, 0, string, length, 698 698 buffer, … … 754 754 755 755 if (unicodeUsed) { 756 VERIFY(!draw || ::TextOutW(hDC, x, y, (LPCWSTR)offsetBuffer, buflen / 2));757 VERIFY(::GetTextExtentPoint32W(hDC, (LPCWSTR)offsetBuffer, buflen / 2, &temp));756 VERIFY(!draw || ::TextOutW(hDC, x, y, reinterpret_cast<LPCWSTR>(offsetBuffer), buflen / 2)); 757 VERIFY(::GetTextExtentPoint32W(hDC, reinterpret_cast<LPCWSTR>(offsetBuffer), buflen / 2, &temp)); 758 758 } 759 759 else { … … 1777 1777 VERIFY(::WideCharToMultiByte(CP_ACP, 0, szFamilyName, -1, 1778 1778 szTmpName, sizeof(szTmpName), NULL, NULL)); 1779 LONG lStatus = ::RegQueryValueExA(hKey, (LPCSTR) szTmpName,1779 LONG lStatus = ::RegQueryValueExA(hKey, reinterpret_cast<LPCSTR>(szTmpName), 1780 1780 NULL, &dwType, szFileName, &dwBytes); 1781 1781 BOOL fUseDefault = FALSE; … … 1788 1788 } 1789 1789 char szDefault[] = "SystemDefaultEUDCFont"; 1790 lStatus = ::RegQueryValueExA(hKey, (LPCSTR) szDefault,1790 lStatus = ::RegQueryValueExA(hKey, reinterpret_cast<LPCSTR>(szDefault), 1791 1791 NULL, &dwType, szFileName, &dwBytes); 1792 1792 fUseDefault = TRUE; … … 1799 1799 } 1800 1800 1801 if (strcmp( (LPCSTR) szFileName, "userfont.fon") == 0) {1801 if (strcmp(reinterpret_cast<char*>(szFileName), "userfont.fon") == 0) { 1802 1802 // This font is associated with no EUDC font 1803 1803 // and the system default EUDC font is not TrueType … … 1806 1806 } 1807 1807 1808 DASSERT(strlen( (LPCSTR)szFileName) > 0);1808 DASSERT(strlen(reinterpret_cast<char*>(szFileName)) > 0); 1809 1809 VERIFY(::MultiByteToWideChar(CP_ACP, 0, 1810 (LPCSTR)szFileName, -1, lpszFileName, cchFileName) != 0);1810 reinterpret_cast<LPCSTR>(szFileName), -1, lpszFileName, cchFileName) != 0); 1811 1811 if (fUseDefault) 1812 1812 wcscpy(m_szDefaultEUDCFile, lpszFileName); -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_InputMethod.cpp
r2 r195 511 511 512 512 if ((buffSize = ::ImmGetDescription(hkl, szImmDescription, 0)) > 0) { 513 szImmDescription = (LPTSTR) safe_Malloc(buffSize * sizeof(TCHAR));513 szImmDescription = static_cast<LPTSTR>(safe_Malloc(buffSize * sizeof(TCHAR))); 514 514 515 515 if (szImmDescription != NULL) { … … 596 596 if (ret == ERROR_SUCCESS) { 597 597 hkl = reinterpret_cast<HKL>(static_cast<INT_PTR>( 598 _tcstoul( (LPCTSTR)szHKL, &end, 16)));598 _tcstoul(reinterpret_cast<LPCTSTR>(szHKL), &end, 16))); 599 599 } 600 600 -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_InputTextInfor.cpp
r190 r195 109 109 // Assign the context data 110 110 m_cStrW = cbData[0]/WCHAR_SZ; 111 m_lpStrW = (LPWSTR)lpData[0];111 m_lpStrW = static_cast<LPWSTR>(lpData[0]); 112 112 113 113 m_cReadStrW = cbData[1]/WCHAR_SZ; 114 m_lpReadStrW = (LPWSTR)lpData[1];114 m_lpReadStrW = static_cast<LPWSTR>(lpData[1]); 115 115 116 116 m_cClauseW = cbData[2]/DWORD_SZ - 1; … … 188 188 if (env == NULL || lpStrW == NULL || cStrW == 0) return NULL; 189 189 190 return env->NewString( (jchar*)lpStrW, cStrW);190 return env->NewString(jsafe_cast<const jchar*>(lpStrW), cStrW); 191 191 } 192 192 … … 253 253 } 254 254 else { 255 readingClauseW[cls] = MakeJavaString(env, (LPWSTR)NULL, 0);255 readingClauseW[cls] = MakeJavaString(env, NULL, 0); 256 256 } 257 257 } -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_List.cpp
r190 r195 688 688 for (jsize i=0; i < itemCount; i++) 689 689 { 690 LP TSTR itemPtr = NULL;690 LPCTSTR itemPtr = NULL; 691 691 jstring item = (jstring)env->GetObjectArrayElement(items, i); 692 692 JNI_CHECK_NULL_GOTO(item, "null item", next_item); 693 itemPtr = (LPTSTR)JNU_GetStringPlatformChars(env, item, 0);693 itemPtr = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, item, 0)); 694 694 if (itemPtr == NULL) 695 695 { … … 698 698 else 699 699 { 700 l->InsertString(index+i, itemPtr);700 l->InsertString(index+i, const_cast<LPTSTR>(itemPtr)); 701 701 JNU_ReleaseStringPlatformChars(env, item, itemPtr); 702 702 } -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Menu.cpp
r2 r195 150 150 UINT flags = MF_STRING | (enabled ? MF_ENABLED : MF_GRAYED); 151 151 flags |= MF_OWNERDRAW; 152 LPCTSTR itemInfo = (LPCTSTR) this;152 LPCTSTR itemInfo = reinterpret_cast<LPCTSTR>(this); 153 153 154 154 if (_tcscmp(item->GetClassName(), TEXT("SunAwtMenu")) == 0) { 155 155 flags |= MF_POPUP; 156 itemInfo = (LPCTSTR) item;156 itemInfo = reinterpret_cast<LPCTSTR>(item); 157 157 } 158 158 -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_MenuItem.cpp
r190 r195 166 166 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 167 167 NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 168 (LPTSTR)&buf, 0, NULL);168 reinterpret_cast<LPTSTR>(&buf), 0, NULL); 169 169 jstring s = JNU_NewStringPlatform(env, buf); 170 170 createError = JNU_NewObjectByName(env, "java/lang/InternalError", … … 636 636 637 637 mii.fType = MFT_OWNERDRAW; 638 mii.dwTypeData = (LPTSTR)(*sb);638 mii.dwTypeData = reinterpret_cast<LPTSTR>(*sb); 639 639 640 640 // find index by menu item id … … 700 700 case MENUITEM_SETLABEL: 701 701 { 702 LPCTSTR sb = (LPCTSTR)args->param1;702 LPCTSTR sb = reinterpret_cast<LPCTSTR>(args->param1); 703 703 DASSERT(!IsBadStringPtr(sb, 20)); 704 704 this->SetLabel(sb); -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_PrintControl.cpp
r190 r195 136 136 137 137 JavaStringBuffer printerNameBuf(env, printerName); 138 LPTSTR lpcPrinterName = (LPTSTR)printerNameBuf;138 LPTSTR lpcPrinterName = jsafe_cast<LPTSTR>(printerNameBuf); 139 139 DASSERT(lpcPrinterName != NULL); 140 140 … … 436 436 (DEVNAMES *)::GlobalLock(ppd->hDevNames); 437 437 DASSERT(!IsBadWritePtr(devnames, devnameSize)); 438 LPTSTR lpcDevnames = (LPTSTR)devnames;438 LPTSTR lpcDevnames = reinterpret_cast<LPTSTR>(devnames); 439 439 440 440 // note: all sizes are in characters, not in bytes … … 512 512 513 513 DWORD result1 = DeviceCapabilities(printer, port, 514 DC_PAPERS, (LPTSTR) papers, NULL);514 DC_PAPERS, reinterpret_cast<LPTSTR>(papers), NULL); 515 515 516 516 DWORD result2 = DeviceCapabilities(printer, port, 517 DC_PAPERSIZE, (LPTSTR) paperSizes,517 DC_PAPERSIZE, reinterpret_cast<LPTSTR>(paperSizes), 518 518 NULL); 519 519 520 520 // REMIND: cache in papers and paperSizes 521 521 if (result1 == -1 || result2 == -1 ) { 522 free( (LPTSTR)papers);522 free(papers); 523 523 papers = NULL; 524 free( (LPTSTR)paperSizes);524 free(paperSizes); 525 525 paperSizes = NULL; 526 526 } … … 578 578 579 579 if (papers != NULL) { 580 free( (LPTSTR)papers);580 free(papers); 581 581 } 582 582 583 583 if (paperSizes != NULL) { 584 free( (LPTSTR)paperSizes);584 free(paperSizes); 585 585 } 586 586 … … 621 621 pd.hDevNames = AwtPrintControl::getPrintHDName(env, printCtrl); 622 622 623 LP TSTR getName = (LPTSTR)JNU_GetStringPlatformChars(env,624 printerName, NULL) ;623 LPCTSTR getName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, 624 printerName, NULL)); 625 625 626 626 BOOL samePrinter = FALSE; … … 631 631 DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(pd.hDevNames); 632 632 if (devnames != NULL) { 633 LPTSTR lpdevnames = (LPTSTR)devnames;633 LPTSTR lpdevnames = reinterpret_cast<LPTSTR>(devnames); 634 634 printName = lpdevnames+devnames->wDeviceOffset; 635 635 … … 951 951 DEVNAMES *devnames = (DEVNAMES*)::GlobalLock(pd.hDevNames); 952 952 DASSERT(!IsBadReadPtr(devnames, sizeof(DEVNAMES))); 953 LPCTSTR lpcNames = (LPTSTR)devnames;953 LPCTSTR lpcNames = reinterpret_cast<LPTSTR>(devnames); 954 954 LPCTSTR pbuf = (_tcslen(lpcNames + devnames->wDeviceOffset) == 0 ? 955 955 TEXT("") : lpcNames + devnames->wDeviceOffset); -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp
r190 r195 438 438 int sz = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, NULL, 0); 439 439 if (sz > 0) { 440 LPTSTR str = (LPTSTR)safe_Malloc(sizeof(TCHAR) * sz);440 LPTSTR str = static_cast<LPTSTR>(safe_Malloc(sizeof(TCHAR) * sz)); 441 441 if (str != NULL) { 442 442 sz = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, str, sz); … … 446 446 } 447 447 } 448 free( (LPTSTR)str);448 free(str); 449 449 } 450 450 } … … 484 484 DEVNAMES* names = (DEVNAMES*)::GlobalLock(setup.hDevNames); 485 485 if (names != NULL) { 486 LPTSTR printer = (LPTSTR)names+names->wDeviceOffset;486 LPTSTR printer = reinterpret_cast<LPTSTR>(names)+names->wDeviceOffset; 487 487 SAVE_CONTROLWORD 488 488 HDC newDC = ::CreateDC(TEXT("WINSPOOL"), printer, NULL, NULL); … … 610 610 if (devnames != NULL) { 611 611 612 LPTSTR lpdevnames = (LPTSTR)devnames;612 LPTSTR lpdevnames = reinterpret_cast<LPTSTR>(devnames); 613 613 LPTSTR printerName = _tcsdup(lpdevnames+devnames->wDeviceOffset); 614 614 … … 622 622 } 623 623 ::GlobalUnlock(hDevNames); 624 free ( (LPTSTR)printerName);624 free (printerName); 625 625 return; 626 626 } … … 633 633 ::ClosePrinter(hPrinter); 634 634 ::GlobalUnlock(hDevNames); 635 free ( (LPTSTR)printerName);635 free (printerName); 636 636 return ; 637 637 } … … 648 648 LOCALE_IMEASURE, NULL, 0); 649 649 if (sz > 0) { 650 LPTSTR str = (LPTSTR)safe_Malloc(sizeof(TCHAR) * sz);650 LPTSTR str = static_cast<LPTSTR>(safe_Malloc(sizeof(TCHAR) * sz)); 651 651 if (str != NULL) { 652 652 sz = GetLocaleInfo(LOCALE_USER_DEFAULT, … … 657 657 } 658 658 } 659 free( (LPTSTR)str);659 free(str); 660 660 } 661 661 } … … 694 694 ::GlobalFree(pDevMode); 695 695 696 free ( (LPTSTR)printerName);696 free (printerName); 697 697 698 698 ::ClosePrinter(hPrinter); … … 919 919 920 920 if (devnames != NULL) { 921 LPTSTR lpdevnames = (LPTSTR)devnames;921 LPTSTR lpdevnames = reinterpret_cast<LPTSTR>(devnames); 922 922 LPTSTR printername = lpdevnames+devnames->wDeviceOffset; 923 923 LPTSTR port = lpdevnames+devnames->wOutputOffset; … … 1090 1090 DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(hDevNames); 1091 1091 if (devnames != NULL) { 1092 LPTSTR lpdevnames = (LPTSTR)devnames;1092 LPTSTR lpdevnames = reinterpret_cast<LPTSTR>(devnames); 1093 1093 LPTSTR printer = lpdevnames+devnames->wDeviceOffset; 1094 1094 LPTSTR port = lpdevnames+devnames->wOutputOffset; … … 1128 1128 int err = 0; 1129 1129 1130 LP TSTR destination = NULL;1130 LPCTSTR destination = NULL; 1131 1131 if (dest != NULL) { 1132 destination = (LPTSTR)JNU_GetStringPlatformChars(env, dest, NULL);1132 destination = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, dest, NULL)); 1133 1133 } else { 1134 1134 destination = VerifyDestination(env, self); … … 1136 1136 LPTSTR docname = NULL; 1137 1137 if (jobname != NULL) { 1138 LP TSTR tmp = (LPTSTR)JNU_GetStringPlatformChars(env, jobname, NULL);1138 LPCTSTR tmp = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, jobname, NULL)); 1139 1139 docname = _tcsdup(tmp); 1140 1140 JNU_ReleaseStringPlatformChars(env, jobname, tmp); … … 1353 1353 if (devnames != NULL) { 1354 1354 1355 LPTSTR lpdevnames = (LPTSTR)devnames;1355 LPTSTR lpdevnames = reinterpret_cast<LPTSTR>(devnames); 1356 1356 LPTSTR printerName = _tcsdup(lpdevnames+devnames->wDeviceOffset); 1357 1357 … … 2984 2984 2985 2985 if (devnames != NULL) { 2986 LPTSTR lpdevnames = (LPTSTR)devnames;2986 LPTSTR lpdevnames = reinterpret_cast<LPTSTR>(devnames); 2987 2987 LPTSTR printer = lpdevnames+devnames->wDeviceOffset; 2988 2988 LPTSTR port = lpdevnames+devnames->wOutputOffset; … … 3130 3130 3131 3131 DWORD result = DeviceCapabilities(deviceName, portName, 3132 DC_PAPERSIZE, (LPTSTR) paperSizes,3132 DC_PAPERSIZE, reinterpret_cast<LPTSTR>(paperSizes), 3133 3133 NULL); 3134 3134 if (result == -1) { … … 3759 3759 DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(hDevNames); 3760 3760 if (devnames != NULL) { 3761 LPTSTR lpdevnames = (LPTSTR)devnames;3761 LPTSTR lpdevnames = reinterpret_cast<LPTSTR>(devnames); 3762 3762 printer = _tcsdup(lpdevnames+devnames->wDeviceOffset); 3763 3763 port = _tcsdup(lpdevnames+devnames->wOutputOffset); … … 3779 3779 3780 3780 DWORD result1 = DeviceCapabilities(printer, port, 3781 DC_PAPERS, (LPTSTR) papers, NULL);3781 DC_PAPERS, reinterpret_cast<LPTSTR>(papers), NULL); 3782 3782 DWORD result2 = DeviceCapabilities(printer, port, 3783 DC_PAPERSIZE, (LPTSTR) paperSizes,3783 DC_PAPERSIZE, reinterpret_cast<LPTSTR>(paperSizes), 3784 3784 NULL); 3785 3785 … … 3990 3990 // Copy the DEVNAMES information from PRINTER_INFO_2 structure. 3991 3991 pDevNames->wDriverOffset = sizeof(DEVNAMES)/sizeof(TCHAR); 3992 memcpy( (LPTSTR)pDevNames+ pDevNames->wDriverOffset,3992 memcpy(reinterpret_cast<LPTSTR>(pDevNames) + pDevNames->wDriverOffset, 3993 3993 p2->pDriverName, drvNameLen*sizeof(TCHAR)); 3994 3994 3995 3995 pDevNames->wDeviceOffset = static_cast<WORD>(sizeof(DEVNAMES)/sizeof(TCHAR)) + 3996 3996 drvNameLen + 1; 3997 memcpy( (LPTSTR)pDevNames+ pDevNames->wDeviceOffset,3997 memcpy(reinterpret_cast<LPTSTR>(pDevNames) + pDevNames->wDeviceOffset, 3998 3998 p2->pPrinterName, ptrNameLen*sizeof(TCHAR)); 3999 3999 4000 4000 pDevNames->wOutputOffset = static_cast<WORD>(sizeof(DEVNAMES)/sizeof(TCHAR)) + 4001 4001 drvNameLen + ptrNameLen + 2; 4002 memcpy( (LPTSTR)pDevNames+ pDevNames->wOutputOffset,4002 memcpy(reinterpret_cast<LPTSTR>(pDevNames) + pDevNames->wOutputOffset, 4003 4003 p2->pPortName, porNameLen*sizeof(TCHAR)); 4004 4004 … … 4021 4021 { 4022 4022 TRY; 4023 LP TSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,4024 printer, NULL) ;4023 LPCTSTR printerName = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, 4024 printer, NULL)); 4025 4025 HDC hDC = AwtPrintControl::getPrintDC(env, name); 4026 4026 if (hDC != NULL) { … … 4052 4052 } 4053 4053 4054 SetPrinterDevice( printerName, &hDevMode, &hDevNames);4054 SetPrinterDevice(const_cast<LPTSTR>(printerName), &hDevMode, &hDevNames); 4055 4055 4056 4056 AwtPrintControl::setPrintHDMode(env, name, hDevMode); … … 4099 4099 4100 4100 printer = JNU_NewStringPlatform(env, 4101 (LPTSTR)pDevNames+pDevNames->wDeviceOffset);4101 reinterpret_cast<LPTSTR>(pDevNames)+pDevNames->wDeviceOffset); 4102 4102 ::GlobalUnlock(hDevNames); 4103 4103 return printer; -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_TextArea.cpp
r190 r195 252 252 WCHAR *string = new WCHAR[length]; 253 253 env->GetStringRegion(jStr, 0, static_cast<jsize>(length - 1), 254 reinterpret_cast<jchar*>(string));254 jsafe_cast<jchar*>(string)); 255 255 string[length-1] = '\0'; 256 256 for (size_t i = 0; i < maxlen && i < length - 1; i++) { … … 995 995 // WCHAR* buffer = TO_WSTRING(text); 996 996 WCHAR *buffer = new WCHAR[length]; 997 env->GetStringRegion(text, 0, length-1, reinterpret_cast<jchar*>(buffer));997 env->GetStringRegion(text, 0, length-1, jsafe_cast<jchar*>(buffer)); 998 998 buffer[length-1] = '\0'; 999 999 -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_TextComponent.cpp
r190 r195 327 327 c->GetText(buf, len + 1); 328 328 c->RemoveCR(buf); 329 result = env->NewString( reinterpret_cast<jchar*>(buf),329 result = env->NewString(jsafe_cast<jchar*>(buf), 330 330 static_cast<jsize>(wcslen(buf))); 331 331 delete [] buf; … … 364 364 int length = env->GetStringLength(text); 365 365 WCHAR* buffer = new WCHAR[length + 1]; 366 env->GetStringRegion(text, 0, length, reinterpret_cast<jchar*>(buffer));366 env->GetStringRegion(text, 0, length, jsafe_cast<jchar*>(buffer)); 367 367 buffer[length] = 0; 368 368 c->CheckLineSeparator(buffer); -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp
r191 r195 314 314 int length = env->GetStringLength(jstr); 315 315 buffer = new TCHAR[length + 1]; 316 LPCTSTR tmp = (LPCTSTR)JNU_GetStringPlatformChars(env, jstr, NULL);316 LPCTSTR tmp = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, jstr, NULL)); 317 317 _tcscpy(buffer, tmp); 318 318 JNU_ReleaseStringPlatformChars(env, jstr, tmp); … … 380 380 HWND hwnd = CreateWindow( 381 381 szAwtToolkitClassName, 382 (LPCTSTR)name,/* window name */382 name, /* window name */ 383 383 WS_DISABLED, /* window style */ 384 384 -1, -1, /* position of window */ -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_TrayIcon.cpp
r193 r195 734 734 } 735 735 736 tooltipStr = reinterpret_cast<LPCTSTR>(env->GetStringChars(jtooltip, (jboolean *)NULL));736 tooltipStr = jsafe_cast<LPCTSTR>(env->GetStringChars(jtooltip, (jboolean *)NULL)); 737 737 trayIcon->SetToolTip(tooltipStr); 738 env->ReleaseStringChars(jtooltip, reinterpret_cast<const jchar *>(tooltipStr));738 env->ReleaseStringChars(jtooltip, jsafe_cast<const jchar *>(tooltipStr)); 739 739 ret: 740 740 env->DeleteGlobalRef(self); … … 857 857 trayIcon = (AwtTrayIcon *)pData; 858 858 859 captionStr = reinterpret_cast<LPCTSTR>(env->GetStringChars(jcaption, (jboolean *)NULL));860 textStr = reinterpret_cast<LPCTSTR>(env->GetStringChars(jtext, (jboolean *)NULL));861 msgTypeStr = reinterpret_cast<LPCTSTR>(env->GetStringChars(jmsgType, (jboolean *)NULL));859 captionStr = jsafe_cast<LPCTSTR>(env->GetStringChars(jcaption, (jboolean *)NULL)); 860 textStr = jsafe_cast<LPCTSTR>(env->GetStringChars(jtext, (jboolean *)NULL)); 861 msgTypeStr = jsafe_cast<LPCTSTR>(env->GetStringChars(jmsgType, (jboolean *)NULL)); 862 862 863 863 trayIcon->DisplayMessage(captionStr, textStr, msgTypeStr); 864 864 865 env->ReleaseStringChars(jcaption, reinterpret_cast<const jchar *>(captionStr));866 env->ReleaseStringChars(jtext, reinterpret_cast<const jchar *>(textStr));867 env->ReleaseStringChars(jmsgType, reinterpret_cast<const jchar *>(msgTypeStr));865 env->ReleaseStringChars(jcaption, jsafe_cast<const jchar *>(captionStr)); 866 env->ReleaseStringChars(jtext, jsafe_cast<const jchar *>(textStr)); 867 env->ReleaseStringChars(jmsgType, jsafe_cast<const jchar *>(msgTypeStr)); 868 868 ret: 869 869 env->DeleteGlobalRef(self); -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Unicode.cpp
r190 r195 36 36 int len = env->GetStringLength(jstr); 37 37 38 env->GetStringRegion(jstr, 0, len, reinterpret_cast<jchar*>(lpwstr));38 env->GetStringRegion(jstr, 0, len, jsafe_cast<jchar*>(lpwstr)); 39 39 lpwstr[len] = '\0'; 40 40 -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Unicode.h
r187 r195 47 47 #define TO_WSTRING(jstr) \ 48 48 ((jstr == NULL) ? NULL : \ 49 (JNI_J2WHelper1(env, (LPWSTR) alloca((env->GetStringLength(jstr)+1)*2), \49 (JNI_J2WHelper1(env, static_cast<LPWSTR>(alloca((env->GetStringLength(jstr)+1)*2)), \ 50 50 jstr) \ 51 51 )) -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp
r190 r195 171 171 { 172 172 if (getWinVer() >= 5 && procAddFontResourceEx != NULL) { 173 LP TSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, NULL);173 LPCTSTR file = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, fontName, NULL)); 174 174 (*procAddFontResourceEx)(file, FR_PRIVATE, NULL); 175 175 } … … 190 190 { 191 191 if (getWinVer() >= 5 && procRemoveFontResourceEx != NULL) { 192 LP TSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, NULL);192 LPCTSTR file = jsafe_cast<LPCTSTR>(JNU_GetStringPlatformChars(env, fontName, NULL)); 193 193 (*procRemoveFontResourceEx)(file, FR_PRIVATE, NULL); 194 194 } -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Window.cpp
r190 r195 596 596 GetLastError(), 597 597 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 598 (LPTSTR)&msgBuffer, // it's an output parameter when allocate buffer is used598 reinterpret_cast<LPTSTR>(&msgBuffer), // it's an output parameter when allocate buffer is used 599 599 0, 600 600 NULL); … … 1677 1677 int length = env->GetStringLength(title); 1678 1678 WCHAR *buffer = new WCHAR[length + 1]; 1679 env->GetStringRegion(title, 0, length, reinterpret_cast<jchar*>(buffer));1679 env->GetStringRegion(title, 0, length, jsafe_cast<jchar*>(buffer)); 1680 1680 buffer[length] = L'\0'; 1681 1681 VERIFY(::SetWindowTextW(w->GetHWnd(), buffer));
Note:
See TracChangeset
for help on using the changeset viewer.