changeset 7750:24bda55fca48

8021773: print function as defined by jrunscript's init.js script is incompatible with nashorn's definition Reviewed-by: hannesw, lagergren
author sundar
date Mon, 29 Jul 2013 21:39:21 +0530
parents 5d4a35823071
children e83fc6d9cf03
files src/share/classes/com/sun/tools/script/shell/init.js
diffstat 1 files changed, 7 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/script/shell/init.js	Sat Jul 27 12:26:01 2013 -0700
+++ b/src/share/classes/com/sun/tools/script/shell/init.js	Mon Jul 29 21:39:21 2013 +0530
@@ -332,7 +332,7 @@
  * @param str input from which script is loaded and evaluated
  */
 if (typeof(load) == 'undefined') {
-    var load = function(str) {
+    this.load = function(str) {
         var stream = inStream(str);
         var bstream = new BufferedInputStream(stream);
         var reader = new BufferedReader(new InputStreamReader(bstream));
@@ -712,7 +712,7 @@
      * @param exitCode integer code returned to OS shell.
      * optional, defaults to 0
      */
-    var exit = function (code) {
+    this.exit = function (code) {
         if (code) {
             java.lang.System.exit(code + 0);
         } else {
@@ -725,7 +725,7 @@
     /**
      * synonym for exit
      */
-    var quit = function (code) {
+    this.quit = function (code) {
         exit(code);
     }
 }
@@ -881,7 +881,7 @@
      * @param format string to format the rest of the print items
      * @param args variadic argument list
      */
-    var printf = function (format, args/*, more args*/) {  
+    this.printf = function (format, args/*, more args*/) {  
         var array = java.lang.reflect.Array.newInstance(java.lang.Object, 
                     arguments.length - 1);
         for (var i = 0; i < array.length; i++) {
@@ -921,25 +921,7 @@
 }
 
 if (typeof(println) == 'undefined') {
-    var print = function(str, newline) {
-        if (typeof(str) == 'undefined') {
-            str = 'undefined';
-        } else if (str == null) {
-            str = 'null';
-        }
+    // just synonym to print
+    this.println = print;
+}
 
-        if (!(out instanceof java.io.PrintWriter)) {
-            out = new java.io.PrintWriter(out);
-        }
-
-        out.print(String(str));
-        if (newline) {
-            out.print('\n');
-        }
-        out.flush();
-    }
-
-    var println = function(str) {
-        print(str, true);
-    };
-}