JAPICOMPAT(1)
π JAPICOMPAT(1) π
okay so bestie, buckle up β this is japicompat, a page from the General Commands Manual, and it's here to do one very specific iconic thing: test Java APIs for binary backwards compatibility. π
β¨ NAME β¨
japicompat β Test Java APIs for binary backwards compatibility.
πΈ SYNOPSIS πΈ
japicompat [-svqhtjw4] [-o outfile] [-i ignorefiles] <original_api> <api_to_check>
π¦ DESCRIPTION π¦
So japicompat is part of japitools, and its whole personality is testing for compatibility between Java APIs. π
They (the tools, the whole squad) were originally designed for testing free implementations of Java itself for compatibility with Sun's JDK, but lowkey they can also be used for testing backward compatibility between versions of any API. No cap.
The tools are japize and japicompat. Here's the tea:
japizeis a Java program which emits a listing of an API in a machine-readable format.japicompatthen takes two such listings and compares them for binary compatibility, as defined by Sun in the Java Language Specification.
It's giving compiler energy but make it a compatibility check. π₯
π OPTIONS π
-sβ disable additional binary compatibility checks (only do checks defined by the JLS).-vβ enable checks for minor compatibility problems.- SerialVersionUID checking:
japicompatreports a minor error if a Serializable class has a differentSerialVersionUIDbetween the two releases. - Deprecation checking:
japicompatreports a minor error if a class or member was deprecated in the original API but is not deprecated in the API being checked.
- SerialVersionUID checking:
-qβ disables progress reports. (shhh, no updates, just vibes π€«)-hβ generates output in HTML format. The HTML files produced depend on thejapi.cssfile to get attractive presentation. β¨-tβ generates output in text format. This is the default.-jβ generates output in raw machine readable form. The format produced is called"japio"format, and by convention should be saved with a".japio"file extension. The standalonejapiotextandjapiohtmlutilities can be used to convert this format into html or text (actually,japicompatcallsjapiotextorjapiohtmlinternally if the-hor-tflags are used). Japio files can also be used with the-iflag to support ignoring errors caused by incompatibilities between JDK versions. π-wβ disable warnings for running against old buggy japi files. By defaultjapicompatwill produce warnings if run against japi files originally generated by older versions ofjapitoolsthat had known bugs thatjapifixcannot eliminate.-4β use 1.4-compatible mode. This works as long as the APIs to compare does not contain 1.5-only items.-o<outfile>β Send the output to<outfile>instead of stdout. The format of this file depends on the-h,-tand-jflags.-i<ignorefiles>β okay bestie this one is a whole saga, so let's sit down π«Ά
Suppose you are attempting to implement the Java API. You have (pretty much) completed coverage of the early JDK versions (1.0 and 1.1) but still have some distance to achieve full coverage of 1.4 (this is an accurate description of all Free Software Java implementations at the time of writing). Using japicompat to compare your implementation with JDK 1.4 gives accurate results, but you might also want to show your coverage of the earlier versions.
Unfortunately Sun has not followed their own binary compatibility rules between JDK releases, let alone the expanded rules that japicompat tests for. So when you run a comparison between JDK 1.1 and your implementation, you will get spurious error reports when you're compatible with 1.4 but not 1.1. π
Obviously what you really want is to ignore errors like this, and japicompat provides a way to do so. First, run a comparison between 1.1 and 1.4 using the -j switch. Then run the comparison between 1.1 and your implementation, passing the "-i" option with the output of the previous run. For example:
$ japicompat -jo ignore-11-14.japio jdk11.japi.gz jdk14.japi.gz
$ japicompat -ho jdk11-myimpl.html -i ignore-11-14.japio jdk11.japi.gz myimpl.japi.gz
You can also get the same effect by running:
$ japicompat -ho jdk11-myimpl.html -i jdk14.japi.gz jdk11.japi.gz myimpl.japi.gz
This is obviously simpler and quicker to type, but requires the comparison between jdk11 and jdk14 to be run every single time. Making the japio file manually allows for it to be saved and used again the next time, which lets japicompat run about twice as fast. β‘
<original_api><api_to_check>β The japi files corresponding to the APIs to be compared.
japicompat specifically tests that the second argument is backwardly-compatible with the first. Therefore, a perfect implementation of JDK 1.1 would produce no errors regardless of the order of the arguments, but a perfect implementation of JDK1.1 plus parts of JDK1.2 should be tested as follows:
$ japicompat jdk11.japi.gz myimpl.japi.gz
$ japicompat myimpl.japi.gz jdk12.japi.gz
It is probably impossible to make an implementation that passes both these tests, since Sun's own JDK1.2 produces numerous errors when tested against JDK1.1. See the discussion of the -i option above for a way to cope with this situation. π
Either compressed (.japi.gz) or uncompressed (.japi) files can be passed to japicompat: The file extension is used to determine whether or not to pipe input through gzip or not.
π SEE ALSO π
japize(1)β Produce a listing of an API in a machine-readable format.japilist(1)β List the contents of japi files.japiohtml(1)β Convertjapicompatoutput to pretty html format.japiotext(1)β Convertjapicompatoutput to readable plain text format.
and that's the whole page, bestie, we ate and left no crumbs π this one's dated October 6, 2005 and it lives in the General Commands Manual (the JAPICOMPAT(1) corner of it, specifically) β fr fr, iconic since '05 ππ
π¦ where this page comes from
- debian bookworm: japitools 0.9.7+git20150619-1 Β· GPL-2.0-or-later
- debian trixie: japitools 0.9.7+git20150619-1 Β· GPL-2.0-or-later
- ubuntu jammy: japitools 0.9.7+git20150619-1 Β· GPL-2.0-or-later
- ubuntu noble: japitools 0.9.7+git20150619-1 Β· GPL-2.0-or-later
- ubuntu resolute: japitools 0.9.7+git20150619-1build1 Β· GPL-2.0-or-later
- ubuntu stonking: japitools 0.9.7+git20150619-1build1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms