--- old/src/java.base/share/conf/security/java.policy 2015-12-18 17:36:44.047837600 +0530 +++ new/src/java.base/share/conf/security/java.policy 2015-12-18 17:36:43.621813200 +0530 @@ -19,6 +19,10 @@ permission java.security.AllPermission; }; +grant codeBase "jrt:/jdk.dynalink" { + permission java.security.AllPermission; +}; + grant codeBase "jrt:/jdk.scripting.nashorn" { permission java.security.AllPermission; }; --- /dev/null 2015-12-18 17:36:46.000000000 +0530 +++ new/test/tools/jjs/Hello.java 2015-12-18 17:36:45.967947400 +0530 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2005, 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. + * + * 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. + */ + +/** + * This is a test program used in the test jjs-cpTest.sh. + */ +public class Hello { + public Hello() {} + public String getString() { + return "hello"; + } +} --- /dev/null 2015-12-18 17:36:48.000000000 +0530 +++ new/test/tools/jjs/args.js 2015-12-18 17:36:47.802052300 +0530 @@ -0,0 +1,21 @@ +/* + * This is the test JavaScript program used in jjs-argsTest.sh + */ + +if (typeof(arguments) == 'undefined') { + throw new Error("arguments expected"); +} + +if (arguments.length != 2) { + throw new Error("2 arguments are expected here"); +} + +if (arguments[0] != 'hello') { + throw new Error("First arg should be 'hello'"); +} + +if (arguments[1] != 'world') { + throw new Error("Second arg should be 'world'"); +} + +print("Passed"); --- /dev/null 2015-12-18 17:36:50.000000000 +0530 +++ new/test/tools/jjs/classpath.js 2015-12-18 17:36:49.591154600 +0530 @@ -0,0 +1,8 @@ +/* + * This is the test JavaScript program used in jjs-cpTest.sh + */ + +var v = new Packages.Hello(); +if (v.string != 'hello') { + throw new Error("Unexpected property value"); +} --- /dev/null 2015-12-18 17:36:52.000000000 +0530 +++ new/test/tools/jjs/common.sh 2015-12-18 17:36:51.406258500 +0530 @@ -0,0 +1,66 @@ +# +# Copyright (c) 2015, 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. +# +# 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. +# + +# + +setup() { + # Verify directory context variables are set + if [ "${TESTJAVA}" = "" ] ; then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 + fi + + if [ "${TESTCLASSES}" = "" ] ; then + TESTCLASSES="." + fi + + if [ "${TESTSRC}" = "" ] ; then + TESTSRC="." + fi + + OS=`uname -s` + case ${OS} in + Windows_*) + PS=";" + FS="\\" + # MKS diff deals with trailing CRs automatically + golden_diff="diff" + ;; + CYGWIN*) + PS=":" + FS="/" + # Cygwin diff needs to be told to ignore trailing CRs + golden_diff="diff --strip-trailing-cr" + ;; + *) + PS=":" + FS="/" + # Assume any other platform doesn't have the trailing CR stuff + golden_diff="diff" + ;; + esac + + JJS="${TESTJAVA}/bin/jjs" + JAVAC="${TESTJAVA}/bin/javac" + JAVA="${TESTJAVA}/bin/java" +} --- /dev/null 2015-12-18 17:36:53.000000000 +0530 +++ new/test/tools/jjs/es6.js 2015-12-18 17:36:53.200361100 +0530 @@ -0,0 +1,13 @@ +/* + * This is the test JavaScript program used in jjs-es6Test.sh + */ + +const X = 4; +try { + X = 55; + throw new Error("should have thrown TypeError"); +} catch (e) { + if (! (e instanceof TypeError)) { + throw new Error("TypeError expected, got " + e); + } +} --- /dev/null 2015-12-18 17:36:55.000000000 +0530 +++ new/test/tools/jjs/file.js 2015-12-18 17:36:54.994463700 +0530 @@ -0,0 +1,47 @@ +/* + * This is the test JavaScript program used in jjs-fileTest.sh + */ + +// good old 'hello world'! +print('hello'); + +// basic number manipulation +var v = 2 + 5; +v *= 5; +v.doubleValue(); +v = v + " is the value"; +if (v != 0) { + print('yes v != 0'); +} + +// basic java access +java.lang.System.out.println('hello world from script'); + +// basic stream manipulation +var al = new java.util.ArrayList(); +al.add("hello"); +al.add("world"); +// script functions for lambas +al.stream().map(function(s) s.toUpperCase()).forEach(print); + +// interface implementation +new java.lang.Runnable() { + run: function() { + print('I am runnable'); + } +}.run(); + +// java class extension +var MyList = Java.extend(java.util.ArrayList); +var m = new MyList() { + size: function() { + print("size called"); + // call super.size() + return Java.super(m).size(); + } +}; + +print("is m an ArrayList? " + (m instanceof java.util.ArrayList)); +m.add("hello"); +m.add("world"); +print(m.size()); --- /dev/null 2015-12-18 17:36:57.000000000 +0530 +++ new/test/tools/jjs/file.out 2015-12-18 17:36:56.803567200 +0530 @@ -0,0 +1,9 @@ +hello +yes v != 0 +hello world from script +HELLO +WORLD +I am runnable +is m an ArrayList? true +size called +2 --- /dev/null 2015-12-18 17:36:59.000000000 +0530 +++ new/test/tools/jjs/jjs-DTest.sh 2015-12-18 17:36:58.641672300 +0530 @@ -0,0 +1,44 @@ +#!/bin/sh + +# +# Copyright (c) 2015, 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. +# +# 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. +# + + +# @test +# @bug 8145750 +# @summary jjs fails to run simple scripts with security manager turned on +# @run shell jjs-DTest.sh +# @summary Test that output of 'jjs -D' + +. ${TESTSRC-.}/common.sh + +setup + +# test whether value specified by -D option is passed +# to script as java.lang.System property. + +${JJS} -J-Djava.security.manager -J-Djava.security.policy=${TESTSRC}/sysprops.policy -Djjs.foo=bar ${TESTSRC}/sysprops.js + +if [ $? -ne 0 ]; then + exit 1 +fi --- /dev/null 2015-12-18 17:37:01.000000000 +0530 +++ new/test/tools/jjs/jjs-argsTest.sh 2015-12-18 17:37:00.477777300 +0530 @@ -0,0 +1,43 @@ +#!/bin/sh + +# +# Copyright (c) 2015, 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. +# +# 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. +# + + +# @test +# @bug 8145750 +# @summary jjs fails to run simple scripts with security manager turned on +# @run shell jjs-argsTest.sh +# @summary Test passing of script arguments from command line + +. ${TESTSRC-.}/common.sh + +setup + +# we check whether args after "--" are passed as script arguments + +${JJS} -J-Djava.security.manager ${TESTSRC}/args.js -- hello world + +if [ $? -ne 0 ]; then + exit 1 +fi --- /dev/null 2015-12-18 17:37:02.000000000 +0530 +++ new/test/tools/jjs/jjs-cpTest.sh 2015-12-18 17:37:02.323882900 +0530 @@ -0,0 +1,60 @@ +#!/bin/sh + +# +# Copyright (c) 2015, 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. +# +# 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. +# + + +# @test +# @bug 8145750 +# @summary jjs fails to run simple scripts with security manager turned on +# @run shell jjs-cpTest.sh +# @summary Test -cp option to set classpath + +. ${TESTSRC-.}/common.sh + +setup + +rm -f Hello.class +${JAVAC} ${TESTSRC}/Hello.java -d . + +# we check whether classpath setting for app classes +# work with jjs. Script should be able to +# access Java class "Hello". + +${JJS} -J-Djava.security.manager -cp . ${TESTSRC}/classpath.js + +if [ $? -ne 0 ]; then + exit 1 +fi + +# -classpath and -cp are synonyms + +${JJS} -J-Djava.security.manager -classpath . ${TESTSRC}/classpath.js + +if [ $? -ne 0 ]; then + exit 1 +fi + +rm -f Hello.class +echo "Passed" +exit 0 --- /dev/null 2015-12-18 17:37:04.000000000 +0530 +++ new/test/tools/jjs/jjs-es6Test.sh 2015-12-18 17:37:04.161988100 +0530 @@ -0,0 +1,41 @@ +#!/bin/sh + +# +# Copyright (c) 2015, 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. +# +# 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. +# + + +# @test +# @bug 8145750 +# @summary jjs fails to run simple scripts with security manager turned on +# @run shell jjs-es6Test.sh +# @summary Test that output of 'jjs --language=es6' + +. ${TESTSRC-.}/common.sh + +setup + +${JJS} -J-Djava.security.manager --language=es6 ${TESTSRC}/es6.js + +if [ $? -ne 0 ]; then + exit 1 +fi --- /dev/null 2015-12-18 17:37:06.000000000 +0530 +++ new/test/tools/jjs/jjs-fileTest.sh 2015-12-18 17:37:05.976091800 +0530 @@ -0,0 +1,49 @@ +#!/bin/sh + +# +# Copyright (c) 2015, 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. +# +# 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. +# + + +# @test +# @bug 8145750 +# @summary jjs fails to run simple scripts with security manager turned on +# @run shell jjs-fileTest.sh +# @summary Test that output of 'jjs file.js' matches the file.out file + +. ${TESTSRC-.}/common.sh + +setup +rm -f jjs-fileTest.out 2>/dev/null +${JJS} -J-Djava.security.manager ${TESTSRC}/file.js > jjs-fileTest.out 2>&1 + +$golden_diff jjs-fileTest.out ${TESTSRC}/file.out +if [ $? != 0 ] +then + echo "Output of jjs file.js differ from expected output. Failed." + rm -f jjs-fileTest.out 2>/dev/null + exit 1 +fi + +rm -f jjs-fTest.out +echo "Passed" +exit 0 --- /dev/null 2015-12-18 17:37:08.000000000 +0530 +++ new/test/tools/jjs/jjs-helpTest.sh 2015-12-18 17:37:07.836198200 +0530 @@ -0,0 +1,50 @@ +#!/bin/sh + +# +# Copyright (c) 2005, 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. +# +# 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. +# + + +# @test +# @bug 8145750 +# @summary jjs fails to run simple scripts with security manager turned on +# @run shell jjs-helpTest.sh +# @summary Test that output of 'jjs -help' is not empty + +. ${TESTSRC-.}/common.sh + +setup + +rm -f jjs-helpTest.out 2>/dev/null +${JJS} -J-Djava.security.manager -help > jjs-helpTest.out 2>&1 + +if [ ! -s jjs-helpTest.out ] +then + echo "Output of jjs -help is empty. Failed." + rm -f jjs-helpTest.out 2>/dev/null + exit 1 +fi + +rm -f jjs-helpTest.out 2>/dev/null + +echo "Passed" +exit 0 --- /dev/null 2015-12-18 17:37:10.000000000 +0530 +++ new/test/tools/jjs/jjs-scriptingTest.sh 2015-12-18 17:37:09.646301700 +0530 @@ -0,0 +1,41 @@ +#!/bin/sh + +# +# Copyright (c) 2015, 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. +# +# 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. +# + + +# @test +# @bug 8145750 +# @summary jjs fails to run simple scripts with security manager turned on +# @run shell jjs-scriptingTest.sh +# @summary Test that output of 'jjs -scripting' + +. ${TESTSRC-.}/common.sh + +setup + +${JJS} -J-Djava.security.manager -scripting ${TESTSRC}/scripting.js + +if [ $? -ne 0 ]; then + exit 1 +fi --- /dev/null 2015-12-18 17:37:12.000000000 +0530 +++ new/test/tools/jjs/jjs-strictTest.sh 2015-12-18 17:37:11.486407000 +0530 @@ -0,0 +1,41 @@ +#!/bin/sh + +# +# Copyright (c) 2015, 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. +# +# 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. +# + + +# @test +# @bug 8145750 +# @summary jjs fails to run simple scripts with security manager turned on +# @run shell jjs-strictTest.sh +# @summary Test that output of 'jjs -strict' + +. ${TESTSRC-.}/common.sh + +setup + +${JJS} -J-Djava.security.manager -strict ${TESTSRC}/strict.js + +if [ $? -ne 0 ]; then + exit 1 +fi --- /dev/null 2015-12-18 17:37:13.000000000 +0530 +++ new/test/tools/jjs/scripting.js 2015-12-18 17:37:13.293510300 +0530 @@ -0,0 +1,18 @@ +/* + * This is the test JavaScript program used in jjs-scriptingTest.sh + */ + +var str = <