Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advapi32Util.registryGetStringValue Javadoc says only REG_SZ values are allowed, but implementation also allows REG_EXPAND_SZ #1513

Open
sratz opened this issue Mar 24, 2023 · 1 comment

Comments

@sratz
Copy link
Contributor

sratz commented Mar 24, 2023

The Javadoc of Advapi32Util.registryGetStringValue()
https://github.com/java-native-access/jna/blob/e96f30192e9455e7cc4117cce06fc3fa80bead55/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java#LL754C32-L754C32
says

Get a registry REG_SZ value.,

however the implementation
https://github.com/java-native-access/jna/blob/e96f30192e9455e7cc4117cce06fc3fa80bead55/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java#LL772C52-L772C52
also returns the value if its type is

REG_EXPAND_SZ.

My expectation was that REG_EXPAND_SZ would be rejected for symmetry reasons:

  • #registrySetStringValue() <- REG_SZ
  • #registryGetStringValue() -> REG_SZ / REG_EXPAND_SZ
  • #registrySetExpandableStringValue() <- REG_EXPAND_SZ
  • #registryGetExpandableStringValue() -> REG_EXPAND_SZ

Is the implementation incorrect or is this the expected behavior and the Javadoc should be adjusted?

@dbwiddis
Copy link
Contributor

Is the implementation incorrect or is this the expected behavior

Well it's probaby incorrect, but removing that behavior would probably break compatibility, so we're stuck with it. It's been that way for 11 years, so I doubt there's any value in changing it now.

and the Javadoc should be adjusted?

Given we have another documented method for REG_EXPAND_SZ I'd just leave it as-is.

I'll note the exception message for registryGetExpandableStringValue() is wrong as it refers to REG_SZ, probably as a result of copy-paste. There may be other such errors if you're eager to submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants