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

AbstractPipeline invokes overridden method in constructor

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 22
    • None
    • core-libs
    • None

      Currently java.util.stream.AbstractPipeline's constructor calls the designed-to-be-overridden `opIsStateful()` which means that since the AbstractPipeline constructor runs before the subclass' initialization logic, that means that any implementations of `opIsStateful()` must only rely on global state and/or constants.

      Furthermore, `opIsStateful()` is only used for parallel evaluation, and currently requires a boolean field per AbstractPipeline (`hasAnyStateful`) regardless of whether they ever need to evaluate in parallel or not.

      It should be possible to avoid needing the `hasAnyStateful` field, as well as avoiding to call `opIsStateful()` in the AbstractPipeline constructor, so that implementations thereof can use instance state to produce their values, and only invoke it for parallel evaluations.

            vklang Viktor Klang
            vklang Viktor Klang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: