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

(bf) Consider removing blank lines from generated Buffer sources

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None

      Description

      Colleague Tobias Thierer writes:

      ---
      OpenJDK's build system includes some "gensrc" rules that process a single .template file to generate multiple .java files. This is used for example for the java.nio Buffers classes.

      By default, the tool (Spp) that processes the templates inserts empty lines in certain cases around conditional sections of the template that aren't included in all output files.

      Most gensrc rules pass the parameter "-nel" to cause Spp to not insert these empty lines; however it is missing from make/gensrc/GensrcBuffer.gmk which generates the java.nio Buffer classes.

      The attached 2-line patch makes GensrcBuffer.gmk also pass this command line flag to make the generated files more readable (not containing hundreds of redundant empty lines).

      ---

      diff -r 36ca515343e0 make/gensrc/GensrcBuffer.gmk
      --- a/make/gensrc/GensrcBuffer.gmk Thu Jun 21 08:58:59 2018 -0300
      +++ b/make/gensrc/GensrcBuffer.gmk Wed Jul 18 18:16:54 2018 +0100
      @@ -162,6 +162,7 @@
         $1_nbytes := $5
         $1_nbytesButOne := $6
         $1_CMD := $(TOOL_SPP) \
      + -nel \
           -Dtype=$$($1_type) \
           -DType=$$($1_Type) \
           -Dfulltype=$$($1_fulltype) \
      @@ -231,6 +232,7 @@
       
         $$($1_DST): $$($1_DEP) $(GENSRC_BUFFER_DST)/_the.buffer.dir
        $(TOOL_SPP) < $$($1_SRC) > $$($1_OUT).tmp \
      + -nel \
        -K$$($1_type) \
        -K$$($1_category) \
        -K$$($1_streams) \

      ---

      Martin says: I've been hacking on nio X-Buffer for decades and didn't know about spp's -nel. The only reason I can think of to not do this is to keep line numbers consistent with X-Buffer; but if you care about line numbers you probably have the generated sources anyways.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bpb Brian Burkhalter
              Reporter:
              martin Martin Buchholz
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: