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

java.util.logging.Level.parse does not throw IAE for "unknown" names

XMLWordPrintable

    • b42
    • sparc
    • solaris_2.6, solaris_7
    • Verified



      Name: sdR10048 Date: 12/18/2003


      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b31"
      JCK : 1.5
      Platform[s] : Solaris
      switch/Mode :
      JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
      Failing Test [s] :
      api/java_util/logging/Level/index.html#Parse[Level2009]


      Specification excerpt:
      ======================
      --------- J2SE API spec v.1.5 ---------
      ...
      public static Level parse(String name)
                         throws IllegalArgumentException

      Parse a level name string into a Level.

      The argument string may consist of either a level name or an integer value.

      For example:
      "SEVERE"
      "1000"

      Parameters:
          name - string to be parsed

      Returns:
          The parsed value. Passing an integer that corresponds to a known name
          (eg 700) will return the associated name (eg CONFIG). Passing an integer
          that does not (eg 1) will return a new level name initialized to that value.

      Throws:
          NullPointerException - if the name is null

          IllegalArgumentException - if the value is not valid. Valid values are integers between
              Integer.MIN_VALUE and Integer.MAX_VALUE, and all known level names.
              Known names are the levels defined by this class (i.e. FINE, FINER, FINEST),
              or new levels defined by subclasses.

      ...
      ---------- end-of-excerpt ---------------

      Problem description
      ===================
      The designated method does not throw IllegalArgumentException with "unknown"
      level name in case some level with such "unknown" name has been created before.
      See demo.

      This causes JCK testcase to fail in singleJVM mode:
      api/java_util/logging/Level/index.html#Parse[Level2009]
          
      Minimized test:
      ===============
      ------- J.java -------
      import java.util.logging.*;

      public class J extends Level {
          public J(String name, int value) {
              super(name, value);
          }
          public static void main(String[] args) {
              System.out.println("-----------");
              try {
                  System.out.println( Level.parse("a") );
              } catch (Exception e) {
                  e.printStackTrace();
              }
              new J("a", 11);
              System.out.println("-----------");
              System.out.println( Level.parse("a") );
          }
      }

      ------- end-of-J.java -------

      Minimized test output:
      ======================
      ] (dsv@archer) ~/tmp
      ] java -showversion J
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b31)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b31, mixed mode)

      -----------
      java.lang.IllegalArgumentException: Bad level "a"
              at java.util.logging.Level.parse(Level.java:335)
              at J.main(J.java:10)
      -----------
      a


      JCK test source location:
      ==========================
      /java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests
          
      ======================================================================

            caustinsunw Calvin Austin (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: