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

unclear spec for .beancontext.BeanContextSupport.add/remove

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: sdC67446 Date: 06/09/98


      The spec for method
      java.beans.beancontext.BeanContextSupport.add(Object targetChild)
      says nothing about method's behavior if validatePendingAdd(..) returns false;
      The doc for validatePendingAdd(Object targetChild) says:

      protected boolean validatePendingAdd(Object targetChild)
            Subclasses of this class may override, or envelope,
            this method to add validation behavior for the
            BeanContext to examine child objects immediately
            prior to their being added to the BeanContext.

      Currently add(Object targetChild) throws undocumented IllegalStateException
      if validatePendingAdd(targetChild) returns false;

      The same situation exists with remove(Object targetChild) and
      validatePendingRemove() accordingly.

      --------------The doc also says:--------------
      public boolean add(Object targetChild)

            Adds/nests a child within this BeanContext
            Invoked as a side effect of java.beans.Beans.instantiate().

            Parameters:
                  targetChildren - The child objects to nest within this BeanContext

      -----Here is the test demonstrating the bug:------
      import java.beans.beancontext.*;
      import java.beans.*;
      import java.util.*;

      public class Test extends BeanContextSupport {

          public boolean validatePendingAdd(Object targetChild) {
              return false;
          }

          public Test() {
              super();
          }
          
          public static void main(String[] args) {
              Test bcs = new Test();
              bcs.add(new Integer(0));
          }
      }
      -----Output from test:--------------------
      Exception in thread "main" java.lang.IllegalStateException
              at java.beans.beancontext.BeanContextSupport.add(Compiled Code)
              at Test.main(Compiled Code)
      --------------------------------------------------
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              jhosunw Jamie Ho (Inactive)
              Reporter:
              sdmitriesunw Sergei Dmitriev (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: