Welcome to COJAC, a tool that leverages in new ways the arithmetic
Welcome to COJAC, a tool that leverages in new ways the arithmetic
capabilities of the Java programming language.
capabilities of the Java programming language. The idea is summarized in
small demos on [YouTube](https://youtu.be/DqAFQfbWZOU?list=PLHLKWUtT0B7kNos1e48vKhFlGAXR1AAkF).
If you need a definition for the acronym "COJAC", feel free to choose one of
If you need a definition for the acronym "COJAC", feel free to choose one of
following:
following:
...
@@ -50,7 +51,7 @@ following:
...
@@ -50,7 +51,7 @@ following:
COJAC is in fact a two-fold tool:
COJAC is in fact a two-fold tool:
- a **_"numerical sniffer"_** that detects anomalies arising in arithmetic operations,
- a **_"numerical sniffer"_** that detects anomalies arising in arithmetic operations,
on either integers (eg overflow) or floating point numbers (eg
on both integers (eg overflow) and floating point numbers (eg
cancellation or NaN outcome). This can be of great help to detect vicious bugs
cancellation or NaN outcome). This can be of great help to detect vicious bugs
involving annoying events that normally happen silently in the Java Virtual
involving annoying events that normally happen silently in the Java Virtual
Machine. See [§2](home#2-cojac-the-numerical-sniffer). This tool is pretty
Machine. See [§2](home#2-cojac-the-numerical-sniffer). This tool is pretty
...
@@ -100,7 +101,7 @@ COJAC is offered (without warranty of any kind) in the hope it can be useful
...
@@ -100,7 +101,7 @@ COJAC is offered (without warranty of any kind) in the hope it can be useful
for educational purposes, as well as in the software industry.
for educational purposes, as well as in the software industry.
You might be interested in the
You might be interested in the
[valgrind-based cousin](https://github.com/frederic-bapst/cojac-grind), a
[valgrind-based cousin](https://github.com/Cojac/cojac-grind), a
similar tool not limited to the Java world (it acts on any Linux binary).
similar tool not limited to the Java world (it acts on any Linux binary).
The concept of _numerical problem sniffer_ is presented in our
The concept of _numerical problem sniffer_ is presented in our
...
@@ -127,7 +128,8 @@ the problems.
...
@@ -127,7 +128,8 @@ the problems.
The COJAC sniffer tracks the following kinds of event:
The COJAC sniffer tracks the following kinds of event:
**Integer overflow*: the result is out-of-bounds for a `long` or `int` operation (an arithmetic operation, not the bit-shift operations). Examples: `3*Integer.MAX_VALUE, Integer.MIN_VALUE/-1`
**Integer overflow*: the result is out-of-bounds for a `long` or `int` operation (an arithmetic operation, not the bit-shift operations). Examples: `3*Integer.MAX_VALUE, Integer.MIN_VALUE/-1`
**Offending typecasting*: a value loses its essence after a type conversion. Examples: `(short) Long.MAX_VALUE, (int) Float.NaN`
**Offending typecasting*: a value loses its essence after a type conversion. Examples: `(short) Long.MAX_VALUE, (int) Float.NaN`. We also detect loss
of precision when converting int-to-float or long-to-double (not included in release v1.4). Example: `(float)Integer.MAX_VALUE`
**Smearing*: adding/subtracting a non-zero floating point number (float or double) has no effect because the two operands have excessively different orders of magnitude. Examples: `(342.0 + 1.0E-43), (342.0 - 1.0E+43)`
**Smearing*: adding/subtracting a non-zero floating point number (float or double) has no effect because the two operands have excessively different orders of magnitude. Examples: `(342.0 + 1.0E-43), (342.0 - 1.0E+43)`
**Cancellation*: two floating point numbers almost cancel each other after an addition or subtraction, so that the least significant bits (often noise) are promoted to highest significance. Example: `(3.000001f - 3.0f)`
**Cancellation*: two floating point numbers almost cancel each other after an addition or subtraction, so that the least significant bits (often noise) are promoted to highest significance. Example: `(3.000001f - 3.0f)`
**Questionable comparisons*: two floating point numbers are being compared, but they are very close together. Example: `if (3.000001f >= 3.0f)...`
**Questionable comparisons*: two floating point numbers are being compared, but they are very close together. Example: `if (3.000001f >= 3.0f)...`
...
@@ -550,7 +552,7 @@ Two nice tools to enrich Java arithmetic capabilities, on-the-fly:
...
@@ -550,7 +552,7 @@ Two nice tools to enrich Java arithmetic capabilities, on-the-fly: