I've been trying to get the JDK to compile with the new /permissive- switch in 
VS2017 (https://devblogs.microsoft.com/cppblog/permissive-switch/) however 
there have been a few issues in various parts of the code.

While testing this, I found some issues in the AWT code.  In one case we name a 
function with the class:: prefix when the function is declared inline in the 
class definition.  Other cases include where we are assigning string literals 
to non-const char* variables.  I took some time to fix these and attached a 
patch.  Let me know if there are any comments.

c:\Users\Andrew\Documents\mercurial\openjdk\jdk\src\java.desktop\windows\native\libawt\windows\awt.h(343):
 error C2440: 'return': cannot convert from 'const unsigned short *' to 'LPWSTR'
c:\Users\Andrew\Documents\mercurial\openjdk\jdk\src\java.desktop\windows\native\libawt\windows\awt.h(343):
 note: Conversion from string literal loses const qualifier (see 
/Zc:strictStrings)
c:\users\andrew\documents\mercurial\openjdk\jdk\src\java.desktop\windows\native\libawt\windows\awt_Component.h(455):
 error C2061: syntax error: identifier 'javaKey'
c:\users\andrew\documents\mercurial\openjdk\jdk\src\java.desktop\windows\native\libawt\windows\awt_Component.h(455):
 error C4430: missing type specifier - int assumed. Note: C++ does not support 
default-int

Thanks,

-Andrew
ÿþdiff --git 
a/src/java.desktop/windows/native/libawt/windows/awt.h
 
b/src/java.desktop/windows/native/libawt/windows/awt.h

--- 
a/src/java.desktop/windows/native/libawt/windows/awt.h

+++ 
b/src/java.desktop/windows/native/libawt/windows/awt.h

@@ -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; }

 };

 

diff --git 
a/src/java.desktop/windows/native/libawt/windows/awt_Component.h
 
b/src/java.desktop/windows/native/libawt/windows/awt_Component.h

--- 
a/src/java.desktop/windows/native/libawt/windows/awt_Component.h

+++ 
b/src/java.desktop/windows/native/libawt/windows/awt_Component.h

@@ -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);

Reply via email to