Merge jdk8u20-b20

Thu, 19 Jun 2014 17:59:34 -0700

author
lana
date
Thu, 19 Jun 2014 17:59:34 -0700
changeset 872
ed3439dca4a7
parent 863
6e9c4e34bc61
parent 871
c9ed47ef089a
child 873
f2925491b61b

Merge

     1.1 --- a/make/build.xml	Wed Jun 18 12:35:42 2014 -0700
     1.2 +++ b/make/build.xml	Thu Jun 19 17:59:34 2014 -0700
     1.3 @@ -193,14 +193,16 @@
     1.4      </jar>
     1.5    </target>
     1.6  
     1.7 -  <target name="javadoc" depends="prepare">
     1.8 -    <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="src/overview.html" windowtitle="${nashorn.product.name} ${nashorn.version}" additionalparam="-quiet" failonerror="true">
     1.9 +  <target name="javadoc" depends="jar">
    1.10 +    <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="src/overview.html" 
    1.11 +        extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}"
    1.12 +        additionalparam="-quiet" failonerror="true">
    1.13        <classpath>
    1.14          <pathelement location="${build.classes.dir}"/>
    1.15        </classpath>
    1.16        <fileset dir="${src.dir}" includes="**/*.java"/>
    1.17        <fileset dir="${jdk.asm.src.dir}" includes="**/*.java"/>
    1.18 -      <link href="http://docs.oracle.com/javase/7/docs/api/"/>
    1.19 +      <link href="http://docs.oracle.com/javase/8/docs/api/"/>
    1.20        <!-- The following tags are used only in ASM sources - just ignore these -->
    1.21        <tag name="label" description="label tag in ASM sources" enabled="false"/>
    1.22        <tag name="linked" description="linked tag in ASM sources" enabled="false"/>
    1.23 @@ -208,6 +210,19 @@
    1.24      </javadoc>
    1.25    </target>
    1.26  
    1.27 +  <!-- generate javadoc only for nashorn extension api classes -->
    1.28 +  <target name="javadocapi" depends="jar">
    1.29 +    <javadoc destdir="${dist.javadoc.dir}" use="yes" extdirs="${nashorn.ext.path}" 
    1.30 +        windowtitle="${nashorn.product.name}" additionalparam="-quiet" failonerror="true">
    1.31 +      <classpath>
    1.32 +        <pathelement location="${build.classes.dir}"/>
    1.33 +      </classpath>
    1.34 +      <fileset dir="${src.dir}" includes="jdk/nashorn/api/**/*.java"/>
    1.35 +      <link href="http://docs.oracle.com/javase/8/docs/api/"/>
    1.36 +    </javadoc>
    1.37 +  </target>
    1.38 +
    1.39 +
    1.40    <!-- generate shell.html for shell tool documentation -->
    1.41    <target name="shelldoc" depends="jar">
    1.42      <java classname="${nashorn.shell.tool}" dir="${basedir}" output="${dist.dir}/shell.html" failonerror="true" fork="true">
    1.43 @@ -336,35 +351,32 @@
    1.44      <echo message="WARNING: TestNG not available, will not run tests. Please copy testng.jar under test/lib directory."/>
    1.45    </target>
    1.46  
    1.47 -  <target name="test" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
    1.48 -    <fileset id="test.classes" dir="${build.test.classes.dir}">
    1.49 -      <include name="**/api/javaaccess/*Test.class"/>
    1.50 -      <include name="**/api/scripting/*Test.class"/>
    1.51 -      <include name="**/codegen/*Test.class"/>
    1.52 -      <include name="**/parser/*Test.class"/>
    1.53 -      <include name="**/runtime/*Test.class"/>
    1.54 -      <include name="**/runtime/regexp/*Test.class"/>
    1.55 -      <include name="**/runtime/regexp/joni/*Test.class"/>
    1.56 -      <include name="**/framework/*Test.class"/>
    1.57 -    </fileset>
    1.58 +  <!-- only to be invoked as dependency of "test" target -->
    1.59 +  <target name="-test-classes-all" depends="jar" unless="test.class">
    1.60 +      <fileset id="test.classes" dir="${build.test.classes.dir}">
    1.61 +          <include name="**/api/javaaccess/*Test.class"/>
    1.62 +          <include name="**/api/scripting/*Test.class"/>
    1.63 +          <include name="**/codegen/*Test.class"/>
    1.64 +          <include name="**/parser/*Test.class"/>
    1.65 +          <include name="**/runtime/*Test.class"/>
    1.66 +          <include name="**/runtime/regexp/*Test.class"/>
    1.67 +          <include name="**/runtime/regexp/joni/*Test.class"/>
    1.68 +          <include name="**/framework/*Test.class"/>
    1.69 +     </fileset>
    1.70 +  </target>
    1.71  
    1.72 +  <!-- only to be invoked as dependency of "test" target -->
    1.73 +  <target name="-test-classes-single" depends="jar" if="test.class">
    1.74 +     <fileset id="test.classes" dir="${build.test.classes.dir}">
    1.75 +         <include name="${test.class}*"/>
    1.76 +     </fileset>
    1.77 +  </target>
    1.78 +
    1.79 +  <!-- only to be invoked as dependency of "test" target -->
    1.80 +  <target name="-test-nosecurity" unless="test.class">
    1.81      <fileset id="test.nosecurity.classes" dir="${build.test.classes.dir}">
    1.82        <include name="**/framework/ScriptTest.class"/>
    1.83      </fileset>
    1.84 -
    1.85 -    <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
    1.86 -       verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
    1.87 -      <jvmarg line="${ext.class.path}"/>
    1.88 -      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
    1.89 -      <propertyset>
    1.90 -        <propertyref prefix="test-sys-prop."/>
    1.91 -        <mapper from="test-sys-prop.*" to="*" type="glob"/>
    1.92 -      </propertyset>
    1.93 -      <sysproperty key="test.js.excludes.file" value="${exclude.list}"/>
    1.94 -      <classpath>
    1.95 -          <pathelement path="${run.test.classpath}"/>
    1.96 -      </classpath>
    1.97 -    </testng>
    1.98      <testng outputdir="${build.nosecurity.test.results.dir}" classfilesetref="test.nosecurity.classes"
    1.99         verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
   1.100        <jvmarg line="${ext.class.path}"/>
   1.101 @@ -382,6 +394,28 @@
   1.102      </testng>
   1.103    </target>
   1.104  
   1.105 +  <!-- only to be invoked as dependency of "test" target -->
   1.106 +  <target name="-test-security">
   1.107 +    <delete dir="${build.dir}/nashorn_code_cache"/>
   1.108 +    <property name="debug.test.jvmargs" value=""/>
   1.109 +    <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
   1.110 +       verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
   1.111 +      <jvmarg line="${ext.class.path}"/>
   1.112 +      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
   1.113 +      <jvmarg line="${debug.test.jvmargs}"/>
   1.114 +      <propertyset>
   1.115 +        <propertyref prefix="test-sys-prop."/>
   1.116 +        <mapper from="test-sys-prop.*" to="*" type="glob"/>
   1.117 +      </propertyset>
   1.118 +      <sysproperty key="test.js.excludes.file" value="${exclude.list}"/>
   1.119 +      <classpath>
   1.120 +          <pathelement path="${run.test.classpath}"/>
   1.121 +      </classpath>
   1.122 +    </testng>
   1.123 +  </target>
   1.124 +
   1.125 +  <target name="test" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-policy-file, -test-security, -test-nosecurity" if="testng.available"/>
   1.126 +
   1.127    <target name="test-basicparallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file">
   1.128        <!-- use just build.test.classes.dir to avoid referring to TestNG -->
   1.129        <java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" failonerror="true" fork="true">
     2.1 --- a/make/nbproject/ide-file-targets.xml	Wed Jun 18 12:35:42 2014 -0700
     2.2 +++ b/make/nbproject/ide-file-targets.xml	Thu Jun 19 17:59:34 2014 -0700
     2.3 @@ -22,38 +22,14 @@
     2.4   questions.
     2.5  -->
     2.6  <project basedir=".." name="nashorn-IDE">
     2.7 -    <property file="nbproject/nbjdk.properties"/>
     2.8 -    <property location="${netbeans.user}/build.properties" name="user.properties.file"/>
     2.9 -    <property file="${user.properties.file}"/>
    2.10 -    <import file="jdk.xml"/>
    2.11 -    <import file="${basedir}/build-init.xml"/>
    2.12 -    <!-- TODO: edit the following target according to your needs -->
    2.13 -    <!-- (more info: http://www.netbeans.org/kb/articles/freeform-config.html#runsingle) -->
    2.14 -    <target depends="-jdk-init, init" name="debug-selected-file-in-src">
    2.15 -        <fail unless="debug.class">Must set property 'debug.class'</fail>
    2.16 -        <ant antfile="build.xml" inheritall="false" target="jar"/>
    2.17 +    <target name="debug-selected-file-in-src">
    2.18 +        <fail unless="test.class">Must set property 'debug.class'</fail>
    2.19          <nbjpdastart addressproperty="jpda.address" name="nashorn" transport="dt_socket">
    2.20              <classpath path="${run.test.classpath}"/>
    2.21          </nbjpdastart>
    2.22 -        <java classname="${debug.class}" fork="false">
    2.23 -            <classpath path="${run.test.classpath}"/>
    2.24 -            <jvmarg line="${boot.class.path}"/>
    2.25 -            <jvmarg value="-Xdebug"/>
    2.26 -            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
    2.27 -            <jvmarg line="${run.test.jvmargs}"/>
    2.28 -            <arg value="${debug.class}"/>
    2.29 -        </java>
    2.30 -    </target>
    2.31 -    <!-- TODO: edit the following target according to your needs -->
    2.32 -    <!-- (more info: http://www.netbeans.org/kb/articles/freeform-config.html#runsingle) -->
    2.33 -    <target depends="-jdk-init, init" name="run-selected-file-in-src">
    2.34 -        <fail unless="run.class">Must set property 'run.class'</fail>
    2.35 -        <ant antfile="build.xml" inheritall="false" target="jar"/>
    2.36 -        <java classname="${run.class}" failonerror="true" fork="false">
    2.37 -            <classpath path="${run.test.classpath}"/>
    2.38 -            <jvmarg line="${boot.class.path}"/>
    2.39 -            <jvmarg line="${run.test.jvmargs}"/>
    2.40 -            <arg value="${run.class}"/>
    2.41 -        </java>
    2.42 +        <ant antfile="build.xml" inheritall="false" target="test">
    2.43 +            <property name="test.class" value="${test.class}"/>
    2.44 +            <property name="debug.test.jvmargs" value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
    2.45 +        </ant>
    2.46      </target>
    2.47  </project>
     3.1 --- a/make/nbproject/project.xml	Wed Jun 18 12:35:42 2014 -0700
     3.2 +++ b/make/nbproject/project.xml	Thu Jun 19 17:59:34 2014 -0700
     3.3 @@ -98,27 +98,27 @@
     3.4                      <script>nbproject/nbjdk.xml</script>
     3.5                      <target>debug-nb</target>
     3.6                  </action>
     3.7 -                <action name="debug.single">
     3.8 -                    <script>nbproject/ide-file-targets.xml</script>
     3.9 -                    <target>debug-selected-file-in-src</target>
    3.10 +                <action name="run.single">
    3.11 +                    <script>build.xml</script>
    3.12 +                    <target>test</target>
    3.13                      <context>
    3.14 -                        <property>debug.class</property>
    3.15 -                        <folder>test/src</folder>
    3.16 +                        <property>test.class</property>
    3.17 +                        <folder>../test/src</folder>
    3.18                          <pattern>\.java$</pattern>
    3.19 -                        <format>java-name</format>
    3.20 +                        <format>relative-path-noext</format>
    3.21                          <arity>
    3.22                              <one-file-only/>
    3.23                          </arity>
    3.24                      </context>
    3.25                  </action>
    3.26 -                <action name="run.single">
    3.27 +                <action name="debug.single">
    3.28                      <script>nbproject/ide-file-targets.xml</script>
    3.29 -                    <target>run-selected-file-in-src</target>
    3.30 +                    <target>debug-selected-file-in-src</target>
    3.31                      <context>
    3.32 -                        <property>run.class</property>
    3.33 -                        <folder>test/src</folder>
    3.34 +                        <property>test.class</property>
    3.35 +                        <folder>../test/src</folder>
    3.36                          <pattern>\.java$</pattern>
    3.37 -                        <format>java-name</format>
    3.38 +                        <format>relative-path-noext</format>
    3.39                          <arity>
    3.40                              <one-file-only/>
    3.41                          </arity>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/samples/filebrowser.js	Thu Jun 19 17:59:34 2014 -0700
     4.3 @@ -0,0 +1,100 @@
     4.4 +#// Usage: jjs -fx filebrowser.js -- <start_dir>
     4.5 +
     4.6 +/*
     4.7 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     4.8 + * 
     4.9 + * Redistribution and use in source and binary forms, with or without
    4.10 + * modification, are permitted provided that the following conditions
    4.11 + * are met:
    4.12 + * 
    4.13 + *   - Redistributions of source code must retain the above copyright
    4.14 + *     notice, this list of conditions and the following disclaimer.
    4.15 + * 
    4.16 + *   - Redistributions in binary form must reproduce the above copyright
    4.17 + *     notice, this list of conditions and the following disclaimer in the
    4.18 + *     documentation and/or other materials provided with the distribution.
    4.19 + * 
    4.20 + *   - Neither the name of Oracle nor the names of its
    4.21 + *     contributors may be used to endorse or promote products derived
    4.22 + *     from this software without specific prior written permission.
    4.23 + * 
    4.24 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    4.25 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    4.26 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    4.27 + * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    4.28 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    4.29 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    4.30 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    4.31 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    4.32 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    4.33 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    4.34 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    4.35 + */
    4.36 +
    4.37 +// Uses -fx and javafx TreeView to visualize directories
    4.38 +if (!$OPTIONS._fx) {
    4.39 +    print("Usage: jjs -fx filebrowser.js -- <start_dir>");
    4.40 +    exit(1);
    4.41 +}
    4.42 +
    4.43 +// Java classes used
    4.44 +var File = Java.type("java.io.File");
    4.45 +var Files = Java.type("java.nio.file.Files");
    4.46 +
    4.47 +// check directory argument, if passed
    4.48 +var dir = arguments.length > 0? new File(arguments[0]) : new File(".");
    4.49 +if (! dir.isDirectory()) {
    4.50 +    print(dir + " is not a directory!");
    4.51 +    exit(2);
    4.52 +}
    4.53 +
    4.54 +// JavaFX classes used
    4.55 +var FXCollections = Java.type("javafx.collections.FXCollections");
    4.56 +var Scene     = Java.type("javafx.scene.Scene");
    4.57 +var TreeItem  = Java.type("javafx.scene.control.TreeItem");
    4.58 +var TreeView  = Java.type("javafx.scene.control.TreeView");
    4.59 +
    4.60 +// create a subclass of JavaFX TreeItem class
    4.61 +var LazyTreeItem = Java.extend(TreeItem);
    4.62 +
    4.63 +// lazily filling children of a directory LazyTreeItem
    4.64 +function buildChildren(dir) {
    4.65 +    var children = FXCollections.observableArrayList();
    4.66 +    var stream = Files.list(dir.toPath());
    4.67 +    stream.forEach(function(path) {
    4.68 +        var file = path.toFile();
    4.69 +        var item = file.isDirectory()?
    4.70 +            makeLazyTreeItem(file) : new TreeItem(file.name);
    4.71 +        children.add(item);
    4.72 +    });
    4.73 +    stream.close();
    4.74 +    return children;
    4.75 +}
    4.76 +
    4.77 +// create an instance LazyTreeItem with override methods
    4.78 +function makeLazyTreeItem(dir) {
    4.79 +    var item = new LazyTreeItem(dir.name) {
    4.80 +        expanded: false,
    4.81 +        isLeaf: function() false,
    4.82 +        getChildren: function() {
    4.83 +            if (! this.expanded) {
    4.84 +                // call super class (TreeItem) method
    4.85 +                Java.super(item).getChildren().setAll(buildChildren(dir));
    4.86 +                this.expanded = true;
    4.87 +            }
    4.88 +            // call super class (TreeItem) method
    4.89 +            return Java.super(item).getChildren();
    4.90 +        }
    4.91 +    }
    4.92 +    return item;
    4.93 +}
    4.94 +
    4.95 +// JavaFX start method
    4.96 +function start(stage) {
    4.97 +    stage.title = dir.absolutePath;
    4.98 +    var rootItem = makeLazyTreeItem(dir);
    4.99 +    rootItem.expanded = true;
   4.100 +    var tree = new TreeView(rootItem);
   4.101 +    stage.scene = new Scene(tree, 300, 450);
   4.102 +    stage.show();
   4.103 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/samples/word_histogram.js	Thu Jun 19 17:59:34 2014 -0700
     5.3 @@ -0,0 +1,53 @@
     5.4 +#nashorn word histogram of a file
     5.5 +
     5.6 +/*
     5.7 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     5.8 + * 
     5.9 + * Redistribution and use in source and binary forms, with or without
    5.10 + * modification, are permitted provided that the following conditions
    5.11 + * are met:
    5.12 + * 
    5.13 + *   - Redistributions of source code must retain the above copyright
    5.14 + *     notice, this list of conditions and the following disclaimer.
    5.15 + * 
    5.16 + *   - Redistributions in binary form must reproduce the above copyright
    5.17 + *     notice, this list of conditions and the following disclaimer in the
    5.18 + *     documentation and/or other materials provided with the distribution.
    5.19 + * 
    5.20 + *   - Neither the name of Oracle nor the names of its
    5.21 + *     contributors may be used to endorse or promote products derived
    5.22 + *     from this software without specific prior written permission.
    5.23 + * 
    5.24 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    5.25 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    5.26 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    5.27 + * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    5.28 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    5.29 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    5.30 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    5.31 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    5.32 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    5.33 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    5.34 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    5.35 + */
    5.36 +
    5.37 +/*
    5.38 + * This example demonstrates how to print word histogram
    5.39 + * of a given text file using regex, array and JSON
    5.40 + * functions.
    5.41 + */
    5.42 +
    5.43 +if (arguments.length < 1) {
    5.44 +    print("Usage: jjs -scripting word_histogram.js -- <file>");
    5.45 +    exit(1);
    5.46 +}
    5.47 +
    5.48 +var obj = {};
    5.49 +
    5.50 +readFully(arguments[0]).
    5.51 +    split(/[^\w+]/).
    5.52 +    forEach(function(x)
    5.53 +      (x in obj? obj[x]++ : obj[x] = 1));
    5.54 +
    5.55 +print(JSON.stringify(obj));
    5.56 +
     6.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Wed Jun 18 12:35:42 2014 -0700
     6.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Thu Jun 19 17:59:34 2014 -0700
     6.3 @@ -496,7 +496,7 @@
     6.4      public void setProto(final Object proto) {
     6.5          inGlobal(new Callable<Void>() {
     6.6              @Override public Void call() {
     6.7 -                sobj.setProtoCheck(unwrap(proto, global));
     6.8 +                sobj.setPrototypeOf(unwrap(proto, global));
     6.9                  return null;
    6.10              }
    6.11          });
    6.12 @@ -621,6 +621,7 @@
    6.13      /**
    6.14       * Utilitity to convert this script object to the given type.
    6.15       *
    6.16 +     * @param <T> destination type to convert to
    6.17       * @param type destination type to convert to
    6.18       * @return converted object
    6.19       */
     7.1 --- a/src/jdk/nashorn/api/scripting/package-info.java	Wed Jun 18 12:35:42 2014 -0700
     7.2 +++ b/src/jdk/nashorn/api/scripting/package-info.java	Thu Jun 19 17:59:34 2014 -0700
     7.3 @@ -32,7 +32,8 @@
     7.4   * ScriptEngine nashornEngine = new ScriptEngineManager().getEngineByName("Nashorn");
     7.5   * </pre>
     7.6   * <p>Nashorn script engines implement the optional {@link javax.script.Invocable} and {@link javax.script.Compilable}
     7.7 - * interfaces, allowing for efficient pre-compilation and repeated execution of scripts. See
     7.8 + * interfaces, allowing for efficient pre-compilation and repeated execution of scripts. In addition,
     7.9 + * this package provides nashorn specific extension classes, interfaces and methods. See
    7.10   * {@link jdk.nashorn.api.scripting.NashornScriptEngineFactory} for further details.
    7.11   */
    7.12  package jdk.nashorn.api.scripting;
     8.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Wed Jun 18 12:35:42 2014 -0700
     8.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Jun 19 17:59:34 2014 -0700
     8.3 @@ -1500,7 +1500,9 @@
     8.4          method.dup();
     8.5          if (protoNode != null) {
     8.6              load(protoNode);
     8.7 -            method.invoke(ScriptObject.SET_PROTO_CHECK);
     8.8 +            // take care of { __proto__: 34 } or some such!
     8.9 +            method.convert(Type.OBJECT);
    8.10 +            method.invoke(ScriptObject.SET_PROTO_FROM_LITERAL);
    8.11          } else {
    8.12              globalObjectPrototype();
    8.13              method.invoke(ScriptObject.SET_PROTO);
     9.1 --- a/src/jdk/nashorn/internal/ir/annotations/Reference.java	Wed Jun 18 12:35:42 2014 -0700
     9.2 +++ b/src/jdk/nashorn/internal/ir/annotations/Reference.java	Thu Jun 19 17:59:34 2014 -0700
     9.3 @@ -32,9 +32,7 @@
     9.4   * Reference node in AST, i.e. anything not a copy. Important for
     9.5   * AST traversal and cloning. Cloning currently as a rule uses
     9.6   * existingOrSame for references and otherwise existingOrCopy
     9.7 - * <p>
     9.8   */
     9.9 -
    9.10  @Retention(value=RetentionPolicy.RUNTIME)
    9.11  public @interface Reference {
    9.12      // EMPTY
    10.1 --- a/src/jdk/nashorn/internal/objects/Global.java	Wed Jun 18 12:35:42 2014 -0700
    10.2 +++ b/src/jdk/nashorn/internal/objects/Global.java	Thu Jun 19 17:59:34 2014 -0700
    10.3 @@ -1908,8 +1908,8 @@
    10.4  
    10.5          // ES6 draft compliant __proto__ property of Object.prototype
    10.6          // accessors on Object.prototype for "__proto__"
    10.7 -        final ScriptFunction getProto = ScriptFunctionImpl.makeFunction("getProto", ScriptObject.GETPROTO);
    10.8 -        final ScriptFunction setProto = ScriptFunctionImpl.makeFunction("setProto", ScriptObject.SETPROTOCHECK);
    10.9 +        final ScriptFunction getProto = ScriptFunctionImpl.makeFunction("getProto", NativeObject.GET__PROTO__);
   10.10 +        final ScriptFunction setProto = ScriptFunctionImpl.makeFunction("setProto", NativeObject.SET__PROTO__);
   10.11          ObjectPrototype.addOwnProperty("__proto__", Attribute.NOT_ENUMERABLE, getProto, setProto);
   10.12  
   10.13  
    11.1 --- a/src/jdk/nashorn/internal/objects/NativeError.java	Wed Jun 18 12:35:42 2014 -0700
    11.2 +++ b/src/jdk/nashorn/internal/objects/NativeError.java	Thu Jun 19 17:59:34 2014 -0700
    11.3 @@ -327,7 +327,12 @@
    11.4          final Object exception = ECMAException.getException(sobj);
    11.5          if (exception instanceof Throwable) {
    11.6              Object value = getScriptStackString(sobj, (Throwable)exception);
    11.7 -            sobj.put(STACK, value, false);
    11.8 +            if (sobj.hasOwnProperty(STACK)) {
    11.9 +                sobj.put(STACK, value, false);
   11.10 +            } else {
   11.11 +                sobj.addOwnProperty(STACK, Attribute.NOT_ENUMERABLE, value);
   11.12 +            }
   11.13 +
   11.14              return value;
   11.15          }
   11.16  
   11.17 @@ -346,7 +351,12 @@
   11.18      public static Object setStack(final Object self, final Object value) {
   11.19          Global.checkObject(self);
   11.20          final ScriptObject sobj = (ScriptObject)self;
   11.21 -        sobj.set(STACK, value, false);
   11.22 +        if (sobj.hasOwnProperty(STACK)) {
   11.23 +            sobj.put(STACK, value, false);
   11.24 +        } else {
   11.25 +            sobj.addOwnProperty(STACK, Attribute.NOT_ENUMERABLE, value);
   11.26 +        }
   11.27 +
   11.28          return value;
   11.29      }
   11.30  
    12.1 --- a/src/jdk/nashorn/internal/objects/NativeObject.java	Wed Jun 18 12:35:42 2014 -0700
    12.2 +++ b/src/jdk/nashorn/internal/objects/NativeObject.java	Thu Jun 19 17:59:34 2014 -0700
    12.3 @@ -25,6 +25,7 @@
    12.4  
    12.5  package jdk.nashorn.internal.objects;
    12.6  
    12.7 +import static jdk.nashorn.internal.lookup.Lookup.MH;
    12.8  import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
    12.9  import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
   12.10  
   12.11 @@ -74,6 +75,9 @@
   12.12   */
   12.13  @ScriptClass("Object")
   12.14  public final class NativeObject {
   12.15 +    public static final MethodHandle GET__PROTO__ = findOwnMH("get__proto__", ScriptObject.class, Object.class);
   12.16 +    public static final MethodHandle SET__PROTO__ = findOwnMH("set__proto__", Object.class, Object.class, Object.class);
   12.17 +
   12.18      private static final Object TO_STRING = new Object();
   12.19  
   12.20      private static InvokeByName getTO_STRING() {
   12.21 @@ -86,6 +90,35 @@
   12.22                  });
   12.23      }
   12.24  
   12.25 +    @SuppressWarnings("unused")
   12.26 +    private static ScriptObject get__proto__(final Object self) {
   12.27 +        // See ES6 draft spec: B.2.2.1.1 get Object.prototype.__proto__
   12.28 +        // Step 1 Let O be the result of calling ToObject passing the this.
   12.29 +        final Object obj = Global.toObject(self);
   12.30 +        Global.checkObject(obj);
   12.31 +        final ScriptObject sobj = (ScriptObject)obj;
   12.32 +        return sobj.getProto();
   12.33 +    }
   12.34 +
   12.35 +    @SuppressWarnings("unused")
   12.36 +    private static Object set__proto__(final Object self, final Object proto) {
   12.37 +        // See ES6 draft spec: B.2.2.1.2 set Object.prototype.__proto__
   12.38 +        // Step 1
   12.39 +        Global.checkObjectCoercible(self);
   12.40 +        // Step 4
   12.41 +        if (! (self instanceof ScriptObject)) {
   12.42 +            return UNDEFINED;
   12.43 +        }
   12.44 +
   12.45 +        final ScriptObject sobj = (ScriptObject)self;
   12.46 +        // __proto__ assignment ignores non-nulls and non-objects
   12.47 +        // step 3: If Type(proto) is neither Object nor Null, then return undefined.
   12.48 +        if (proto == null || proto instanceof ScriptObject) {
   12.49 +            sobj.setPrototypeOf(proto);
   12.50 +        }
   12.51 +        return UNDEFINED;
   12.52 +    }
   12.53 +
   12.54      private static final MethodType MIRROR_GETTER_TYPE = MethodType.methodType(Object.class, ScriptObjectMirror.class);
   12.55      private static final MethodType MIRROR_SETTER_TYPE = MethodType.methodType(Object.class, ScriptObjectMirror.class, Object.class);
   12.56  
   12.57 @@ -160,7 +193,7 @@
   12.58      @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
   12.59      public static Object setPrototypeOf(final Object self, final Object obj, final Object proto) {
   12.60          if (obj instanceof ScriptObject) {
   12.61 -            ((ScriptObject)obj).setProtoCheck(proto);
   12.62 +            ((ScriptObject)obj).setPrototypeOf(proto);
   12.63              return obj;
   12.64          } else if (obj instanceof ScriptObjectMirror) {
   12.65              ((ScriptObjectMirror)obj).setProto(proto);
   12.66 @@ -777,4 +810,8 @@
   12.67          return new LinkRequestImpl(CallSiteDescriptorFactory.create(MethodHandles.publicLookup(), operation,
   12.68                  methodType), false, source);
   12.69      }
   12.70 +
   12.71 +    private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
   12.72 +       return MH.findStatic(MethodHandles.lookup(), NativeObject.class, name, MH.type(rtype, types));
   12.73 +    }
   12.74  }
    13.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExp.java	Wed Jun 18 12:35:42 2014 -0700
    13.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java	Thu Jun 19 17:59:34 2014 -0700
    13.3 @@ -731,6 +731,12 @@
    13.4              if (nextChar == '$') {
    13.5                  // Skip past $
    13.6                  cursor++;
    13.7 +                if (cursor == replacement.length()) {
    13.8 +                    // nothing after "$"
    13.9 +                    sb.append('$');
   13.10 +                    break;
   13.11 +                }
   13.12 +
   13.13                  nextChar = replacement.charAt(cursor);
   13.14                  final int firstDigit = nextChar - '0';
   13.15  
    14.1 --- a/src/jdk/nashorn/internal/runtime/DebuggerSupport.java	Wed Jun 18 12:35:42 2014 -0700
    14.2 +++ b/src/jdk/nashorn/internal/runtime/DebuggerSupport.java	Thu Jun 19 17:59:34 2014 -0700
    14.3 @@ -25,12 +25,20 @@
    14.4  
    14.5  package jdk.nashorn.internal.runtime;
    14.6  
    14.7 +import static jdk.nashorn.internal.codegen.CompilerConstants.SOURCE;
    14.8 +
    14.9 +import java.lang.invoke.MethodHandle;
   14.10 +import java.lang.reflect.Field;
   14.11 +import java.net.URL;
   14.12  import java.util.HashSet;
   14.13  import java.util.Set;
   14.14 +import jdk.nashorn.internal.scripts.JS;
   14.15  
   14.16  /**
   14.17   * This class provides support for external debuggers.  Its primary purpose is
   14.18   * is to simplify the debugger tasks and provide better performance.
   14.19 + * Even though the methods are not public, there are still part of the
   14.20 + * external debugger interface.
   14.21   */
   14.22  final class DebuggerSupport {
   14.23      /**
   14.24 @@ -46,6 +54,11 @@
   14.25           */
   14.26          @SuppressWarnings("unused")
   14.27          DebuggerValueDesc forceLoad = new DebuggerValueDesc(null, false, null, null);
   14.28 +
   14.29 +        // Hook to force the loading of the SourceInfo class
   14.30 +        @SuppressWarnings("unused")
   14.31 +        final
   14.32 +        SourceInfo srcInfo = new SourceInfo(null, 0, null, null);
   14.33      }
   14.34  
   14.35      /** This class is used to send a bulk description of a value. */
   14.36 @@ -70,6 +83,54 @@
   14.37          }
   14.38      }
   14.39  
   14.40 +    static class SourceInfo {
   14.41 +        final String name;
   14.42 +        final URL    url;
   14.43 +        final int    hash;
   14.44 +        final char[] content;
   14.45 +
   14.46 +        SourceInfo(final String name, final int hash, final URL url, final char[] content) {
   14.47 +            this.name    = name;
   14.48 +            this.hash    = hash;
   14.49 +            this.url     = url;
   14.50 +            this.content = content;
   14.51 +        }
   14.52 +    }
   14.53 +
   14.54 +    /**
   14.55 +     * Hook that is called just before invoking method handle
   14.56 +     * from ScriptFunctionData via invoke, constructor method calls.
   14.57 +     *
   14.58 +     * @param mh script class method about to be invoked.
   14.59 +     */
   14.60 +    static void notifyInvoke(final MethodHandle mh) {
   14.61 +        // Do nothing here. This is placeholder method on which a
   14.62 +        // debugger can place a breakpoint so that it can access the
   14.63 +        // (script class) method handle that is about to be invoked.
   14.64 +        // See ScriptFunctionData.invoke and ScriptFunctionData.construct.
   14.65 +    }
   14.66 +
   14.67 +    /**
   14.68 +     * Return the script source info for the given script class.
   14.69 +     *
   14.70 +     * @param clazz compiled script class
   14.71 +     * @return SourceInfo
   14.72 +     */
   14.73 +    static SourceInfo getSourceInfo(final Class<?> clazz) {
   14.74 +        if (JS.class.isAssignableFrom(clazz)) {
   14.75 +            try {
   14.76 +                final Field sourceField = clazz.getDeclaredField(SOURCE.symbolName());
   14.77 +                sourceField.setAccessible(true);
   14.78 +                final Source src = (Source) sourceField.get(null);
   14.79 +                return src.getSourceInfo();
   14.80 +            } catch (final IllegalAccessException | NoSuchFieldException ignored) {
   14.81 +                return null;
   14.82 +            }
   14.83 +        }
   14.84 +
   14.85 +        return null;
   14.86 +    }
   14.87 +
   14.88      /**
   14.89       * Return the current context global.
   14.90       * @return context global.
   14.91 @@ -84,7 +145,7 @@
   14.92       * @param self            Receiver to use.
   14.93       * @param string          String to evaluate.
   14.94       * @param returnException true if exceptions are to be returned.
   14.95 -     * @return Result of eval as string, or, an exception or null depending on returnException.
   14.96 +     * @return Result of eval, or, an exception or null depending on returnException.
   14.97       */
   14.98      static Object eval(final ScriptObject scope, final Object self, final String string, final boolean returnException) {
   14.99          final ScriptObject global = Context.getGlobal();
  14.100 @@ -235,7 +296,7 @@
  14.101       * @param value Arbitrary value to be displayed by the debugger.
  14.102       * @return A string representation of the value or an array of DebuggerValueDesc.
  14.103       */
  14.104 -    private static String valueAsString(final Object value) {
  14.105 +    static String valueAsString(final Object value) {
  14.106          final JSType type = JSType.of(value);
  14.107  
  14.108          switch (type) {
    15.1 --- a/src/jdk/nashorn/internal/runtime/GlobalFunctions.java	Wed Jun 18 12:35:42 2014 -0700
    15.2 +++ b/src/jdk/nashorn/internal/runtime/GlobalFunctions.java	Thu Jun 19 17:59:34 2014 -0700
    15.3 @@ -459,5 +459,4 @@
    15.4      private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    15.5          return MH.findStatic(MethodHandles.lookup(), GlobalFunctions.class, name, MH.type(rtype, types));
    15.6      }
    15.7 -
    15.8  }
    16.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Wed Jun 18 12:35:42 2014 -0700
    16.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Thu Jun 19 17:59:34 2014 -0700
    16.3 @@ -519,6 +519,8 @@
    16.4          final Object   selfObj = convertThisObject(self);
    16.5          final Object[] args    = arguments == null ? ScriptRuntime.EMPTY_ARRAY : arguments;
    16.6  
    16.7 +        DebuggerSupport.notifyInvoke(mh);
    16.8 +
    16.9          if (isVarArg(mh)) {
   16.10              if (needsCallee(mh)) {
   16.11                  return mh.invokeExact(fn, selfObj, args);
   16.12 @@ -572,6 +574,8 @@
   16.13          final MethodHandle mh   = getGenericConstructor();
   16.14          final Object[]     args = arguments == null ? ScriptRuntime.EMPTY_ARRAY : arguments;
   16.15  
   16.16 +        DebuggerSupport.notifyInvoke(mh);
   16.17 +
   16.18          if (isVarArg(mh)) {
   16.19              if (needsCallee(mh)) {
   16.20                  return mh.invokeExact(fn, args);
    17.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Wed Jun 18 12:35:42 2014 -0700
    17.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Thu Jun 19 17:59:34 2014 -0700
    17.3 @@ -132,9 +132,7 @@
    17.4  
    17.5      /** Method handle to retrive prototype of this object */
    17.6      public static final MethodHandle GETPROTO           = findOwnMH("getProto", ScriptObject.class);
    17.7 -    /** Method handle to set prototype of this object */
    17.8 -    public static final MethodHandle SETPROTOCHECK      = findOwnMH("setProtoCheck", void.class, Object.class);
    17.9 -    static final MethodHandle MEGAMORPHIC_GET    = findOwnMH("megamorphicGet", Object.class, String.class, boolean.class, boolean.class);
   17.10 +    static final MethodHandle MEGAMORPHIC_GET    = findOwnMH("megamorphicGet", Object.class, String.class, boolean.class);
   17.11      static final MethodHandle GLOBALFILTER       = findOwnMH("globalFilter", Object.class, Object.class);
   17.12  
   17.13      static final MethodHandle SETFIELD           = findOwnMH("setField",         void.class, CallSiteDescriptor.class, PropertyMap.class, PropertyMap.class, MethodHandle.class, Object.class, Object.class);
   17.14 @@ -160,7 +158,7 @@
   17.15      public static final Call SET_PROTO          = virtualCallNoLookup(ScriptObject.class, "setInitialProto", void.class, ScriptObject.class);
   17.16  
   17.17      /** Method handle for setting the proto of a ScriptObject after checking argument */
   17.18 -    public static final Call SET_PROTO_CHECK    = virtualCallNoLookup(ScriptObject.class, "setProtoCheck", void.class, Object.class);
   17.19 +    public static final Call SET_PROTO_FROM_LITERAL    = virtualCallNoLookup(ScriptObject.class, "setProtoFromLiteral", void.class, Object.class);
   17.20  
   17.21      /** Method handle for setting the user accessors of a ScriptObject */
   17.22      public static final Call SET_USER_ACCESSORS = virtualCall(MethodHandles.lookup(), ScriptObject.class, "setUserAccessors", void.class, String.class, ScriptFunction.class, ScriptFunction.class);
   17.23 @@ -1127,14 +1125,21 @@
   17.24  
   17.25      /**
   17.26       * Set the __proto__ of an object with checks.
   17.27 +     * This is the built-in operation [[SetPrototypeOf]]
   17.28 +     * See ES6 draft spec: 9.1.2 [[SetPrototypeOf]] (V)
   17.29 +     *
   17.30       * @param newProto Prototype to set.
   17.31       */
   17.32 -    public final void setProtoCheck(final Object newProto) {
   17.33 -        if (!isExtensible()) {
   17.34 -            throw typeError("__proto__.set.non.extensible", ScriptRuntime.safeToString(this));
   17.35 -        }
   17.36 -
   17.37 +    public final void setPrototypeOf(final Object newProto) {
   17.38          if (newProto == null || newProto instanceof ScriptObject) {
   17.39 +            if (!isExtensible()) {
   17.40 +                // okay to set same proto again - even if non-extensible
   17.41 +                if (newProto == getProto()) {
   17.42 +                    return;
   17.43 +                }
   17.44 +                throw typeError("__proto__.set.non.extensible", ScriptRuntime.safeToString(this));
   17.45 +            }
   17.46 +
   17.47              // check for circularity
   17.48              ScriptObject p = (ScriptObject)newProto;
   17.49              while (p != null) {
   17.50 @@ -1145,14 +1150,27 @@
   17.51              }
   17.52              setProto((ScriptObject)newProto);
   17.53          } else {
   17.54 -            final Global global = Context.getGlobal();
   17.55 -            final Object  newProtoObject = JSType.toScriptObject(global, newProto);
   17.56 -
   17.57 -            if (newProtoObject instanceof ScriptObject) {
   17.58 -                setProto((ScriptObject)newProtoObject);
   17.59 -            } else {
   17.60 -                throw typeError(global, "cant.set.proto.to.non.object", ScriptRuntime.safeToString(this), ScriptRuntime.safeToString(newProto));
   17.61 -            }
   17.62 +            throw typeError("cant.set.proto.to.non.object", ScriptRuntime.safeToString(this), ScriptRuntime.safeToString(newProto));
   17.63 +        }
   17.64 +    }
   17.65 +
   17.66 +    /**
   17.67 +     * Set the __proto__ of an object from an object literal.
   17.68 +     * See ES6 draft spec: B.3.1 __proto__ Property Names in
   17.69 +     * Object Initializers. Step 6 handling of "__proto__".
   17.70 +     *
   17.71 +     * @param newProto Prototype to set.
   17.72 +     */
   17.73 +    public final void setProtoFromLiteral(final Object newProto) {
   17.74 +        if (newProto == null || newProto instanceof ScriptObject) {
   17.75 +            setPrototypeOf(newProto);
   17.76 +        } else {
   17.77 +            // Some non-object, non-null. Then, we need to set
   17.78 +            // Object.prototype as the new __proto__
   17.79 +            //
   17.80 +            // var obj = { __proto__ : 34 };
   17.81 +            // print(obj.__proto__ === Object.prototype); // => true
   17.82 +            setPrototypeOf(Global.objectPrototype());
   17.83          }
   17.84      }
   17.85  
   17.86 @@ -1727,7 +1745,7 @@
   17.87      protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) {
   17.88          final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
   17.89          if (request.isCallSiteUnstable() || hasWithScope()) {
   17.90 -            return findMegaMorphicGetMethod(desc, name, "getMethod".equals(operator), isScope() && NashornCallSiteDescriptor.isScope(desc));
   17.91 +            return findMegaMorphicGetMethod(desc, name, "getMethod".equals(operator));
   17.92          }
   17.93  
   17.94          final FindProperty find = findProperty(name, true);
   17.95 @@ -1770,22 +1788,19 @@
   17.96      }
   17.97  
   17.98      private static GuardedInvocation findMegaMorphicGetMethod(final CallSiteDescriptor desc, final String name,
   17.99 -                                                              final boolean isMethod, final boolean isScope) {
  17.100 -        final MethodHandle invoker = MH.insertArguments(MEGAMORPHIC_GET, 1, name, isMethod, isScope);
  17.101 +                                                              final boolean isMethod) {
  17.102 +        final MethodHandle invoker = MH.insertArguments(MEGAMORPHIC_GET, 1, name, isMethod);
  17.103          final MethodHandle guard = getScriptObjectGuard(desc.getMethodType());
  17.104          return new GuardedInvocation(invoker, guard);
  17.105      }
  17.106  
  17.107      @SuppressWarnings("unused")
  17.108 -    private Object megamorphicGet(final String key, final boolean isMethod, final boolean isScope) {
  17.109 +    private Object megamorphicGet(final String key, final boolean isMethod) {
  17.110          final FindProperty find = findProperty(key, true);
  17.111  
  17.112          if (find != null) {
  17.113              return find.getObjectValue();
  17.114          }
  17.115 -        if (isScope) {
  17.116 -            throw referenceError("not.defined", key);
  17.117 -        }
  17.118  
  17.119          return isMethod ? getNoSuchMethod(key) : invokeNoSuchProperty(key);
  17.120      }
    18.1 --- a/src/jdk/nashorn/internal/runtime/Source.java	Wed Jun 18 12:35:42 2014 -0700
    18.2 +++ b/src/jdk/nashorn/internal/runtime/Source.java	Thu Jun 19 17:59:34 2014 -0700
    18.3 @@ -124,6 +124,11 @@
    18.4          }
    18.5      }
    18.6  
    18.7 +    /* package-private */
    18.8 +    DebuggerSupport.SourceInfo getSourceInfo() {
    18.9 +        return new DebuggerSupport.SourceInfo(getName(), data.hashCode(),  data.url(), data.array());
   18.10 +    }
   18.11 +
   18.12      // Wrapper to manage lazy loading
   18.13      private static interface Data {
   18.14  
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/script/basic/JDK-8044520.js	Thu Jun 19 17:59:34 2014 -0700
    19.3 @@ -0,0 +1,145 @@
    19.4 +/*
    19.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + * 
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + * 
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + * 
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + * 
   19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 + * or visit www.oracle.com if you need additional information or have any
   19.24 + * questions.
   19.25 + */
   19.26 +
   19.27 +/**
   19.28 + * JDK-8044520: Nashorn cannot execute node.js's express module
   19.29 + *
   19.30 + * @test
   19.31 + * @run
   19.32 + */
   19.33 +
   19.34 +function checkNullProto() {
   19.35 +    var obj = {};
   19.36 +    obj.__proto__ = null;
   19.37 +    var proto = Object.getPrototypeOf(obj);
   19.38 +    if (typeof proto != 'object' || proto !== null) {
   19.39 +        fail("__proto__ can't be set to null!");
   19.40 +    }
   19.41 +}
   19.42 +
   19.43 +checkNullProto();
   19.44 +
   19.45 +function checkSetProto(proto) {
   19.46 +    var obj = {};
   19.47 +    obj.__proto__ = proto;
   19.48 +    if (Object.getPrototypeOf(obj) !== Object.prototype) {
   19.49 +        fail("obj.__proto__ set not ignored for " + proto);
   19.50 +    }
   19.51 +}
   19.52 +
   19.53 +checkSetProto(undefined);
   19.54 +checkSetProto(42);
   19.55 +checkSetProto(false);
   19.56 +checkSetProto("hello");
   19.57 +
   19.58 +function checkLiteralSetProto(proto) {
   19.59 +    var obj = { __proto__: proto };
   19.60 +    if (obj.__proto__ !== Object.prototype) {
   19.61 +        fail("object literal _proto__ set not ignored for " + proto);
   19.62 +    }
   19.63 +}
   19.64 +
   19.65 +checkLiteralSetProto(undefined);
   19.66 +checkLiteralSetProto(34);
   19.67 +checkLiteralSetProto(true);
   19.68 +checkLiteralSetProto("world");
   19.69 +
   19.70 +function checkNullProtoFromLiteral() {
   19.71 +    var obj = { __proto__: null };
   19.72 +    var proto = Object.getPrototypeOf(obj);
   19.73 +    if (typeof proto != 'object' || proto !== null) {
   19.74 +        fail("__proto__ can't be set to null!");
   19.75 +    }
   19.76 +}
   19.77 +
   19.78 +checkNullProtoFromLiteral();
   19.79 +
   19.80 +function checkSetPrototypeOf(proto) {
   19.81 +    try {
   19.82 +        Object.setPrototypeOf({}, proto);
   19.83 +        fail("should have thrown error for " + proto);
   19.84 +    } catch (e) {
   19.85 +        if (! (e instanceof TypeError)) {
   19.86 +            fail("should have thrown TypeError, got " + e);
   19.87 +        }
   19.88 +    }
   19.89 +}
   19.90 +
   19.91 +checkSetPrototypeOf(undefined);
   19.92 +checkSetPrototypeOf(43);
   19.93 +checkSetPrototypeOf(false);
   19.94 +checkSetPrototypeOf("nashorn");
   19.95 +
   19.96 +function checkNullSetPrototypeOf() {
   19.97 +    var obj = { };
   19.98 +    Object.setPrototypeOf(obj, null);
   19.99 +    var proto = Object.getPrototypeOf(obj);
  19.100 +    if (typeof proto != 'object' || proto !== null) {
  19.101 +        fail("__proto__ can't be set to null!");
  19.102 +    }
  19.103 +}
  19.104 +
  19.105 +checkNullSetPrototypeOf();
  19.106 +
  19.107 +var desc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
  19.108 +
  19.109 +function checkProtoGetterOnPrimitive(value) {
  19.110 +    // call __proto__ getter on primitive - check ToObject
  19.111 +    // is called on 'this' value as per draft spec
  19.112 +    if (desc.get.call(value) !== Object(value).__proto__) {
  19.113 +        fail("can't call __proto__ getter on " + value);
  19.114 +    }
  19.115 +}
  19.116 +
  19.117 +checkProtoGetterOnPrimitive(32);
  19.118 +checkProtoGetterOnPrimitive(false);
  19.119 +checkProtoGetterOnPrimitive("great!");
  19.120 +
  19.121 +function checkProtoSetterOnNonObjectThis(self) {
  19.122 +    try {
  19.123 +        desc.set.call(self);
  19.124 +        fail("should have thrown TypeError");
  19.125 +    } catch (e) {
  19.126 +        if (! (e instanceof TypeError)) {
  19.127 +            fail("should throw TypeError on non-object self, got " +e);
  19.128 +        }
  19.129 +    }
  19.130 +}
  19.131 +
  19.132 +checkProtoSetterOnNonObjectThis(undefined);
  19.133 +checkProtoSetterOnNonObjectThis(null);
  19.134 +
  19.135 +function checkProtoSetterReturnValue(obj, p) {
  19.136 +    if (typeof desc.set.call(obj, p) != "undefined") {
  19.137 +        fail("__proto__ setter does not return undefined: " + obj + " " + p);
  19.138 +    }
  19.139 +}
  19.140 +
  19.141 +// try non-object 'this'. setter is expected to return undefined.
  19.142 +checkProtoSetterReturnValue(23);
  19.143 +checkProtoSetterReturnValue(false);
  19.144 +checkProtoSetterReturnValue("foo");
  19.145 +
  19.146 +// set proper __proto__. Still return value is undefined.
  19.147 +checkProtoSetterReturnValue({}, {});
  19.148 +checkProtoSetterReturnValue({}, null);
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/script/basic/JDK-8044612.js	Thu Jun 19 17:59:34 2014 -0700
    20.3 @@ -0,0 +1,37 @@
    20.4 +/*
    20.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 + *
    20.8 + * This code is free software; you can redistribute it and/or modify it
    20.9 + * under the terms of the GNU General Public License version 2 only, as
   20.10 + * published by the Free Software Foundation.
   20.11 + *
   20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 + * version 2 for more details (a copy is included in the LICENSE file that
   20.16 + * accompanied this code).
   20.17 + *
   20.18 + * You should have received a copy of the GNU General Public License version
   20.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 + *
   20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.23 + * or visit www.oracle.com if you need additional information or have any
   20.24 + * questions.
   20.25 + */
   20.26 +
   20.27 +/**
   20.28 + * JDK-8044612: StringIndexOutOfBoundException in NativeRegExp.appendReplacement
   20.29 + *
   20.30 + * @test
   20.31 + * @run
   20.32 + */
   20.33 +
   20.34 +if ("hello".replace("h", "$") != "$ello") {
   20.35 +    fail("String.prototype.replace failed to handle '$' as replacement");
   20.36 +}
   20.37 +
   20.38 +if ("hello".replace("o", "$x") != "hell$x") {
   20.39 +    fail("String.prototype.replace failed to handle '$x' as replacement");
   20.40 +} 
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/script/basic/JDK-8044695.js	Thu Jun 19 17:59:34 2014 -0700
    21.3 @@ -0,0 +1,37 @@
    21.4 +/*
    21.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + * 
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + * 
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + * 
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + * 
   21.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   21.23 + * or visit www.oracle.com if you need additional information or have any
   21.24 + * questions.
   21.25 + */
   21.26 +
   21.27 +/**
   21.28 + * JDK-8044695: __stack__ becomes visible in Error properties
   21.29 + *
   21.30 + * @test
   21.31 + * @run
   21.32 + */
   21.33 +
   21.34 +var e = new Error();
   21.35 +// access stack to force __stack__
   21.36 +e.stack;
   21.37 +var jsonStr = JSON.stringify(e);
   21.38 +if (jsonStr != "{}") {
   21.39 +    fail("JSON string is not {}, it is " + jsonStr);
   21.40 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/script/basic/JDK-8044750.js	Thu Jun 19 17:59:34 2014 -0700
    22.3 @@ -0,0 +1,53 @@
    22.4 +/*
    22.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + * 
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + * 
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + * 
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + * 
   22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 + * or visit www.oracle.com if you need additional information or have any
   22.24 + * questions.
   22.25 + */
   22.26 +
   22.27 +/**
   22.28 + * JDK-8044750: megamorphic getter for scope objects does not call __noSuchProperty__ hook
   22.29 + *
   22.30 + * @test
   22.31 + * @run
   22.32 + */
   22.33 +
   22.34 +__noSuchProperty__ = function(name) {
   22.35 +    return 1;
   22.36 +}
   22.37 +
   22.38 +function func(obj) {
   22.39 +    with(obj) {
   22.40 +        // this "foo" getter site becomes megamorphic
   22.41 +        // due to different 'with' scope objects.
   22.42 +        foo;
   22.43 +    }
   22.44 +}
   22.45 +
   22.46 +for (var i = 0; i < 20; i++) {
   22.47 +    var obj = {};
   22.48 +    obj.foo = i;
   22.49 +    obj[i] = i;
   22.50 +    func(obj);
   22.51 +}
   22.52 +
   22.53 +// pass a 'with' scope object that does not have 'foo'.
   22.54 +// callsite inside func should see __noSuchProperty__
   22.55 +// hook on global scope object.
   22.56 +func({});
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/script/nosecurity/JDK-8044798.js	Thu Jun 19 17:59:34 2014 -0700
    23.3 @@ -0,0 +1,159 @@
    23.4 +/*
    23.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.7 + * 
    23.8 + * This code is free software; you can redistribute it and/or modify it
    23.9 + * under the terms of the GNU General Public License version 2 only, as
   23.10 + * published by the Free Software Foundation.
   23.11 + * 
   23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   23.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   23.15 + * version 2 for more details (a copy is included in the LICENSE file that
   23.16 + * accompanied this code).
   23.17 + * 
   23.18 + * You should have received a copy of the GNU General Public License version
   23.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   23.21 + * 
   23.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   23.23 + * or visit www.oracle.com if you need additional information or have any
   23.24 + * questions.
   23.25 + */
   23.26 +
   23.27 +/**
   23.28 + * JDK-8044798: API for debugging Nashorn
   23.29 + *
   23.30 + * @test
   23.31 + * @run
   23.32 + */
   23.33 +
   23.34 +// basic API exercise checks
   23.35 +
   23.36 +var Arrays = Java.type("java.util.Arrays");
   23.37 +var CharArray = Java.type("char[]");
   23.38 +var DebuggerSupport = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport");
   23.39 +var DebuggerValueDesc = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport.DebuggerValueDesc");
   23.40 +
   23.41 +var valueDescFields = DebuggerValueDesc.class.declaredFields;
   23.42 +Arrays.sort(valueDescFields, function(f1, f2) f1.name.compareTo(f2.name));
   23.43 +var keyField;
   23.44 +for each (var f in valueDescFields) {
   23.45 +    if (f.name == "key") {
   23.46 +        keyField = f;
   23.47 +    }
   23.48 +    f.accessible = true;
   23.49 +}
   23.50 +
   23.51 +var debuggerSupportMethods = DebuggerSupport.class.declaredMethods;
   23.52 +
   23.53 +// methods of DebuggerSupport that we use
   23.54 +var evalMethod, valueInfoMethod, valueInfosMethod;
   23.55 +var getSourceInfoMethod, valueAsStringMethod;
   23.56 +
   23.57 +for each (var m in debuggerSupportMethods) {
   23.58 +    m.accessible = true;
   23.59 +    switch (m.name) {
   23.60 +        case "eval":
   23.61 +            evalMethod = m;
   23.62 +            break;
   23.63 +        case "valueInfo":
   23.64 +            if (m.parameterCount == 3) {
   23.65 +                valueInfoMethod = m;
   23.66 +            }
   23.67 +            break;
   23.68 +        case "valueInfos":
   23.69 +            valueInfosMethod = m;
   23.70 +            break;
   23.71 +        case "valueAsString":
   23.72 +            valueAsStringMethod = m;
   23.73 +            break;
   23.74 +        case "getSourceInfo":
   23.75 +            getSourceInfoMethod = m;
   23.76 +            break;
   23.77 +    }
   23.78 +}
   23.79 +
   23.80 +// eval
   23.81 +var value = evalMethod.invoke(null, null, null, "33 + 55", false);
   23.82 +print(value);
   23.83 +
   23.84 +// valueInfo
   23.85 +var info = valueInfoMethod.invoke(null, "apply", Function, true);
   23.86 +for each (var f in valueDescFields) {
   23.87 +    print(f.name, "=", f.get(info));
   23.88 +}
   23.89 +
   23.90 +// valueInfo - user defined object
   23.91 +var info = valueInfoMethod.invoke(null, "foo", { foo: 343 }, true);
   23.92 +for each (var f in valueDescFields) {
   23.93 +    print(f.name, "=", f.get(info));
   23.94 +}
   23.95 +
   23.96 +// valueInfos
   23.97 +var infos = valueInfosMethod.invoke(null, Object, true);
   23.98 +Arrays.sort(infos, function (i1, i2) keyField.get(i1).compareTo(keyField.get(i2)));
   23.99 +
  23.100 +for each (var info in infos) {
  23.101 +    for each (var f in valueDescFields) {
  23.102 +        print(f.name, "=", f.get(info));
  23.103 +    }  
  23.104 +}
  23.105 +
  23.106 +// valueInfos - user defined object
  23.107 +var infos = valueInfosMethod.invoke(null, { foo: 34, bar: "hello" }, true);
  23.108 +Arrays.sort(infos, function (i1, i2) keyField.get(i1).compareTo(keyField.get(i2)));
  23.109 +
  23.110 +for each (var info in infos) {
  23.111 +    for each (var f in valueDescFields) {
  23.112 +        print(f.name, "=", f.get(info));
  23.113 +    }  
  23.114 +}
  23.115 +
  23.116 +// valueAsString
  23.117 +function printValue(value) {
  23.118 +    print(valueAsStringMethod.invoke(null, value));
  23.119 +}
  23.120 +
  23.121 +printValue(undefined);
  23.122 +printValue(null);
  23.123 +printValue("hello");
  23.124 +printValue(Math.PI);
  23.125 +printValue(this);
  23.126 +
  23.127 +// The below are not part of DebuggerSupport. But we need these to
  23.128 +// test DebuggerSupport.getSourceInfo etc. which need compiled script class
  23.129 +
  23.130 +var Source = Java.type("jdk.nashorn.internal.runtime.Source");
  23.131 +var Context = Java.type("jdk.nashorn.internal.runtime.Context");
  23.132 +var sourceCls = Source.class;
  23.133 +var errorMgrCls = Java.type("jdk.nashorn.internal.runtime.ErrorManager").class;
  23.134 +var booleanCls = Java.type("java.lang.Boolean").TYPE;
  23.135 +
  23.136 +// private compile method of Context class
  23.137 +var compileMethod = Context.class.getDeclaredMethod("compile",
  23.138 +                sourceCls, errorMgrCls, booleanCls);
  23.139 +compileMethod.accessible = true;
  23.140 +
  23.141 +var scriptCls = compileMethod.invoke(Context.context,
  23.142 +    Source.sourceFor("test", "print('hello')"),
  23.143 +    new Context.ThrowErrorManager(), false);
  23.144 +
  23.145 +var SCRIPT_CLASS_NAME_PREFIX = "jdk.nashorn.internal.scripts.Script$";
  23.146 +print("script class name pattern satisfied? " +
  23.147 +    scriptCls.name.startsWith(SCRIPT_CLASS_NAME_PREFIX));
  23.148 +
  23.149 +var srcInfo = getSourceInfoMethod.invoke(null, scriptCls);
  23.150 +var srcInfoFields = srcInfo.class.declaredFields;
  23.151 +Arrays.sort(srcInfoFields, function(f1, f2) f1.name.compareTo(f2.name));
  23.152 +
  23.153 +print("Source info");
  23.154 +for each (var f in srcInfoFields) {
  23.155 +    f.accessible = true;
  23.156 +    var fieldValue = f.get(srcInfo);
  23.157 +    if (fieldValue instanceof CharArray) {
  23.158 +        fieldValue = new java.lang.String(fieldValue);
  23.159 +    }
  23.160 +
  23.161 +    print(f.name, "=", fieldValue);
  23.162 +}
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/script/nosecurity/JDK-8044798.js.EXPECTED	Thu Jun 19 17:59:34 2014 -0700
    24.3 @@ -0,0 +1,104 @@
    24.4 +88
    24.5 +expandable = false
    24.6 +key = apply
    24.7 +valueAsObject = function Function() { [native code] }
    24.8 +valueAsString = function Function() { [native code] }
    24.9 +expandable = true
   24.10 +key = foo
   24.11 +valueAsObject = [object Object]
   24.12 +valueAsString = {foo: 343}
   24.13 +expandable = false
   24.14 +key = bindProperties
   24.15 +valueAsObject = function bindProperties() { [native code] }
   24.16 +valueAsString = function bindProperties() { [native code] }
   24.17 +expandable = false
   24.18 +key = create
   24.19 +valueAsObject = function create() { [native code] }
   24.20 +valueAsString = function create() { [native code] }
   24.21 +expandable = false
   24.22 +key = defineProperties
   24.23 +valueAsObject = function defineProperties() { [native code] }
   24.24 +valueAsString = function defineProperties() { [native code] }
   24.25 +expandable = false
   24.26 +key = defineProperty
   24.27 +valueAsObject = function defineProperty() { [native code] }
   24.28 +valueAsString = function defineProperty() { [native code] }
   24.29 +expandable = false
   24.30 +key = freeze
   24.31 +valueAsObject = function freeze() { [native code] }
   24.32 +valueAsString = function freeze() { [native code] }
   24.33 +expandable = false
   24.34 +key = getOwnPropertyDescriptor
   24.35 +valueAsObject = function getOwnPropertyDescriptor() { [native code] }
   24.36 +valueAsString = function getOwnPropertyDescriptor() { [native code] }
   24.37 +expandable = false
   24.38 +key = getOwnPropertyNames
   24.39 +valueAsObject = function getOwnPropertyNames() { [native code] }
   24.40 +valueAsString = function getOwnPropertyNames() { [native code] }
   24.41 +expandable = false
   24.42 +key = getPrototypeOf
   24.43 +valueAsObject = function getPrototypeOf() { [native code] }
   24.44 +valueAsString = function getPrototypeOf() { [native code] }
   24.45 +expandable = false
   24.46 +key = isExtensible
   24.47 +valueAsObject = function isExtensible() { [native code] }
   24.48 +valueAsString = function isExtensible() { [native code] }
   24.49 +expandable = false
   24.50 +key = isFrozen
   24.51 +valueAsObject = function isFrozen() { [native code] }
   24.52 +valueAsString = function isFrozen() { [native code] }
   24.53 +expandable = false
   24.54 +key = isSealed
   24.55 +valueAsObject = function isSealed() { [native code] }
   24.56 +valueAsString = function isSealed() { [native code] }
   24.57 +expandable = false
   24.58 +key = keys
   24.59 +valueAsObject = function keys() { [native code] }
   24.60 +valueAsString = function keys() { [native code] }
   24.61 +expandable = false
   24.62 +key = length
   24.63 +valueAsObject = 1
   24.64 +valueAsString = 1
   24.65 +expandable = false
   24.66 +key = name
   24.67 +valueAsObject = Object
   24.68 +valueAsString = "Object"
   24.69 +expandable = false
   24.70 +key = preventExtensions
   24.71 +valueAsObject = function preventExtensions() { [native code] }
   24.72 +valueAsString = function preventExtensions() { [native code] }
   24.73 +expandable = false
   24.74 +key = prototype
   24.75 +valueAsObject = [object Object]
   24.76 +valueAsString = {toString: function toString() { [native code] }, toLocaleString: function toLocaleString() { [native code] }, valueOf: function valueOf() { [native code] }, hasOwnProperty: function hasOwnProperty() { [native code] }, isPrototypeOf: function isPrototypeOf() { [native code] }, propertyIsEnumerable: function propertyIsEnumerable() { [native code] }, constructor: function Object() { [native code] }, __proto__: null}
   24.77 +expandable = false
   24.78 +key = seal
   24.79 +valueAsObject = function seal() { [native code] }
   24.80 +valueAsString = function seal() { [native code] }
   24.81 +expandable = false
   24.82 +key = setIndexedPropertiesToExternalArrayData
   24.83 +valueAsObject = function setIndexedPropertiesToExternalArrayData() { [native code] }
   24.84 +valueAsString = function setIndexedPropertiesToExternalArrayData() { [native code] }
   24.85 +expandable = false
   24.86 +key = setPrototypeOf
   24.87 +valueAsObject = function setPrototypeOf() { [native code] }
   24.88 +valueAsString = function setPrototypeOf() { [native code] }
   24.89 +expandable = false
   24.90 +key = bar
   24.91 +valueAsObject = hello
   24.92 +valueAsString = "hello"
   24.93 +expandable = false
   24.94 +key = foo
   24.95 +valueAsObject = 34
   24.96 +valueAsString = 34
   24.97 +undefined
   24.98 +null
   24.99 +"hello"
  24.100 +3.141592653589793
  24.101 +[object global]
  24.102 +script class name pattern satisfied? true
  24.103 +Source info
  24.104 +content = print('hello')
  24.105 +hash = 1655359881
  24.106 +name = test
  24.107 +url = null
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/test/script/nosecurity/debuggersupportapi.js	Thu Jun 19 17:59:34 2014 -0700
    25.3 @@ -0,0 +1,94 @@
    25.4 +/*
    25.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 + * 
    25.8 + * This code is free software; you can redistribute it and/or modify it
    25.9 + * under the terms of the GNU General Public License version 2 only, as
   25.10 + * published by the Free Software Foundation.
   25.11 + * 
   25.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   25.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.15 + * version 2 for more details (a copy is included in the LICENSE file that
   25.16 + * accompanied this code).
   25.17 + * 
   25.18 + * You should have received a copy of the GNU General Public License version
   25.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   25.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.21 + * 
   25.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   25.23 + * or visit www.oracle.com if you need additional information or have any
   25.24 + * questions.
   25.25 + */
   25.26 +
   25.27 +/**
   25.28 + * JDK-8044798: API for debugging Nashorn
   25.29 + *
   25.30 + * @test
   25.31 + * @run
   25.32 + */
   25.33 +
   25.34 +// Basic API class, method, field existence checks.
   25.35 +
   25.36 +// The following classes and the associated methods and fields are used as
   25.37 +// private debugger interface. Though private/implementation defined, nashorn
   25.38 +// code should not be changed to remove these classes, fields and methods.
   25.39 +// The test takes signatures of debugger interface and stores in .EXPECTED file.
   25.40 +// If any incompatible change is made to nashorn to break any of these, this
   25.41 +// test will fail.
   25.42 +
   25.43 +var Arrays = Java.type("java.util.Arrays");
   25.44 +var DebuggerSupport = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport");
   25.45 +
   25.46 +print(DebuggerSupport.class);
   25.47 +print();
   25.48 +var methods = DebuggerSupport.class.declaredMethods;
   25.49 +Arrays.sort(methods, function(m1, m2) m1.name.compareTo(m2.name));
   25.50 +for each (var mth in methods) {
   25.51 +    switch (mth.name) {
   25.52 +        case "eval":
   25.53 +        case "notifyInvoke":
   25.54 +        case "getSourceInfo":
   25.55 +        case "valueAsString":
   25.56 +        case "valueInfos":
   25.57 +            print(mth);
   25.58 +            break;
   25.59 +        case "valueInfo":
   25.60 +            if (mth.parameterCount == 3) {
   25.61 +                print(mth);
   25.62 +            }
   25.63 +            break;
   25.64 +    }
   25.65 +}
   25.66 +print();
   25.67 +
   25.68 +var DebuggerValueDesc = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport.DebuggerValueDesc");
   25.69 +print(DebuggerValueDesc.class);
   25.70 +print();
   25.71 +var fields = DebuggerValueDesc.class.declaredFields;
   25.72 +Arrays.sort(fields, function(f1, f2) f1.name.compareTo(f2.name));
   25.73 +for each (var fld in fields) {
   25.74 +    switch (fld.name) {
   25.75 +        case "key":
   25.76 +        case "expandable":
   25.77 +        case "valueAsObject":
   25.78 +        case "valueAsString":
   25.79 +            print(fld);
   25.80 +    }
   25.81 +}
   25.82 +print();
   25.83 +
   25.84 +var SourceInfo = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport.SourceInfo");
   25.85 +print(SourceInfo.class);
   25.86 +print();
   25.87 +var fields = SourceInfo.class.declaredFields;
   25.88 +Arrays.sort(fields, function(f1, f2) f1.name.compareTo(f2.name));
   25.89 +for each (var fld in fields) {
   25.90 +    switch (fld.name) {
   25.91 +        case "name":
   25.92 +        case "hash":
   25.93 +        case "url":
   25.94 +        case "content":
   25.95 +            print(fld);
   25.96 +    }
   25.97 +}
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/script/nosecurity/debuggersupportapi.js.EXPECTED	Thu Jun 19 17:59:34 2014 -0700
    26.3 @@ -0,0 +1,22 @@
    26.4 +class jdk.nashorn.internal.runtime.DebuggerSupport
    26.5 +
    26.6 +static java.lang.Object jdk.nashorn.internal.runtime.DebuggerSupport.eval(jdk.nashorn.internal.runtime.ScriptObject,java.lang.Object,java.lang.String,boolean)
    26.7 +static jdk.nashorn.internal.runtime.DebuggerSupport$SourceInfo jdk.nashorn.internal.runtime.DebuggerSupport.getSourceInfo(java.lang.Class)
    26.8 +static void jdk.nashorn.internal.runtime.DebuggerSupport.notifyInvoke(java.lang.invoke.MethodHandle)
    26.9 +static java.lang.String jdk.nashorn.internal.runtime.DebuggerSupport.valueAsString(java.lang.Object)
   26.10 +static jdk.nashorn.internal.runtime.DebuggerSupport$DebuggerValueDesc jdk.nashorn.internal.runtime.DebuggerSupport.valueInfo(java.lang.String,java.lang.Object,boolean)
   26.11 +static jdk.nashorn.internal.runtime.DebuggerSupport$DebuggerValueDesc[] jdk.nashorn.internal.runtime.DebuggerSupport.valueInfos(java.lang.Object,boolean)
   26.12 +
   26.13 +class jdk.nashorn.internal.runtime.DebuggerSupport$DebuggerValueDesc
   26.14 +
   26.15 +final boolean jdk.nashorn.internal.runtime.DebuggerSupport$DebuggerValueDesc.expandable
   26.16 +final java.lang.String jdk.nashorn.internal.runtime.DebuggerSupport$DebuggerValueDesc.key
   26.17 +final java.lang.Object jdk.nashorn.internal.runtime.DebuggerSupport$DebuggerValueDesc.valueAsObject
   26.18 +final java.lang.String jdk.nashorn.internal.runtime.DebuggerSupport$DebuggerValueDesc.valueAsString
   26.19 +
   26.20 +class jdk.nashorn.internal.runtime.DebuggerSupport$SourceInfo
   26.21 +
   26.22 +final char[] jdk.nashorn.internal.runtime.DebuggerSupport$SourceInfo.content
   26.23 +final int jdk.nashorn.internal.runtime.DebuggerSupport$SourceInfo.hash
   26.24 +final java.lang.String jdk.nashorn.internal.runtime.DebuggerSupport$SourceInfo.name
   26.25 +final java.net.URL jdk.nashorn.internal.runtime.DebuggerSupport$SourceInfo.url
    27.1 --- a/test/src/jdk/nashorn/api/scripting/ScopeTest.java	Wed Jun 18 12:35:42 2014 -0700
    27.2 +++ b/test/src/jdk/nashorn/api/scripting/ScopeTest.java	Thu Jun 19 17:59:34 2014 -0700
    27.3 @@ -510,6 +510,23 @@
    27.4          assertEquals(e.eval("x", newCtxt), 2);
    27.5      }
    27.6  
    27.7 +    // @bug 8044750: megamorphic getter for scope objects does not call __noSuchProperty__ hook
    27.8 +    @Test
    27.9 +    public static void testMegamorphicGetInGlobal() throws Exception {
   27.10 +        final ScriptEngineManager m = new ScriptEngineManager();
   27.11 +        final ScriptEngine engine = m.getEngineByName("nashorn");
   27.12 +        final String script = "foo";
   27.13 +        // "foo" is megamorphic because of different global scopes.
   27.14 +        // Make sure ScriptContext variable search works even after
   27.15 +        // it becomes megamorphic.
   27.16 +        for (int index = 0; index < 25; index++) {
   27.17 +            final Bindings bindings = new SimpleBindings();
   27.18 +            bindings.put("foo", index);
   27.19 +            final Number value = (Number)engine.eval(script, bindings);
   27.20 +            assertEquals(index, value.intValue());
   27.21 +        }
   27.22 +    }
   27.23 +
   27.24      /**
   27.25       * Test "slow" scopes involving {@code with} and {@code eval} statements for shared script classes with multiple globals.
   27.26       */

mercurial