Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8173706

Is able to set a negative j.u.Vector size in JDK9 b151

    Details

    • Subcomponent:
    • Introduced In Build:
      b151
    • Resolved In Build:
      b156
    • Verification:
      Verified

      Backports

        Description

        In JDK9b151
        Vector::setSize(negative) throws ArrayIndexOutOfBoundsException on the first attempt but it also sets the size to the passed negative value.

        Consider the following code

        =========
        public class NegativeSize {
            public static void main(String[] args) {
                java.util.Vector vector = new java.util.Vector<>();
                setNegativeSize(vector);
                setNegativeSize(vector);
            }

            private static void setNegativeSize(java.util.Vector vector) {
                try {
                    System.err.println("trying Vector::setSize(-1)");
                    vector.setSize(-1);
                    System.err.println("No exception thrown");
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.err.println("OK. AIOOBE as expected.");;
                }
                System.err.println("and Vector::size() = " + vector.size());
            }
        }
        =========

        For JDK9b150:

        trying Vector::setSize(-1)
        OK. AIOOBE as expected.
        and Vector::size() = 0
        trying Vector::setSize(-1)
        OK. AIOOBE as expected.
        and Vector::size() = 0

        For JDK9b151:

        trying Vector::setSize(-1)
        OK. AIOOBE as expected.
        and Vector::size() = -1
        trying Vector::setSize(-1)
        No exception thrown
        and Vector::size() = -1

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  smailar Sharanaprasad Mailar (Inactive)
                  Reporter:
                  dbessono Dmitry Bessonov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: