RFR: JDK-8311113: Remove invalid pointer cast and clean up setLabel() in awt_MenuItem.cpp [v2]
Harshitha Onkar
honkar at openjdk.org
Wed Aug 23 22:17:22 UTC 2023
> In awt_MenuItem.cpp (712,22): ` mii.dwTypeData = (LPTSTR)(*sb)` produces invalid pointer cast warning when complied on clang and moreover this is a no-op.
>
> `mii.dwTypeData` is used only when **MIIM_STRING** flag is set in the fMask (as per [Docs](https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-menuiteminfoa)), which is not the case in JDK [Ln#705](https://github.com/openjdk/jdk/blob/e56d3bc2dab3d32453b6eda66e8434953c436084/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp#L706). Hence the assignment ` mii.dwTypeData = (LPTSTR)(*sb)` is not required and so is the label parameter. Additionally necessary cleanup is done at the following places -
>
> - WMenuItemPeer.java - to the native function call
> - awt_MenuItem.cpp - `WMenuItemPeer__1setLabel() ,_SetLabel(), SetLabel()`
> - awt_MenuItem.h
>
> Added a test which checks setLabel() functionality on Menu, MenuItem and PopupMenu.
Harshitha Onkar has updated the pull request incrementally with two additional commits since the last revision:
- changed MIIM_TYPE to MIIM_FTYPE for fMask
- Test updated to compare before and after screenshots
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/15276/files
- new: https://git.openjdk.org/jdk/pull/15276/files/5917e73e..c10275c2
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=15276&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=15276&range=00-01
Stats: 125 lines in 2 files changed: 32 ins; 46 del; 47 mod
Patch: https://git.openjdk.org/jdk/pull/15276.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/15276/head:pull/15276
PR: https://git.openjdk.org/jdk/pull/15276
More information about the client-libs-dev
mailing list