8225032: Fix some C++ conformance issues in AWT Windows code
authorserb
Thu, 30 May 2019 17:14:06 -0700
changeset 55190 55dc1385d1b7
parent 55189 fdaf7287ea3a
child 55191 feb860d41612
8225032: Fix some C++ conformance issues in AWT Windows code Reviewed-by: prr, serb Contributed-by: andrewluotechnologies@outlook.com
src/java.desktop/windows/native/libawt/windows/awt.h
src/java.desktop/windows/native/libawt/windows/awt_Component.h
src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp
--- a/src/java.desktop/windows/native/libawt/windows/awt.h	Thu May 30 11:52:23 2019 -0700
+++ b/src/java.desktop/windows/native/libawt/windows/awt.h	Thu May 30 17:14:06 2019 -0700
@@ -337,7 +337,7 @@
 protected:
     LPWSTR m_pStr;
     jsize  m_dwSize;
-    LPWSTR getNonEmptyString() {
+    LPCWSTR getNonEmptyString() {
         return (NULL==m_pStr)
                 ? L""
                 : m_pStr;
@@ -378,9 +378,9 @@
         m_pStr = (LPWSTR)SAFE_SIZE_ARRAY_REALLOC(safe_Realloc, m_pStr, m_dwSize+1, sizeof(WCHAR) );
     }
     //we are in UNICODE now, so LPWSTR:=:LPTSTR
-    operator LPWSTR() { return getNonEmptyString(); }
+    operator LPCWSTR() { return getNonEmptyString(); }
     operator LPARAM() { return (LPARAM)getNonEmptyString(); }
-    void *GetData() { return (void *)getNonEmptyString(); }
+    const void *GetData() { return (const void *)getNonEmptyString(); }
     jsize  GetSize() { return m_dwSize; }
 };
 
--- a/src/java.desktop/windows/native/libawt/windows/awt_Component.h	Thu May 30 11:52:23 2019 -0700
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Component.h	Thu May 30 17:14:06 2019 -0700
@@ -449,7 +449,7 @@
     static void JavaKeyToWindowsKey(UINT javaKey, UINT *windowsKey, UINT *modifiers, UINT originalWindowsKey);
     static void UpdateDynPrimaryKeymap(UINT wkey, UINT jkeyLegacy, jint keyLocation, UINT modifiers);
 
-    INLINE static void AwtComponent::JavaKeyToWindowsKey(UINT javaKey,
+    INLINE static void JavaKeyToWindowsKey(UINT javaKey,
                                        UINT *windowsKey, UINT *modifiers)
     {
         JavaKeyToWindowsKey(javaKey, windowsKey, modifiers, IGNORE_KEY);
--- a/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp	Thu May 30 11:52:23 2019 -0700
+++ b/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp	Thu May 30 17:14:06 2019 -0700
@@ -130,7 +130,7 @@
     DWORD cbBuf = *pcbBuf, dummyWord = 0;
 
     JavaStringBuffer printerNameBuf(env, printerName);
-    LPTSTR lpcPrinterName = (LPTSTR)printerNameBuf;
+    LPCTSTR lpcPrinterName = (LPCTSTR)printerNameBuf;
     DASSERT(lpcPrinterName != NULL);
 
     // For NT, first do a quick check of all remote and local printers.