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

JShell LocalExecutionControl should allow decorating the execution task

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 25
    • tools
    • None
    • jdk-25+9-73-gba28119642a

    • generic
    • generic

      JShell local execution mode is useful for implementing ad hoc tasks within a single application. For example, a Java application may want add support for evaluating Java expressions to its command line interface (CLI).

      In such cases, there is often a need to "decorate" the execution of each snippet by wrapping its execution somehow. For example, a database application may want to automatically open a transaction for the duration of a snippet's execution and make it available to the snippet via its standard mechanism (e.g., ThreadLocal variable, Hibernate session, etc). Another example is an application that wants to log something, or track time elapsed, at the the start and stop of every snippet execution.

      To support such use cases, JShell's LocalExecutionControl should provide a subclass hook that allows the subclass to take action anytime a snippet starts or stops execution.

      Currently LocalExecutionControl provides methods clientCodeEnter() and clientCodeLeave(), but these are not useful for the situations described above, because those methods are not invoked in the thread that actually executes the snippet; instead, they are invoked in the thread that creates the thread that executes the snippet.

            acobbs Archie Cobbs
            acobbs Archie Cobbs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: