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

jshell tool: toString-representation of instance appears to be inconsistent

XMLWordPrintable

    • b120
    • 9
    • x86

      FULL PRODUCT VERSION :
      > java --version
      java 9-ea
      Java(TM) SE Runtime Environment (build 9-ea+156)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+156, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 10, 64bit

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      jshell

      A DESCRIPTION OF THE PROBLEM :
      The output provided by toString is truncated when an instance is created with `new`. This appears to be inconsistent with just printing the instance after that.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Save code given in Bugreport.java to open it with jshell.

      jshell> /o Bugreport.java //printing board for nine men's morris

      class Board {
          @Override
          public String toString() {
              String s = "";
              s += String.format(".-----.-----.\n");
              s += String.format("| | |\n");
              s += String.format("| .---.---. |\n");
              s += String.format("| | | | |\n");
              s += String.format("| | .-.-. | |\n");
              s += String.format("| | | | | |\n");
              s += String.format(".-.-. .-.-.\n");
              s += String.format("| | | | | |\n");
              s += String.format("| | .-.-. | |\n");
              s += String.format("| | | | |\n");
              s += String.format("| .---.---. |\n");
              s += String.format("| | |\n");
              s += String.format(".-----.-----.");
              return s;
          }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      jshell> b // output not truncated
      b ==> .-----.-----.
      | | |
      | .---.---. |
      | | | | |
      | | .-.-. | |
      | | | | | |
      .-.-. .-.-.
      | | | | | |
      | | .-.-. | |
      | | | | |
      | .---.---. |
      | | |
      .-----.-----.


      ACTUAL -
      jshell> Board b = new Board() // output truncated
      b ==> .-----.-----.
      | | |
      | .---.---. |
      | | | ... | |
      .-----.-----.

      REPRODUCIBILITY :
      This bug can be reproduced always.

            rfield Robert Field (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: