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

Always causes ArrayIndexOutOfBoundsException #1087

Closed
wants to merge 1 commit into from
Closed

Always causes ArrayIndexOutOfBoundsException #1087

wants to merge 1 commit into from

Conversation

ertauren
Copy link

@ertauren ertauren commented Apr 24, 2019

.toArray(new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[0]);

at this line, spesifiying Array's length as 0 does cause ArrayIndexOutOfBoundsException. Either need to alter Structure.java's toArray method or some change in here. I am bit new in java and github so there might be better solution than writing "((SYSTEM_LOGICAL_PROCESSOR_INFORMATION[])firstInformation).length" instead of "0". If my solution is wrong or there is better solution please consider this propose of file change as bug report.
If somehow this isn't bug please give me some pointers so that i can learn

https://github.com/java-native-access/jna/blob/db28278447a82bf7dd4e2fe8e73df80398c92235/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java#L675

at this line, spesifiying Array's length as 0 does cause ArrayIndexOutOfBoundsException. Either need to alter Structure.java's toArray method or some change in here. I am bit new in java and github so there might be better solution than writing "((SYSTEM_LOGICAL_PROCESSOR_INFORMATION[])firstInformation).length" instead of "0".  If there is better solution please consider this propose of file change as bug report.
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this pull request Apr 24, 2019
…rays

As a performance optimization calls to Collections#toArray where changed
from providing a correctly sized array to using a zero sized array.

See 07f3ce0

The change is invalid if the object toArray is called on is a Structure,
the calls just look the same. This changeset is a partial revert of the
above mentioned commit.

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

Please see here for a different PR: #1088 (the problem is a bit bigger).

matthiasblaesing added a commit to matthiasblaesing/jna that referenced this pull request Apr 25, 2019
…rays

As a performance optimization calls to Collections#toArray where changed
from providing a correctly sized array to using a zero sized array.

See 07f3ce0

The change is invalid if the object toArray is called on is a Structure,
the calls just look the same. This changeset is a partial revert of the
above mentioned commit.

Closes: java-native-access#1087
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this pull request Apr 26, 2019
…rays

As a performance optimization calls to Collections#toArray where changed
from providing a correctly sized array to using a zero sized array.

See 07f3ce0

The change is invalid if the object toArray is called on is a Structure,
the calls just look the same. This changeset is a partial revert of the
above mentioned commit.

Closes: java-native-access#1087
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 this pull request may close these issues.

None yet

2 participants