A Firefox Addon which redirects you to the latest javadocs
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Dialog.html https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html
Requires Node.js 22+. Run npm install once.
| Command | What it does |
|---|---|
npm test |
Offline unit tests: rewrite rules, background script, settings page. |
npm run test:corpus |
Online check of the rules against every class and package page of Java 1.5–26 and JavaFX 2/8 (~110k pages), for every target version. See below. |
npm run update-modules |
Creates missing json/modules-v*.json files and refreshes json/modules-javafx.json. -- --check compares all of them with the published data. |
npm run lint |
Mozilla's web-ext lint. |
npm start |
Starts Firefox with the add-on loaded. |
npm run build |
Packages the add-on into web-ext-artifacts/ (dev files are excluded, see web-ext-config.mjs). |
The rewrite rules live in redirect-rules.js, which has no WebExtension dependencies so it can be tested with Node.
java-redirect.js is the background script glue around it.
Texts shown to users (the add-on's name and description, and the settings page) are translated in _locales/<language>/messages.json; en_GB is the default, matching the default language of the AMO listing. npm test checks that every language defines the same messages. AMO takes the name and summary of each language from these files when a new version is uploaded.
scripts/check-corpus.mjs downloads the class indexes (allclasses-noframe.html, type-search-index.js, element-list) of every published Javadoc version, cached in .cache/javadoc/. It rewrites every old page for every target version and compares the result with the pages that really exist in the target version:
ok: rewritten to the right pagegone: the class doesn't exist in the target. The add-on's HEAD check prevents a redirect.missed: the target has the page, but the URL wasn't rewritten (a warning;--strictfails on it)broken,wrong,downgrade: errors, the check fails on them
Options: --targets 21,27, --verify 20 (HEAD-requests sample URLs to validate the page lists), --refresh. The full list of findings is written to .cache/corpus-report.json.
- Bump
LATEST_VERSIONinredirect-rules.js. The settings page and default follow automatically. npm run update-modulesto generatejson/modules-v<N>.jsonand refresh the JavaFX map.npm testandnpm run test:corpus, then bumpversioninmanifest.json.
Java 11+ URLs contain the module name, so the add-on maps packages to modules. The maps in json/ are generated by npm run update-modules from the element-list file published with each Javadoc:
modules-v<N>.json: the JDK packages of Java N, from Oracle's docs.modules-javafx.json: the JavaFX packages, from the latest openjfx.io docs. JavaFX has never moved a package between modules, so one map covers every version.
A page goes to Oracle if the target JDK has its package, otherwise to openjfx.io if JavaFX has it, otherwise it is left alone. For example, netscape.javascript moved from the JDK to JavaFX in Java 24.