Skip to content

Commit 9abfaad

Browse files
committed
Minor documentation cleanup.
1 parent 14854c4 commit 9abfaad

File tree

6 files changed

+38
-35
lines changed

6 files changed

+38
-35
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ The goals of GraalVM JavaScript are:
1414

1515

1616
## Getting Started
17-
The preferred way to run GraalVM JavaScript is from a [GraalVM](https://www.graalvm.org/downloads/).
18-
Starting with GraalVM for JDK 21 (23.1), GraalVM JavaScript is available as a [standalone distribution](https://github.com/oracle/graaljs/releases) and a [Maven artifact](https://central.sonatype.com/artifact/org.graalvm.polyglot/js) (but no longer as a GraalVM component).
17+
The preferred way to run GraalVM JavaScript (a.k.a. GraalJS) is from a [GraalVM](https://www.graalvm.org/downloads/).
18+
As of GraalVM for JDK 21, (23.1), GraalVM JavaScript and Node.js runtimes are available as [standalone distributions](https://github.com/oracle/graaljs/releases) and [Maven artifacts](https://central.sonatype.com/artifact/org.graalvm.polyglot/js) (but no longer as GraalVM components).
1919
See the documentation on the [GraalVM website](https://www.graalvm.org/latest/reference-manual/js/) for more information on how to set up GraalVM JavaScript.
2020

2121
### Standalone Distribution
@@ -73,7 +73,7 @@ Due to those limitations, running on a stock JVM is not a supported feature - pl
7373
## Documentation
7474

7575
Extensive documentation is available on [graalvm.org](https://www.graalvm.org/): see [Getting Started](https://www.graalvm.org/docs/getting-started/) and the more extensive [JavaScript and Node.js Reference Manual](https://www.graalvm.org/reference-manual/js/).
76-
In addition there is documentation in the source code repository in the [`docs`](https://github.com/graalvm/graaljs/tree/master/docs) folder, for [users](https://github.com/graalvm/graaljs/tree/master/docs/user) and [contributors](https://github.com/graalvm/graaljs/tree/master/docs/contributor).
76+
In addition, there is documentation in the source code repository in the [`docs`](https://github.com/graalvm/graaljs/tree/master/docs) directory, for [users](https://github.com/graalvm/graaljs/tree/master/docs/user) and [contributors](https://github.com/graalvm/graaljs/tree/master/docs/contributor).
7777

7878
For contributors, a guide how to build GraalVM JavaScript from source code can be found in [`Building.md`](https://github.com/graalvm/graaljs/tree/master/docs/Building.md).
7979

docs/user/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Additionally, you can upload your `package-lock.json` or `package.json` file int
8585
### My application is slower on GraalVM JavaScript than on another engine
8686
Reason:
8787
* Ensure your benchmark considers warmup. During the first few iterations, GraalVM JavaScript may be slower than other engines, but after sufficient warmup, this difference should level out.
88-
* GraalVM JavaScript is shipped in two different standalones: Native (default) and JVM (with a `-jvm` infix). While the default _native_ mode offers faster startup and lower latency, it might exhibit slower peak performance (lower throughput) once the application is warmed up. In the _JVM_ mode, the application might need hundreds of milliseconds more to start, but typically shows better peak performance.
88+
* GraalVM JavaScript is shipped in two different standalones: Native (default) and JVM (with a `-jvm` infix). While the default _Native_ mode offers faster startup and lower latency, it might exhibit slower peak performance (lower throughput) once the application is warmed up. In the _JVM_ mode, the application might need hundreds of milliseconds more to start, but typically shows better peak performance.
8989
* Repeated execution of code via newly created `org.graalvm.polyglot.Context` is slow, despite the same code being executed every time.
9090

9191
Solution:

docs/user/JavaScriptCompatibility.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,23 @@ The Graal object is available in GraalVM JavaScript by default, unless deactivat
223223
### `Graal.setUnhandledPromiseRejectionHandler(handler)`
224224

225225
- provides the unhandled promise rejection handler when using option (`js.unhandled-rejections=handler`).
226-
- the handler is called with two arguments: (rejection, promise).
227-
- `Graal.setUnhandledPromiseRejectionHandler` can be called with null, undefined, or empty args to clear the handler.
226+
- the handler is called with two arguments: (rejectionReason, unhandledPromise).
227+
- `Graal.setUnhandledPromiseRejectionHandler` can be called with `null`, `undefined`, or empty arguments to clear the handler.
228228

229229
### Java
230230

231231
The `Java` object is only available when [host class lookup](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/Context.Builder.html#allowHostClassLookup-java.util.function.Predicate-) is allowed.
232-
In order to access Java host classes and its members, they first need to be allowed by the [host access policy](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/HostAccess.html) and when running on a Native Image, be registered for [run time reflection](https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Reflection/).
232+
In order to access Java host classes and its members, they first need to be allowed by the [host access policy](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/HostAccess.html), and when running from a Native Image, be registered for [run time reflection](https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Reflection/).
233233

234234
Note that some functions require the Nashorn compatibility mode flag to be set.
235-
When running on the standalone distribution, this flag can be set with:
235+
When running from the JVM standalone distribution, this flag can be set with:
236236
```shell
237237
js --experimental-options --js.nashorn-compat=true
238238
```
239239

240240
#### `Java.type(className)`
241241

242-
Loads the specified Java class and returns a constructible object that has the static members (i.e. methods and fields) of the class and can be used with the `new` keyword to construct new instances:
242+
`Java.type` loads the specified Java class and returns a constructible object that has the static members (i.e. methods and fields) of the class and can be used with the `new` keyword to construct new instances:
243243
```js
244244
var BigDecimal = Java.type('java.math.BigDecimal');
245245
var point1 = new BigDecimal("0.1");
@@ -253,36 +253,39 @@ console.log(new (Java.type('java.math.BigDecimal'))("1.1").pow(15));
253253

254254
#### `Java.from(javaData)`
255255

256-
- creates a shallow copy of the Java datastructure (Array, List) as a JavaScript array
256+
`Java.from` creates a shallow copy of the Java data structure (Array, List) as a JavaScript array.
257257

258-
In many cases, this is not necessary; you can typically use the Java datastructure directly from JavaScript.
258+
In many cases, this is not necessary; you can typically use the Java data structure directly from JavaScript.
259259

260-
#### `Java.to(jsData, toType)`
260+
#### `Java.to(jsData, javaType)`
261261

262-
- converts the argument to a Java dataype
262+
`Java.to` converts the argument to the Java type.
263263

264-
The source object `jsData` is expected to be a JavaScript array, or an object with a `length` property.
265-
The target `toType` can either be a String (e.g. `"int[]"`) or a type object (e.g., `Java.type("int[]")`).
264+
The source object `jsData` is expected to be a JavaScript array, or an array-like object with a `length` property.
265+
The target `javaType` can either be a String (e.g. `"int[]"`) or a type object (e.g., `Java.type("int[]")`).
266266
Valid target types are Java arrays.
267-
When no target type is provided, `Object[]` is assumed:
267+
When the target type is omitted, it defaults to `Object[]`.
268+
268269
```js
269-
var jsArr = ["a", "b", "c"];
270-
var strArrType = Java.type("java.lang.String[]");
271-
var javaArr = Java.to(jsArr, strArrType);
272-
assertEquals('class java.lang.String[]', String(javaArr.getClass()));
270+
var jsArray = ["a", "b", "c"];
271+
var stringArrayType = Java.type("java.lang.String[]");
272+
var javaArray = Java.to(jsArray, stringArrayType);
273+
assertEquals('class java.lang.String[]', String(javaArray.getClass()));
274+
var javaArray = Java.to(jsArray);
275+
assertEquals('class java.lang.Object[]', String(javaArray.getClass()));
273276
```
274277

275278
The conversion methods as defined by ECMAScript (e.g., `ToString` and `ToDouble`) are executed when a JavaScript value has to be converted to a Java type.
276-
Lossy conversion is disallowed and results in a TypeError.
279+
Lossy conversion is disallowed and results in a `TypeError`.
277280

278281
#### `Java.isJavaObject(obj)`
279282

280-
- returns whether `obj` is an object of the Java language
283+
- returns `true` if `obj` is a Java host object
281284
- returns `false` for native JavaScript objects, as well as for objects of other polyglot languages
282285

283286
#### `Java.isType(obj)`
284287

285-
- returns `true` if `obj` is an object representing the constructor and static members of a Java class, as obtained (for example) by `Java.type()`
288+
- returns `true` if `obj` is an object representing the constructor and static members of a Java class, as obtained by `Java.type()` or package objects.
286289
- returns `false` for all other arguments
287290

288291
#### `Java.typeName(obj)`
@@ -295,25 +298,25 @@ Lossy conversion is disallowed and results in a TypeError.
295298
- returns whether `fn` is an object of the Java language that represents a Java function
296299
- returns `false` for all other types, including native JavaScript function, and functions of other polyglot languages
297300

298-
This function requires the Nashorn compatibility mode flag.
301+
> This function is only available in Nashorn compatibility mode (`--js.nashorn-compat=true`).
299302
300303
#### `Java.isScriptObject(obj)`
301304

302305
- returns whether `obj` is an object of the JavaScript language
303306
- returns `false` for all other types, including objects of Java and other polyglot languages
304307

305-
This function requires the Nashorn compatibility mode flag.
308+
> This function is only available in Nashorn compatibility mode (`--js.nashorn-compat=true`).
306309
307310
#### `Java.isScriptFunction(fn)`
308311

309312
- returns whether `fn` is a JavaScript function
310313
- returns `false` for all other types, including Java function, and functions of other polyglot languages
311314

312-
This function requires the Nashorn compatibility mode flag.
315+
> This function is only available in Nashorn compatibility mode (`--js.nashorn-compat=true`).
313316
314317
#### `Java.addToClasspath(location)`
315318

316-
- adds the specified location (file name or path name, as String) to Java's classpath
319+
- adds the specified location (a `.jar` file or directory path string) to Java's classpath
317320

318321
### Polyglot
319322

docs/user/Options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ For a complete list, use `js --help:js:internal`
8181
This option provides compatibility to a specific version of the ECMAScript specification.
8282
It expects an integer value, where both the edition numbers (`5`, `6`, ...) and the publication years (starting from `2015`) are supported.
8383
As of GraalVM 21.2, `latest`, `staging` are supported, too.
84-
The default in GraalVM 23.1 is the [`ECMAScript 2023 specification`](https://tc39.es/ecma262/).
84+
The default in GraalVM 23.1 is the [`ECMAScript 2023 specification`](https://262.ecma-international.org/14.0/).
8585
GraalVM JavaScript implements some features of the future draft specification and of open proposals, if you explicitly select that version and/or enable specific experimental flags.
8686
For production settings, it is recommended to set the `ecmascript-version` to a released, finalized version of the specification (e.g., `2022`).
8787

docs/user/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ To migrate the code previously targeted to the Nashorn or Rhino engines, [migrat
1313

1414
## Getting Started
1515

16-
As of GraalVM for JDK 21, the JavaScript (GraalJS) and Node.js runtimes are available as standalone distributions.
16+
As of GraalVM for JDK 21, the JavaScript (GraalJS) and Node.js runtimes are available as standalone distributions.
1717
Two standalone language runtime options are available for both Oracle GraalVM and GraalVM Community Edition: a Native Image compiled native launcher or a JVM-based runtime (included).
18-
To distinguish between them, the GraalVM Community Edition version has the suffix `-community` in the name: `graaljs-community-<version>-<os>-<arch>.tar.gz`, `graalnodejs-community-<version>-<os>-<arch>.tar.gz`,
18+
To distinguish between them, the GraalVM Community Edition version has the suffix `-community` in the name: `graaljs-community-<version>-<os>-<arch>.tar.gz`, `graalnodejs-community-<version>-<os>-<arch>.tar.gz`.
1919
A standalone that comes with a JVM has a `-jvm` suffix in a name.
2020

21-
1. Navigate to [GitHub releases](https://github.com/oracle/graaljs/releases/) and select a desired standalone for your operating system.
21+
1. Navigate to [GitHub releases](https://github.com/oracle/graaljs/releases/) and select a desired standalone for your operating system.
2222

2323
2. Unzip the archive:
2424

docs/user/RunOnJDK.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ This document describes how to run GraalVM JavaScript on stock Java VMs, and sho
1616

1717
## GraalVM JavaScript on Maven Central
1818
GraalVM JavaScript is open source and regularly pushed to Maven Central Repository by the community.
19-
You can find it as pom artifact [org.graalvm.polyglot:js](https://mvnrepository.com/artifact/org.graalvm.polyglot/js).
19+
You can find it as a POM artifact, under [`org.graalvm.polyglot:js`](https://mvnrepository.com/artifact/org.graalvm.polyglot/js).
2020

21-
There are example Maven projects for GraalVM JavaScript on JDK21 (or later) using the Graal compiler:
21+
There are example Maven projects for GraalVM JavaScript on JDK 21 (or later) using the Graal compiler:
2222
* [Polyglot Embedding Demo](https://github.com/graalvm/polyglot-embedding-demo).
2323
Example Maven and Gradle projects for a simple JavaScript "Hello World" application.
24-
* [JS Maven Demo](https://github.com/oracle/graaljs/tree/master/graal-js/test/maven-demo)
24+
* [JS Maven Demo](https://github.com/oracle/graaljs/tree/master/graal-js/test/maven-demo).
2525
This example contains a Maven project for a JavaScript benchmark (a prime number generator).
2626
It allows a user to compare the performance of GraalVM JavaScript running with or without the GraalVM compiler as the optimizing compiler.
2727
Running with the GraalVM compiler will significantly improve the execution performance of any relatively large JavaScript codebase.
2828

29-
In essence, the example `pom.xml` file activates JVMCI to install additional JIT compilers, and configures the JIT compiler to be the Graal Compiler by providing it on `--module-path` and `--upgrade-module-path`.
29+
In essence, the example `pom.xml` file activates the JVM Compiler Interface (JVMCI) and configures the JIT compiler to be the Graal compiler by providing it on `--module-path` and `--upgrade-module-path`.
3030

3131
### ScriptEngine JSR 223
3232
GraalVM JavaScript can be started via `ScriptEngine` when _js-scriptengine.jar_ is included on the module path.

0 commit comments

Comments
 (0)