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

Deprecate for removal the jrunscript tool

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 24
    • tools
    • None
    • behavioral
    • minimal
    • Hide
      The usages of jrunscript is expected to be very minimal. The new warning message that is printed after this change could in theory impact usages where such messages aren't expected in the output of this tool. However, given the limited usage of this tool, the practical impact of this change is expected to be minimal.
      Show
      The usages of jrunscript is expected to be very minimal. The new warning message that is printed after this change could in theory impact usages where such messages aren't expected in the output of this tool. However, given the limited usage of this tool, the practical impact of this change is expected to be minimal.
    • Other
    • JDK

      Summary

      A deprecation for removal warning message will be printed whenever the jrunscript tool is launched.

      Problem

      The JDK ships with a jrunscript tool in $JAVA_HOME/bin/ directory. This tool was introduced in Java 6 through https://bugs.openjdk.org/browse/JDK-6265810. The goal, as noted in that issue's description, was to provide a read-eval-print scripting shell for users to experiment/explore scripting language(s) through the javax.script API. This tool, as noted in its man page specification https://docs.oracle.com/en/java/javase/23/docs/specs/man/jrunscript.html has always been experimental and unsupported.

      In Java 15, we removed Nashorn - the sole implementation of a script engine, from the JDK https://bugs.openjdk.org/browse/JDK-8241749. After its removal, the JDK no longer includes any script engine implementations. As a result, including the jrunscript tool within the JDK is no longer of added value. There are also no plans to support or enhance this tool on a ongoing basis. In its current form, the default use of this tool in the current JDK version leads to an error message being printed and the tool exiting with a non-zero exit code:

      $> jrunscript
      script engine for language js can not be found
      echo $?
      8

      The jrunscript tool could be launched with a classpath containing an script engine implementation and thus could still be used for evaluating the scripts:

      $> jrunscript  -cp lib/script.jar:rhino1.7.12/lib/rhino-1.7.12.jar  -e "print('hello world')"
      hello world

      However, there are no plans to continue supporting this experimental tool just for that use case.

      Solution

      The jrunscript tool will be updated to print a deprecation for removal warning in preparation for its removal from a future JDK release.

      Launching jrunscript will now additionally print the following deprecation warning:

      $> jrunscript
      Warning: jrunscript is deprecated and will be removed in a future release.
      script engine for language js can not be found

      Specification

      diff --git a/src/java.scripting/share/classes/module-info.java b/src/java.scripting/share/classes/module-info.java
      index 4367a55a5a1e1..97d30f69c5a35 100644
      --- a/src/java.scripting/share/classes/module-info.java
      +++ b/src/java.scripting/share/classes/module-info.java
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * This code is free software; you can redistribute it and/or modify it
      @@ -30,6 +30,8 @@
        * command-line script shell, <em>{@index jrunscript jrunscript tool}</em>,
        * that supports executing JavaScript and other languages if its corresponding
        * script engine is installed.
      + * <p> The {@code jrunscript} tool is deprecated and will be removed
      + * in a future release.
        *
        * @toolGuide jrunscript
        *
          diff --git a/src/java.scripting/share/man/jrunscript.1 b/src/java.scripting/share/man/jrunscript.1
      --- a/src/java.scripting/share/man/jrunscript.1
      +++ b/src/java.scripting/share/man/jrunscript.1
      @@ -1,4 +1,4 @@
      -.\" Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
      +.\" Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
       .\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       .\"
       .\" This code is free software; you can redistribute it and/or modify it
      @@ -46,6 +46,7 @@ and batch modes
       \f[B]Note:\f[R]
       .PP
       This tool is \f[B]experimental\f[R] and unsupported.
      +It is deprecated and will be removed in a future release.
       .PP
       \f[V]jrunscript\f[R] [\f[I]options\f[R]] [\f[I]arguments\f[R]]
       .TP

            jpai Jaikiran Pai
            jpai Jaikiran Pai
            Alan Bateman, Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: