jdk-24/nashorn
Chris Hegarty 5fe51a5b71 8054834: Modular Source Code
Co-authored-by: Alan Bateman <alan.bateman@oracle.com>
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Magnus Ihse Bursie <magnus.ihse.bursie@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Paul Sandoz <paul.sandoz@oracle.com>
Reviewed-by: alanb, chegar, ihse, mduigou
2014-08-17 15:56:32 +01:00
..
.jcheck 8030068: Update .jcheck/conf files for JDK 9 2013-12-13 09:36:37 -08:00
bin 8047728: (function(x){var o={x:0}; with(o){delete x} return o.x})() evaluates to 0 instead of undefined 2014-06-23 21:23:53 +05:30
buildtools/nasgen 8046898: Make sure that lazy compilation is the default, remove redundant "enable lazy compilation" flags, added warning message if compile logging is enabled and lazy is switched off. Verified existing test suite code coverage equivalence between lazy and eager 2014-06-17 11:37:03 +02:00
docs 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line) 2014-05-27 21:25:07 +02:00
exclude 8022614: Please exclude test test/script/trusted/JDK-8020809.js from Nashorn code coverage run 2013-08-12 16:52:32 +05:30
make 8054834: Modular Source Code 2014-08-17 15:56:32 +01:00
samples 8050964: OptimisticTypesPersistence.java should use java.util.Date instead of java.sql.Date 2014-07-17 16:47:06 +05:30
src/jdk.scripting.nashorn/share/classes 8054834: Modular Source Code 2014-08-17 15:56:32 +01:00
test 8051439: Wrong type calculated for ADD operator with undefined operand 2014-08-06 11:02:14 +02:00
tools/fxshell/jdk/nashorn/tools 8023550: -d option was broken for any dir but '.'. Fixed Java warnings 2013-08-23 14:16:16 +02:00
.hgignore 8035820: Optimistic recompilation 2014-02-26 13:17:57 +01:00
.hgtags Added tag jdk9-b26 for changeset e60692e4f736 2014-08-10 19:39:07 -07:00
ASSEMBLY_EXCEPTION 8005403: Open-source Nashorn 2012-12-21 16:36:24 -04:00
LICENSE 8005403: Open-source Nashorn 2012-12-21 16:36:24 -04:00
README 8038615: test262 repo is now a git repo in github 2014-03-28 13:24:07 +05:30
RELEASE_README 8005403: Open-source Nashorn 2012-12-21 16:36:24 -04:00
THIRD_PARTY_README 8032816: THIRDPARTYREADME LittleCMS preamble missing JRE 8 & JDK 8 2014-01-28 20:10:23 +00:00

- What is Nashorn?

Nashorn is a runtime environment for programs written in ECMAScript 5.1
that runs on top of JVM.

- How to find out more about ECMAScript 5.1?

The specification can be found at

    http://www.ecma-international.org/publications/standards/Ecma-262.htm

- How to checkout sources of Nashorn project?

Nashorn project uses Mercurial source code control system. You can
download Mercurial from http://mercurial.selenic.com/wiki/Download

Information about the forest extension can be found at

    http://mercurial.selenic.com/wiki/ForestExtension

and downlaoded using

    hg clone https://bitbucket.org/gxti/hgforest

You can clone Nashorn Mercurial forest using this command:

    hg fclone http://hg.openjdk.java.net/nashorn/jdk8 nashorn~jdk8
    
To update your copy of the forest (fwith the latest code:

    (cd nashorn~jdk8 ; hg fpull)
    
Or just the nashorn subdirectory with

    (cd nashorn~jdk8/nashorn ; hg pull -u)
    
To learn about Mercurial in detail, please visit http://hgbook.red-bean.com.

- How to build?

To build Nashorn, you need to install JDK 8. You may use the Nashorn
forest build (recommended) or down load from java.net.  You will need to
set JAVA_HOME environmental variable to point to your JDK installation
directory.

    cd nashorn~jdk8/nashorn/make
    ant clean; ant

- How to run?

Use the jjs script (see RELESE_README):

    cd nashorn~jdk8/nashorn
    sh bin/jjs <your .js file>

Nashorn supports javax.script API. It is possible to drop nashorn.jar in
class path and request for "nashorn" script engine from
javax.script.ScriptEngineManager. 

Look for samples under the directory test/src/jdk/nashorn/api/scripting/.

- Documentation

Comprehensive development documentation is found in the Nashorn JavaDoc. You can
build it using:

    cd nashorn~jdk8/nashorn/make
    ant javadoc
    
after which you can view the generated documentation at dist/javadoc/index.html.

- Running tests

Nashorn tests are TestNG based. Running tests requires downloading the
TestNG library and placing its jar file into the lib subdirectory:

    # download and install TestNG
    wget http://testng.org/testng-x.y.z.zip
    unzip testng-x.y.z.zip
    cp testng-x.y.z/testng-x.y.z.jar test/lib/testng.jar
    
After that, you can run the tests using:
    cd make
    ant clean test
    
You can also run the ECMA-262 test suite with Nashorn. In order to do
that, you will need to get a copy of it and put it in
test/script/external/test262 directory. A convenient way to do it is:

   git clone https://github.com/tc39/test262 test/script/external/test262
    
Alternatively, you can check it out elsewhere and make
test/script/external/test262 a symbolic link to that directory. After
you've done this, you can run the ECMA-262 tests using:

    cd nashorn~jdk8/nashorn/make
    ant test262

Ant target to get/update external test suites:

    ant externals
    ant update-externals
    
These tests take time, so we have a parallelized runner for them that
takes advantage of all processor cores on the computer:

    cd nashorn~jdk8/nashorn/make
    ant test262parallel
    
- How to write your own test?

Nashorn uses it's own simple test framework. Any .js file dropped under
nashorn/test directory is considered as a test. A test file can
optionally have .js.EXPECTED (foo.js.EXPECTED for foo.js) associated
with it. The .EXPECTED file, if exists, should contain the output
expected from compiling and/or running the test file.

The test runner crawls these directories for .js files and looks for
JTReg-style @foo comments to identify tests.

    * @test - A test is tagged with @test.

    * @test/fail - Tests that are supposed to fail (compiling, see @run/fail
      for runtime) are tagged with @test/fail.

    * @test/compile-error - Test expects compilation to fail, compares
      output.

    * @test/warning - Test expects compiler warnings, compares output.

    * @test/nocompare - Test expects to compile [and/or run?]
      successfully(may be warnings), does not compare output.

    * @subtest - denotes necessary file for a main test file; itself is not
      a test.

    * @run - A test that should be run is also tagged with @run (otherwise
      the test runner only compiles the test).

    * @run/fail - A test that should compile but fail with a runtime error.

    * @run/ignore-std-error - script may produce output on stderr, ignore
      this output.

    * @argument - pass an argument to script.

    * @option \ - pass option to engine, sample.

/**
 * @option --dump-ir-graph
 * @test
 */