Skip to content

Commit f698c80

Browse files
committed
Follow comments
1 parent 303bae5 commit f698c80

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

web-image/export-java-function/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This demo illustrates the use of **Web Image** - an experimental backend for [Gr
44
Then it can be run in browsers or with Node.js.
55

66
The key idea is to show how you can currently **call Java methods directly from JavaScript** without relying on the `main()` method.
7-
This demo exposes a simple Java `add(int a, int b)` method to the global JavaScript scope using the `@JS` annotation from the [Annotation Interface](https://www.graalvm.org/sdk/javadoc/org/graalvm/webimage/api/JS.html).
7+
This demo exposes a simple Java method to the global JavaScript scope using the `@JS` annotation from the [Annotation Interface](https://www.graalvm.org/sdk/javadoc/org/graalvm/webimage/api/JS.html).
88

99
> Note: Web Image is an experimental technology and under active development. APIs, tooling, and capabilities may change.
1010
@@ -70,7 +70,7 @@ public class Adder {
7070
```
7171

7272
- `@JS` annotation is part of [GraalVM Web Image API](https://www.graalvm.org/sdk/javadoc/org/graalvm/webimage/api/JS.html). It allows you to bridge Java and JavaScript.
73-
- `args = {"adder"}` tells GraalVM that the BiFunction you pass in Java will be available as a JavaScript variable `adder`.
73+
- `args = {"adder"}` tells GraalVM that the BiFunction you pass in Java will be available as a JavaScript variable `adder` (not necessary if the Java source code is compiled with the `-parameters` option).
7474
- `value = "globalThis.adder = adder;"` is a raw JavaScript code executed when the export happens; it sets a variable called `adder` to be globally accessible in browsers.
7575

7676
Further down you see the `export` method:
@@ -87,7 +87,7 @@ This makes the lambda directly callable from JS as `globalThis.adder(...)`.
8787
The next part is calling from JavaScript in HTML, which happens in this part of _index.html_:
8888
```js
8989
<script>
90-
GraalVM.run([], {}).then(() => {
90+
GraalVM.run([]).then(() => {
9191
...
9292
addButton.addEventListener("click", () => {
9393
const a = parseInt(document.getElementById("num1").value);
@@ -109,4 +109,4 @@ GraalVM.run([], {}).then(() => {
109109
### Conclusion
110110

111111
The focus of this demo is to demonstrate direct interaction between Java and JavaScript in the browser via WebAssembly.
112-
Note that the [GraalVM Web Image API](https://www.graalvm.org/sdk/javadoc/org/graalvm/webimage/api/JS.html) is still under active development, there will be better ways to export Java methods to JavaScript.
112+
Note that the [GraalVM Web Image API](https://www.graalvm.org/sdk/javadoc/org/graalvm/webimage/api/JS.html) is still under active development, there will be better ways to export Java methods to JavaScript.

0 commit comments

Comments
 (0)