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

LOGGING APIs: spec for constructors needs to specify illegal values

XMLWordPrintable

    • beta2
    • generic
    • generic
    • Verified



      Name: elR10090 Date: 06/15/2001



      The following is the spcification (from Merlin-b68) for two
      constructors
      java.util.logging.MemoryHandler() and
      java.util.logging.MemoryHandler(Handler, int, Level).

          public MemoryHandler()
          Create a MemoryHandler and configure it based on LogManager
      configuration
          properties.
          
          public MemoryHandler(Handler target, int size, Level pushLevel)
          Create a MemoryHandler.
          The MemoryHandler is configured based on LogManager properties (or
      their
          default values) except that the given pushLevel argument and
      buffer size
          argument are used.

          Parameters: target - the Handler to which to publish output.
                      size - the number of log records to buffer
                      pushLevel - message level to push on
                      
      Spec for MemoryHandler(Handler, int, Level) constructor does not
      define
      situation if size is negative. The current Logging API implementation
      throws unspecified NegativeArraySizeException.

      See the log:

      #java version "1.4.0-beta_refresh"
      #Java(TM) 2 Runtime Environment, Standard Edition (build
      1.4.0-beta_refresh-b68)
      #Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b68, mixed mode)
      #Unexpected exception for constructor MemoryHandler(Handler, int,
      Level) with size == -1.
      #java.lang.NegativeArraySizeException
      # at
      java.util.logging.MemoryHandler.init(MemoryHandler.java:106)
      # at
      java.util.logging.MemoryHandler.<init>(MemoryHandler.java:132)
      # at Test1.run(Test1.java:15)
      # at Test1.main(Test1.java:10)
      ## TEST FAILED.
      #status==97

      To reproduce the failure, please use 'doit1.sh' script found in the
      directory:

          /net/sqesvr.eng/export/vsn/GammaBase/Bugs/<this bug number>

      Use:

          doit1.sh $JAVA_HOME


      Spec for MemoryHandler() constructor also does not define situation if
      size is set in logging.properties file and is negative. The current
      Logging API implementation also throws unspecified
      NegativeArraySizeException.

      See the log:

      #java version "1.4.0-beta_refresh"
      #Java(TM) 2 Runtime Environment, Standard Edition (build
      1.4.0-beta_refresh-b68)
      #Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b68, mixed mode)
      #Unexpected exception for constructor MemoryHandler() with size == -1.
      #java.lang.NegativeArraySizeException
      # at
      java.util.logging.MemoryHandler.init(MemoryHandler.java:106)
      # at
      java.util.logging.MemoryHandler.<init>(MemoryHandler.java:101)
      # at Test2.run(Test2.java:14)
      # at Test2.main(Test2.java:9)
      ## TEST FAILED.
      #status==97

      To reproduce the failure, please use 'doit2.sh' script found in the
      directory:

          /net/sqesvr.eng/export/vsn/GammaBase/Bugs/<this bug number>

      Use:

          doit2.sh $JAVA_HOME

      I guess the specification should specify exceptions if the constructor
      throws them, even for negative values of size. I also believe that
      constructor
      should throw more describable exception, for example
      IllegalArgumentException.

      It is also highly desirable to specify all possible cases for size,
      for example when size == 0.

      ======================================================================

      Similar issues apply to some FileHandler constructors.

      graham.hamilton@Eng 2001-06-25

            ghamiltosunw Graham Hamilton (Inactive)
            latkinsunw Latkin Latkin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: