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

String(byte[], String enc) misses NPE for enc == null

    XMLWordPrintable

Details

    • beta3
    • generic, x86, sparc
    • generic, linux, solaris_8
    • Verified

    Description



      Name: skR10005 Date: 08/13/2001


      The following JCK-tests
      api/java_lang/String/i18n.html#i18nCtor[String1206]
      api/java_lang/String/i18n.html#i18nCtor[String1224]
      fail on jdk1.4beta-b75.

      To reproduce the failure the following simple example can be used:
      =================================================================
      public class A {
          public static void main(String[] argv) {
              byte[] bytes = {(byte)'b'};
              try {
                  new String(bytes, (String)null);
                  System.out.println("No exception");
              } catch (Exception e) {
                  System.out.println(e);
              }
          }
      }

      =================================================================
      $java -version
      java version "1.4.0-beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b75)
      Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b75, mixed mode)
      $java -cp . A
      No exception

      At the same time:
      $java -version
      java version "1.4.0-beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b74)
      Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b74, mixed mode)
      $java -cp . A
      java.lang.NullPointerException

      Despite the API specification for String(byte[], String enc) constructor
      does not say anything about throwing NPE, this bug should be fixed because
      this is a regression. All older jdk versions threw NPE.

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

      Attachments

        Issue Links

          Activity

            People

              iris Iris Clark
              serjsunw Serj Serj (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: