Title: Try a WebAssembly build for an in-browser playground on the website · Issue #21 · openjavaformat/open-java-format · GitHub
Open Graph Title: Try a WebAssembly build for an in-browser playground on the website · Issue #21 · openjavaformat/open-java-format
X Title: Try a WebAssembly build for an in-browser playground on the website · Issue #21 · openjavaformat/open-java-format
Description: Idea Suggested by Denis Pavlyuchenko, @pavlyuchenko_denis on Telegram, in a comment: the project already builds a GraalVM native image, so the same build could target WebAssembly, and https://openjavaformat.dev could get a playground tha...
Open Graph Description: Idea Suggested by Denis Pavlyuchenko, @pavlyuchenko_denis on Telegram, in a comment: the project already builds a GraalVM native image, so the same build could target WebAssembly, and https://openj...
X Description: Idea Suggested by Denis Pavlyuchenko, @pavlyuchenko_denis on Telegram, in a comment: the project already builds a GraalVM native image, so the same build could target WebAssembly, and https://openj...
Opengraph URL: https://github.com/openjavaformat/open-java-format/issues/21
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Try a WebAssembly build for an in-browser playground on the website","articleBody":"### Idea\n\nSuggested by Denis Pavlyuchenko, [@pavlyuchenko_denis](https://t.me/pavlyuchenko_denis) on Telegram, in a comment: the project already builds a GraalVM native image, so the same build could target WebAssembly, and https://openjavaformat.dev could get a playground that formats code in the browser. Nothing would be sent anywhere, which is the point, and the site stays on GitHub Pages with no server.\n\n### Why it looks realistic\n\nGraalVM's Web Image backend, `native-image --tool:svm-wasm`, compiles a JVM application into a Wasm module plus a JavaScript wrapper. The GraalVM team's own demo compiles all of `javac` that way and runs it in the browser:\n\n- live: https://graalvm.github.io/graalvm-demos/web-image/javac/\n- sources: https://github.com/graalvm/graalvm-demos/tree/master/web-image/javac\n\nTried in Chrome 152: compiling the sample class took about 69 ms. The formatter needs only javac's parser, which is less than that demo uses.\n\n### What is different from today's native build\n\n- **GraalVM distribution.** Web Image is experimental and ships in Oracle GraalVM 25.1 or later only. CI builds the native images with `distribution: 'graalvm-community'`, and GraalVM CE 25.0.2 has no `svm-wasm` tool. The Wasm artifact would need its own job with `distribution: 'graalvm'`, which `graalvm/setup-graalvm` already supports, plus Binaryen 119 or later on the `PATH`.\n- **Entry point.** `com.palantir.javaformat.java.Main` works on files. The browser needs a small class that uses `org.graalvm.webimage.api` (`@JS`, `JSObject`, `JSString`) to read the text from the page, call the formatter with the OJF style and write the result back. The demo's `WebMain` is a template for it.\n- **Stability.** The backend's APIs and tooling may change between releases, so the GraalVM version has to be pinned.\n\n### To decide\n\n- Oracle GraalVM is free under the GFTC and the Web Image sources are GPLv2 in `oracle/graal`, but it is not the community build. Is that acceptable for this one artifact, given manifesto principle 3 about artifacts built in public?\n- Where the Wasm module is published: as a release asset that the site's build downloads, or built in the site's repository.\n\n### Size, for scale\n\n| | Size |\n| --- | --- |\n| Wasm module of the javac demo | 27.4 MB |\n| The same over the wire with gzip | 9.8 MB |\n| Our native binary | about 60 MB |\n\nThe module would load on the playground page only. Browsers need WebAssembly GC and exception handling, which current Chrome, Firefox and Safari have.\n\n### Not verified yet\n\nWhether the formatter and its dependencies build under `svm-wasm` unchanged, and whether the existing reachability metadata carries over. Only a trial build can tell.\n\n### Suggested first step\n\nA time-boxed spike of about a day: build `open-java-format` with `--tool:svm-wasm` on Oracle GraalVM, call the formatter from a static test page, and record what had to change, the module size and the time one format takes. Decide after that whether it becomes a CI job and a page on the site.\n\n### Alternatives looked at\n\n- CheerpJ runs an unmodified jar in a browser JVM, but it supports Java 8, 11 and 17 while the formatter needs 21, and its runtime is proprietary and served from the vendor's CDN.\n- A server-side formatter contradicts both the no-server setup of the site and the reason for a playground.\n\n","author":{"url":"https://github.com/abashev","@type":"Person","name":"abashev"},"datePublished":"2026-09-21T08:14:37Z","url":"https://github.com/openjavaformat/open-java-format/issues/21"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5a4bb099-bade-483d-55e4-914326f1b3a4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B26:36935:13F451:1B8E53:6AFBBB5C |
| html-safe-nonce | a16c1e176c512217ec7b91419e5fc30b16de634a8810a0021e1090784635c9d4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjI2OjM2OTM1OjEzRjQ1MToxQjhFNTM6NkFGQkJCNUMiLCJ2aXNpdG9yX2lkIjoiNzA5OTMyMjM4OTM0NjYzMDQ5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a392b52d8ef0c0b169c112655bced66913b836c08fe6e7dfa4affdeed7833ff3 |
| hovercard-subject-tag | issue:5524440785 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/openjavaformat/open-java-format/21/issue_layout |
| twitter:image | https://opengraph.githubassets.com/90b19aed675e22c88500d3e9be9bce296f77ae32f1ab67bdc87ae1497c8b41c1/openjavaformat/open-java-format/issues/21 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/90b19aed675e22c88500d3e9be9bce296f77ae32f1ab67bdc87ae1497c8b41c1/openjavaformat/open-java-format/issues/21 |
| og:image:alt | Idea Suggested by Denis Pavlyuchenko, @pavlyuchenko_denis on Telegram, in a comment: the project already builds a GraalVM native image, so the same build could target WebAssembly, and https://openj... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abashev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2b2ef9c1578c18d8ed27027940544c958743213cf4461659f14d3ccdf51e162c |
| turbo-cache-control | no-preview |
| go-import | github.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git |
| octolytics-dimension-user_id | 325177626 |
| octolytics-dimension-user_login | openjavaformat |
| octolytics-dimension-repository_id | 1288055459 |
| octolytics-dimension-repository_nwo | openjavaformat/open-java-format |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 214273098 |
| octolytics-dimension-repository_parent_nwo | palantir/palantir-java-format |
| octolytics-dimension-repository_network_root_id | 214273098 |
| octolytics-dimension-repository_network_root_nwo | palantir/palantir-java-format |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e4cce0e99cf61481a318ff12c2e8580153a6c7c6 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width