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

WORDByReference.getValue() cause boundsCheck error at runtime #795

Closed
kdeines opened this issue Apr 25, 2017 · 2 comments
Closed

WORDByReference.getValue() cause boundsCheck error at runtime #795

kdeines opened this issue Apr 25, 2017 · 2 comments

Comments

@kdeines
Copy link

kdeines commented Apr 25, 2017

I want to report a problem that I have fought for the last day or so.
WORDByReference TFS=new WORDByReference();
TFS.setValue(new WORD (10000));
System.out.println( "TFS="+ TFS.getPointer().getShort(0));//works shows a value of 10000
System.out.println( "TFS="+ TFS.getValue());//gives error
The line using TFS.getValue() causes an Memory.boundsCheck error at run time.
The line using TFS.getPointer().getShort(0) works.

The code for getValue in the WORDByReference Class is
public WORD getValue() {
return new WORD(getPointer().getInt(0));
}
shouldn't it be
public WORD getValue() {
return new WORD(getPointer().getShort(0));
}
I am no Java expert, but makes sense to me.
Thank you, Kent

matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Apr 26, 2017
WORD is defined to hold 16 bit on windows, so it needs to be accessed 
as short (getShort()).

Closes: java-native-access#795
@matthiasblaesing
Copy link
Member

@kdeines your assessment is correct. I pushed a fix.

@kdeines
Copy link
Author

kdeines commented Apr 26, 2017 via email

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