changeset 2537:2148192430f1

Merge
author andrew
date Fri, 24 Jul 2020 13:17:02 +0100
parents 04a527d98719 (diff) 817629b1fc01 (current diff)
children ab242949177c
files .hgtags
diffstat 3 files changed, 64 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Jul 14 17:23:10 2020 +0100
+++ b/.hgtags	Fri Jul 24 13:17:02 2020 +0100
@@ -1077,6 +1077,7 @@
 0b39fe441888452aa6a7aabef856c23e8cabf9ff jdk8u262-b03
 eef87c0da03ebb76368edb3195c1c5924edda265 jdk8u262-b04
 e2a7c53cfa4d3c689bb819cf7ed6bb766a62baa9 jdk8u262-b05
+e2a7c53cfa4d3c689bb819cf7ed6bb766a62baa9 jdk8u272-b00
 f6630163b3a2b7a136db8b78049f78aa491aaf69 jdk8u262-b06
 e085d9bd4f6596c5633359d16d9bfc39ecfb1b72 jdk8u262-b07
 18103a6d9d495506b71068e6886d436f98bb165c jdk8u262-b08
--- a/src/jdk/nashorn/tools/Shell.java	Tue Jul 14 17:23:10 2020 +0100
+++ b/src/jdk/nashorn/tools/Shell.java	Fri Jul 24 13:17:02 2020 +0100
@@ -288,7 +288,7 @@
                 } catch (IOException ioe) {
                     // ignore
                 }
-                if (l.startsWith("#!")) {
+                if (l != null && l.startsWith("#!")) {
                     shebangFilePos = i;
                 }
                 // We're only checking the first non-option argument. If it's not a shebang file, we're in normal
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/nosecurity/JDK-8193137.js	Fri Jul 24 13:17:02 2020 +0100
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8193137 : Nashorn crashes when given an empty script file.
+ *
+ * @test
+ * @option -scripting
+ * @run
+ */
+
+if (typeof fail != 'function') {
+    fail = print;
+}
+
+var System = java.lang.System;
+var File = java.io.File;
+var javahome = System.getProperty("java.home");
+var nashornJar = new File(System.getProperty("nashorn.jar"));
+if (! nashornJar.isAbsolute()) {
+    nashornJar = new File(".", nashornJar);
+}
+
+// we want to use nashorn.jar passed and not the one that comes with JRE
+var jjsCmd = javahome + "/../bin/jjs";
+jjsCmd = jjsCmd.toString().replace(/\//g, File.separator);
+if (! new File(jjsCmd).isFile()) {
+    jjsCmd = javahome + "/bin/jjs";
+    jjsCmd = jjsCmd.toString().replace(/\//g, File.separator);
+}
+
+$ENV.PWD=System.getProperty("user.dir")
+
+var emptyFile = new File($ENV.PWD+File.separator+"empty.js");
+emptyFile.createNewFile();
+emptyFile.deleteOnExit();
+
+$EXEC(jjsCmd + " empty.js");
+if($ERR != "")
+    fail("jjs fails with empty script file");