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

java.lang.ArrayIndexOutOfBoundsException in java.awt.Container

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.1.5
    • client-libs
    • generic
    • generic

      ==========================================================================
      carlos.lucasius@canada 1998-05-08:

      The bug is easy to track down, given the following trace.
      It comes from a bad test in Container.java:300 ->

      if (index == -1 || index == ncomponents) {

      must become:

      if (index == -1 || index >= ncomponents) {


      $ cat group.java
      import java.awt.*;

      public class group {

          public static void main(String [] args) {
              Container cont = new Container () { };
              Component comp = new Component () { };

              cont.add(comp);
              cont.add(comp,1);
          }
      }
      $ javac group.java
      $ java group
      java.lang.ArrayIndexOutOfBoundsException
              at java.awt.Container.addImpl(Container.java:303)
              at java.awt.Container.add(Container.java:204)
              at group.main(group.java:10)
      $

            son Oleg Sukhodolsky (Inactive)
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: