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

AbstractScriptEngine.getScriptContext creation of SimpleScriptContext is inefficient

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 9, 10
    • Fix Version/s: 11
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b11
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      Every time the method getScriptContext is called, a new instance of SimpleScriptContext is created. This calls
              reader = new InputStreamReader(System.in);
              writer = new PrintWriter(System.out , true);
              errorWriter = new PrintWriter(System.err, true);
      immediately to be replaced by
              ctxt.setReader(context.getReader());
              ctxt.setWriter(context.getWriter());
              ctxt.setErrorWriter(context.getErrorWriter());
      The creation of the reader and writers causes significant overhead in the sense that these objects need to be immediately garbage collected again.
      When this method is called a lot, a new Constructor for SimpleScriptContext that allows the passing of the reader and writers would be a lot more efficient.


      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Activity

            People

            • Assignee:
              hannesw Hannes Wallnoefer
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: