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

Inconsistent String creation for UTF-8 encoding

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 8u11
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.8.0_11"
      Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      This issue prevents me to decode and decrypt a hash for a password when upgrading to java 8

      REGRESSION. Last worked in version 7u55

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.7.0_55"
      Java(TM) SE Runtime Environment (build 1.7.0_55-b14)
      Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode, sharing)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the following code on java 7 (or 6) and then on java 8:
              byte[] array = new byte[3];
              array[0] = (byte) -19;
              array[1] = (byte) -69;
              array[2] = (byte) -100;

              String str = new String(array, "UTF-8");
              for (char c : str.toCharArray()) {
                  System.out.println((int) c);
              }

      java 8 result:
      65533
      java7 result:
      57052



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
              byte[] array = new byte[3];
              array[0] = (byte) -19;
              array[1] = (byte) -69;
              array[2] = (byte) -100;

              String str = new String(array, "UTF-8");
              for (char c : str.toCharArray()) {
                  System.out.println((int) c);
              }

      ---------- END SOURCE ----------

            sherman Xueming Shen
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: