Skip to content

REG_NOTIFY_THREAD_AGNOSTIC should be supported #1333

@Dani-Hub

Description

@Dani-Hub

Provide complete information about the problem

  1. Version of JNA and related jars: 5.8.0
  2. Version and vendor of the java virtual machine: Java-11 AdoptOpenJDK
  3. Operating system: Windows 10
  4. System architecture (CPU type, bitness of the JVM): JVM: 64-bit, processor Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz, 3301 MHz, 4 Kern(e), 4 logische(r) Prozessor(en)
  5. Complete description of the problem:
    Starting with Windows 8, the additional notification filter constant REG_NOTIFY_THREAD_AGNOSTIC has been added, which is used as possible control argument for RegNotifyChangeKeyValue's dwNotifyFilter function argument (see nf-winreg-regnotifychangekeyvalue) and whose underlying integral value has the value 0x10000000 (specified on the page linked above). This constant is currently missing in the existing set of REG_NOTIFY_CHANGE_* constants in com.sun.jna.platform.win32.WinNT. In addition to the lack of the constant, the second problem is, that for Windows systems of at least Windows 8, the existing combined constant, which is currently defined as
int REG_LEGAL_CHANGE_FILTER = REG_NOTIFY_CHANGE_NAME
            | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET
            | REG_NOTIFY_CHANGE_SECURITY; 

is incorrect, because it needs to take the additional value of REG_NOTIFY_THREAD_AGNOSTIC into account.
6. Steps to reproduce:
Try to compile the following Java code:

final int notifyFilter = WinNT.REG_NOTIFY_THREAD_AGNOSTIC;

The code is rejected.
The suggested fix consists of two changes:
a) Add the following additional constant to com.sun.jna.platform.win32.WinNT:

    int REG_NOTIFY_CHANGE_NAME = 0x00000001;
    int REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002;
    int REG_NOTIFY_CHANGE_LAST_SET = 0x00000004;
    int REG_NOTIFY_CHANGE_SECURITY = 0x00000008;
+   int REG_NOTIFY_THREAD_AGNOSTIC = 0x10000000; 

b) Update the value of the existing constant REG_LEGAL_CHANGE_FILTER in com.sun.jna.platform.win32.WinNT:

int REG_LEGAL_CHANGE_FILTER = REG_NOTIFY_CHANGE_NAME
            | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET
-           | REG_NOTIFY_CHANGE_SECURITY; 
+           | REG_NOTIFY_CHANGE_SECURITY | REG_NOTIFY_THREAD_AGNOSTIC;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions