SegmentAllocator doc functional interface example is misleading

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The SegmentAllocator class Javadoc says "SegmentAllocator is a functional interface [...]" and then contains this Java snippet:
      ```
      SegmentAllocator autoAllocator = (byteSize, byteAlignment) -> Arena.ofAuto().allocate(byteSize, byteAlignment);
      ```

      This is rather misleading, because Arena implements SegmentAllocator, so this snippet could be simplified a lot to just `SegmentAllocator autoAllocator = Arena.ofAuto()`.

      Why is this is problem?
      - Many APIs take a SegmentAllocator as parameter, so users might encounter it first before the Arena class
      - Users might think the currently shown snippet is the proper way of obtaining a SegmentAllocator, which leads to unnecessarily complex code

      Suggested changes:
      - Mention Arena more prominently in the SegmentAllocator docs, because for most use cases an Arena will be the default choice
      - Remove the "SegmentAllocator is a functional interface [...]" section or show a more realistic / useful example?

            Assignee:
            Maurizio Cimadamore
            Reporter:
            Webbug Group
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: