Skip to content

Always causes ArrayIndexOutOfBoundsException#1087

Closed
ertauren wants to merge 1 commit intojava-native-access:masterfrom
ertauren:patch-1
Closed

Always causes ArrayIndexOutOfBoundsException#1087
ertauren wants to merge 1 commit intojava-native-access:masterfrom
ertauren:patch-1

Conversation

@ertauren
Copy link
Copy Markdown

@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
Copy Markdown
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.

2 participants