GitHub user AlexShvedoff opened a pull request:

    https://github.com/apache/metamodel/pull/175

    array.set() on a new ArrayList() crashes with index out of bound

    I'm surprised this works for anyone else, but at least on MacOS JDK 
1.8.0_92 having e.g:
    
    List columns = new ArrayList(5);
    columns.set(0, "foo");
    
    ...crashes with an index out of bounds due to the fact that although the 
desired capacity of 5 has been specified, the size is zero when set() is called 
and so it crashes because no element exists at index 0.  See 
https://stackoverflow.com/questions/8896758/initial-size-for-the-arraylist

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/AlexShvedoff/metamodel master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/metamodel/pull/175.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #175
    
----
commit 89e723d7285caa48a2daa7240a2487ba2d996c99
Author: Alex Shvedoff <[email protected]>
Date:   2017-12-15T01:28:13Z

    array.set() on a new ArrayList() crashes with index out of bound
    
    I'm surprised this works for anyone else, but at least on MacOS JDK 
1.8.0_92 having e.g:
    
    List columns = new ArrayList(5);
    columns.set(0, "foo");
    
    ...crashes with an index out of bounds due to the fact that although the 
desired capacity of 5 has been specified, the size is zero when set() is called 
and so it crashes because no element exists at index 0.  See 
https://stackoverflow.com/questions/8896758/initial-size-for-the-arraylist

----


---

Reply via email to