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

javap fails to show the entire string with trailing space in constant pool

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8-pool, 11, 17, 19, 20, 21
    • tools
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      - OS and version: Ubuntu 18.04.6 LTS
      - CPU model: Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz
      - Java version:
      openjdk version "1.8.0_352"
      OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~18.04-b08)
      OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      Run `javap -c -v -p` on a compiled class file of a java source file that has a String with trailing spaces (e.g., "XXX "). The result does not show the entire "XXX " in the corresponding constant pool entry, instead, it is "XXX".

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a file `Test.java` with the following content:
      ```
      public class Test{
          public static void main(String[] args){
      System.out.println("XXX ");
          }
      }
      ```
      2. Run `javac Test.java`
      3. Run `javap -c -v -p Test.class`
      4. Check the #3 entry in the constant pool
      5. Note that the line of #3 does not show the trailing spaces for the String "XXX "

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      " #3 = String #18 // XXX "
      ACTUAL -
      " #3 = String #18 // XXX"

      ---------- BEGIN SOURCE ----------
      public class Test{
          public static void main(String[] args){
      System.out.println("XXX ");
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            adev Anupam Dev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: