Skip to content

Commit

Permalink
Force read of processorArchitecture member of SYSTEM_INFO union
Browse files Browse the repository at this point in the history
  • Loading branch information
dbwiddis authored and matthiasblaesing committed Sep 14, 2019
1 parent f7d3c94 commit 43cdb5c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Bug Fixes
* [#1127](https://github.com/java-native-access/jna/issues/1127): Windows needs a wide string in `c.s.j.p.win32.COM.IShellFolder#ParseDisplayName` - [@dbwiddis](https://github.com/dbwiddis).
* [#1128](https://github.com/java-native-access/jna/issues/1128): KEY_ALL_ACCESS value is incorrect in `c.s.j.p.win32.WinNT.java` - [@trevormaggs](https://github.com/trevormaggs).
* [#1133](https://github.com/java-native-access/jna/issues/1133): Ensure JARs created from the build system don't contain invalid `Info-ZIP Unicode Path` extra info - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#1134](https://github.com/java-native-access/jna/issues/1134): Read correct member of `WinBase.SYSTEM_INFO.processorArchitecture` union - [@dbwiddis](https://github.com/dbwiddis).

Release 5.4.0
=============
Expand Down
12 changes: 12 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/WinBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,18 @@ public static class ByReference extends UNION implements Structure.ByReference {
* Processor architecture (unnamed struct).
*/
public PI pi;

@Override
public void read() {
// dwOemID is obsolete but users may have come to rely on its value because it
// was initialized by default, so we retain its initialization for
// compatibility.
setType("dwOemID");
super.read();
// pi requires type defined for initialization as a structure.
setType("pi");
super.read();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ public void testGetSystemInfo() {
SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO();
Kernel32.INSTANCE.GetSystemInfo(lpSystemInfo);
assertTrue(lpSystemInfo.dwNumberOfProcessors.intValue() > 0);
// the dwOemID member is obsolete, but gets a value.
// the pi member is a structure and isn't read by default
assertEquals(lpSystemInfo.processorArchitecture.dwOemID.getLow(),
lpSystemInfo.processorArchitecture.pi.wProcessorArchitecture);
}

public void testGetSystemTimes() {
Expand Down

0 comments on commit 43cdb5c

Please sign in to comment.