@@ -61,7 +62,7 @@ Feel free to choose one of those acronym meaning:
COJAC is in fact a two-fold tool:
- a "numerical sniffer" that detects anomalies arising in arithmetic operations,
involving either integers (eg overflow) or floating point numbers (eg
on either integers (eg overflow) or floating point numbers (eg
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
Machine. See [§2](home#2-cojac-the-numerical-sniffer).
...
...
@@ -107,10 +108,10 @@ You might be interested in the
[valgrind-based cousin](http://code.google.com/p/cojac-grind/cojac-grind), a
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
[article](http://drdobbs.com/testing/232601564) published by Dr Dobb's
(remember how cool this journal was?). The revolutionary (but still experimental)
wrapping feature is brand new and has not yet been discussed in any paper.
_wrapping feature_ is brand new and has not yet been discussed in any paper.
Any comment/feedback is welcome!
...
...
@@ -137,7 +138,7 @@ The COJAC sniffer tracks the following kinds of event:
**Questionable comparisons*: two floating point numbers are being compared, but they are very close together. Example: `if (3.000001f >= 3.0f)...`
**Underflow*: the result of a division is so small that it gets rounded to zero. Example: `(2.5E-233 / 7.2E+233)`
Note that all these example expressions, if they are written in Java like this,
Note that all these example expressions, when written verbatim in Java,
are evaluated at compile-time because they involve only literal values; so in
that (uninteresting) case, the problems won't be detected by COJAC (see
[known issues](home#51-issues-with-the-sniffer)).
...
...
@@ -147,13 +148,13 @@ that (uninteresting) case, the problems won't be detected by COJAC (see
COJAC offers a fine-grained configuration of what must be instrumented in the application; the options let you select which category (or even which bytecode instructions) to watch:
**`-Ca`*Activates all possible detectors (this is the default behaviour)
**`-Cints`*Watches the "int" operations: `IADD,IDIV,IINC,ISUB,IMUL,INEG`
**`-Clongs`*Watches the "long" operations: `LADD,LDIV,LSUB,LMUL,LNEG`
**`-Cdoubles`*Watches the "double" operations: `DADD,DDIV,DSUB,DMUL,DREM`
**`-Cfloats`*Watches the "float" operations: `FADD,FDIV,FSUB,FMUL,FREM`
**`-Ccasts`*Watches the typecasting operations: `L2I,I2S,I2C,I2B,D2F,D2I,D2L,F2I,F2L`
**`-Cmath`*Watches the invocations of java.lang.Math methods, like `Math.sqrt` etc.
**`-Ca`*to activates all possible detectors (this is the default behaviour)
**`-Cints`*to watch the "int" operations: `IADD`,`IDIV`,`IINC`,`ISUB`,`IMUL`,`INEG`
**`-Clongs`*to watch the "long" operations: `LADD`,`LDIV`,`LSUB`,`LMUL`,`LNEG`
**`-Cdoubles`*to watch the "double" operations: `DADD`,`DDIV`,`DSUB`,`DMUL`,`DREM`
**`-Cfloats`*to watch the "float" operations: `FADD`,`FDIV`,`FSUB`,`FMUL`,`FREM`
**`-Ccasts`*to watch the typecasting operations: `L2I`,`I2S`,`I2C`,`I2B`,`D2F`,`D2I`,`D2L`,`F2I`,`F2L`
**`-Cmath`*to watch the invocations of java.lang.Math methods, like `Math.sqrt` etc.
By default, all detectors are activated.
...
...
@@ -268,11 +269,15 @@ COJAC gives the developer access to detection management through JMX.
The management interface is the following:
```java
Map<String,Integer>getCountersMBean()// gives every opcode instrumented with statistics;
List<String>getBlacklist()// offers the developer a means to know which methods are subject to annotation;
Map<String,Long>getEvent()// gives every detected event that occurred since the beginning of the application;
// gives every opcode instrumented with statistics
Map<String,Integer>getCountersMBean()
// offers the developer a means to know which methods are subject to annotation
List<String>getBlacklist()
// gives every detected event that occurred since the beginning of the application
Map<String,Long>getEvent();
// let you dynamically enable or disable the processing of the detected events.
voidstart()
voidstop()// let you dynamically enable or disable the processing of the detected events.
voidstop()
```
The RMI service URL is parameterized by a couple of COJAC options. Here is
...
...
@@ -307,7 +312,7 @@ activate, and there you go. Everywhere there are float/Float/double/Double data
in user code (local variables, parameters, attributes...), they will be replaced
by an object redefining the arithmetic behavior. As the code inside the Java library
cannot be transformed in such a way, we designed a mechanism that automatically
deals with the necessary conversions when the user code invokes a method from the
deals with the necessary conversions when the user code invokes a method of the
Java library (with the sad consequence that the "enrichment" is then lost).
The "arithmetic behavior" that is embedded in our richer number types includes:
...
...
@@ -322,8 +327,8 @@ The "arithmetic behavior" that is embedded in our richer number types includes:
COJAC features a mechanism of *Magic Methods* that can be used to interact with
the new enriched numbers. A magic method has an identifier starting with
the prefix `COJAC_MAGIC_` and a specific signature, to be declared in user
code; at runtime,
COJAC will redirect the call to such methods to the implementation inside the wrapper,
code; at runtime, COJAC will redirect the call to such methods
towards the implementation inside the wrapper,
thus giving the user code access to the "richer number" power.
The magic methods are model-specific (see below), but every number wrapper will at least