annotate README @ 1494:c7ef0fb26eff

8141144: Move NameCodec to jdk.nashorn.internal space Reviewed-by: hannesw, sundar
author attila
date Mon, 02 Nov 2015 18:26:53 +0100
parents 9f8ab1b79632
children
rev   line source
sundar@1027 1 - What is Nashorn?
sundar@1027 2
sundar@1027 3 Nashorn is a runtime environment for programs written in ECMAScript 5.1
sundar@1027 4 that runs on top of JVM.
sundar@1027 5
sundar@1027 6 - How to find out more about ECMAScript 5.1?
sundar@1027 7
sundar@1027 8 The specification can be found at
sundar@1027 9
sundar@1027 10 http://www.ecma-international.org/publications/standards/Ecma-262.htm
sundar@1027 11
sundar@1027 12 - How to checkout sources of Nashorn project?
sundar@1027 13
sundar@1027 14 Nashorn project uses Mercurial source code control system. You can
sundar@1027 15 download Mercurial from http://mercurial.selenic.com/wiki/Download
sundar@1027 16
sundar@1027 17 Information about the forest extension can be found at
sundar@1027 18
sundar@1027 19 http://mercurial.selenic.com/wiki/ForestExtension
sundar@1027 20
sundar@1027 21 and downlaoded using
sundar@1027 22
sundar@1027 23 hg clone https://bitbucket.org/gxti/hgforest
sundar@1027 24
sundar@1027 25 You can clone Nashorn Mercurial forest using this command:
sundar@1027 26
sundar@1027 27 hg fclone http://hg.openjdk.java.net/nashorn/jdk8 nashorn~jdk8
sundar@1027 28
sundar@1027 29 To update your copy of the forest (fwith the latest code:
sundar@1027 30
sundar@1027 31 (cd nashorn~jdk8 ; hg fpull)
sundar@1027 32
sundar@1027 33 Or just the nashorn subdirectory with
sundar@1027 34
sundar@1027 35 (cd nashorn~jdk8/nashorn ; hg pull -u)
sundar@1027 36
sundar@1027 37 To learn about Mercurial in detail, please visit http://hgbook.red-bean.com.
sundar@1027 38
sundar@1027 39 - How to build?
sundar@1027 40
sundar@1027 41 To build Nashorn, you need to install JDK 8. You may use the Nashorn
sundar@1027 42 forest build (recommended) or down load from java.net. You will need to
sundar@1027 43 set JAVA_HOME environmental variable to point to your JDK installation
sundar@1027 44 directory.
sundar@1027 45
sundar@1027 46 cd nashorn~jdk8/nashorn/make
sundar@1027 47 ant clean; ant
sundar@1027 48
sundar@1027 49 - How to run?
sundar@1027 50
sundar@1027 51 Use the jjs script (see RELESE_README):
sundar@1027 52
sundar@1027 53 cd nashorn~jdk8/nashorn
sundar@1027 54 sh bin/jjs <your .js file>
sundar@1027 55
sundar@1027 56 Nashorn supports javax.script API. It is possible to drop nashorn.jar in
sundar@1027 57 class path and request for "nashorn" script engine from
sundar@1027 58 javax.script.ScriptEngineManager.
sundar@1027 59
sundar@1027 60 Look for samples under the directory test/src/jdk/nashorn/api/scripting/.
sundar@1027 61
sundar@1027 62 - Documentation
sundar@1027 63
sundar@1027 64 Comprehensive development documentation is found in the Nashorn JavaDoc. You can
sundar@1027 65 build it using:
sundar@1027 66
sundar@1027 67 cd nashorn~jdk8/nashorn/make
sundar@1027 68 ant javadoc
sundar@1027 69
sundar@1027 70 after which you can view the generated documentation at dist/javadoc/index.html.
sundar@1027 71
sundar@1027 72 - Running tests
sundar@1027 73
sundar@1027 74 Nashorn tests are TestNG based. Running tests requires downloading the
mhaupt@1301 75 TestNG library and placing its jar file into the test/lib subdirectory. This is
mhaupt@1301 76 done automatically when executing the "ant externals" command to get external
mhaupt@1301 77 test suites (see below).
sundar@1027 78
mhaupt@1301 79 Once TestNG is properly installed, you can run the tests using:
sundar@1027 80 cd make
sundar@1027 81 ant clean test
sundar@1027 82
sundar@1027 83 You can also run the ECMA-262 test suite with Nashorn. In order to do
sundar@1027 84 that, you will need to get a copy of it and put it in
sundar@1027 85 test/script/external/test262 directory. A convenient way to do it is:
sundar@1027 86
sundar@1027 87 git clone https://github.com/tc39/test262 test/script/external/test262
sundar@1027 88
sundar@1027 89 Alternatively, you can check it out elsewhere and make
sundar@1027 90 test/script/external/test262 a symbolic link to that directory. After
sundar@1027 91 you've done this, you can run the ECMA-262 tests using:
sundar@1027 92
sundar@1027 93 cd nashorn~jdk8/nashorn/make
sundar@1027 94 ant test262
sundar@1027 95
sundar@1027 96 Ant target to get/update external test suites:
sundar@1027 97
sundar@1027 98 ant externals
sundar@1027 99 ant update-externals
sundar@1027 100
sundar@1027 101 These tests take time, so we have a parallelized runner for them that
sundar@1027 102 takes advantage of all processor cores on the computer:
sundar@1027 103
sundar@1027 104 cd nashorn~jdk8/nashorn/make
sundar@1027 105 ant test262parallel
sundar@1027 106
sundar@1027 107 - How to write your own test?
sundar@1027 108
sundar@1027 109 Nashorn uses it's own simple test framework. Any .js file dropped under
sundar@1027 110 nashorn/test directory is considered as a test. A test file can
sundar@1027 111 optionally have .js.EXPECTED (foo.js.EXPECTED for foo.js) associated
sundar@1027 112 with it. The .EXPECTED file, if exists, should contain the output
sundar@1027 113 expected from compiling and/or running the test file.
sundar@1027 114
sundar@1027 115 The test runner crawls these directories for .js files and looks for
sundar@1027 116 JTReg-style @foo comments to identify tests.
sundar@1027 117
sundar@1027 118 * @test - A test is tagged with @test.
sundar@1027 119
sundar@1027 120 * @test/fail - Tests that are supposed to fail (compiling, see @run/fail
sundar@1027 121 for runtime) are tagged with @test/fail.
sundar@1027 122
sundar@1027 123 * @test/compile-error - Test expects compilation to fail, compares
sundar@1027 124 output.
sundar@1027 125
sundar@1027 126 * @test/warning - Test expects compiler warnings, compares output.
sundar@1027 127
sundar@1027 128 * @test/nocompare - Test expects to compile [and/or run?]
sundar@1027 129 successfully(may be warnings), does not compare output.
sundar@1027 130
sundar@1027 131 * @subtest - denotes necessary file for a main test file; itself is not
sundar@1027 132 a test.
sundar@1027 133
sundar@1027 134 * @run - A test that should be run is also tagged with @run (otherwise
sundar@1027 135 the test runner only compiles the test).
sundar@1027 136
sundar@1027 137 * @run/fail - A test that should compile but fail with a runtime error.
sundar@1027 138
sundar@1027 139 * @run/ignore-std-error - script may produce output on stderr, ignore
sundar@1027 140 this output.
sundar@1027 141
sundar@1027 142 * @argument - pass an argument to script.
sundar@1027 143
sundar@1027 144 * @option \ - pass option to engine, sample.
sundar@1027 145
sundar@1027 146 /**
sundar@1027 147 * @option --dump-ir-graph
sundar@1027 148 * @test
sundar@1027 149 */