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

toString() methods for the XxxByReference classes #1179

Closed
michab66 opened this issue Apr 20, 2020 · 2 comments
Closed

toString() methods for the XxxByReference classes #1179

michab66 opened this issue Apr 20, 2020 · 2 comments

Comments

@michab66
Copy link

michab66 commented Apr 20, 2020

This is a request for a new feature.

Description

The use case is: being in the debugger, stepping through native code, having instances of XxxByReference, e.g. IntByReference. In this case it is in the debugger hard to get the value of the referenced Xxx, since the toString() offered by the instance is inherited from PointerType. So the information one gets offers a lot of information on the internal layout of the referenced object, but it is very hard to simply find the actual value.

We work around this inconvenience regularly by adding temporary code like

IntByReference theInteger = new IntByReference( 313 );
... // Call system api use and modify 'theInteger'.
// Get 'theInteger's value into a local variable.
int tmp = theInteger.getValue();
... // And on it goes.

The proposal is to add a toString()-operation to the XxxByReference-classes in the com.sun.jna.ptr package, each displaying the respective value in hex format. The hex format has the advantage that the sign bits are explicitly visible.

Impact on existing code

As far as we can see this would have no negative consequences, since the object layout of an IntByReference is clear and has no potential for errors if JNA is implemented properly.

The positive consequence is that the value is visible in the debugger on the first glance, without any hassle.

The operation can be implemented as common code so that the functionality is available on all platforms.

References

@dbwiddis
Copy link
Contributor

This was completed in #1182 and can be closed.

@matthiasblaesing
Copy link
Member

Thanks for the reminder :-)

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

Successfully merging a pull request may close this issue.

3 participants