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

String.stripIndent javadoc text is confusing about text blocks

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 15
    • core-libs
    • None

      The specification of String.stripIndent includes this example:

      ```

      Incidental white space is often present in a text block to align the content with the opening delimiter. For example, in the following code, dots represent incidental white space:

       String html = """
       ..............<html>
       .............. <body>
       .............. <p>Hello, world</p>
       .............. </body>
       ..............</html>
       ..............""";

      ```

      The implication is that the value of that text block includes the spaces that are rendered with dots. I think this was the case in preview versions of the text block feature, but, as finalized, the value of the text block is everything after the dots. The *compiler* effectively calls stripIndent. So this example is likely to confuse users, especially those coming from languages like Python or Kotlin where you do have to call the equivalent of stripIndent.

            bchristi Brent Christian
            emcmanus Eamonn McManus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: