Integer widening operators: some preliminary statistics.
Ruslan Shevchenko
rssh at gradsoft.com.ua
Thu Apr 23 15:34:37 PDT 2009
Good day, Bruce.
Some data about integer widening operator:
http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000906.html
3 checks was implemented:
1. model check for expression like ($x && 0xff) or (0xff & $x) where $x
must have a type byte (original request). This check named as "widening
operator (semantics)"
2. syntax check for expression like ($x && 0xff) or (0xff & $x) where $x
can have any type. This check named as "widening operator (syntax)"
Example of second but not first:
<pre>
public static short reverseBytes(short s) {
return (short) (((s & 0xff) << 8) | ((s & 0xff00) >> 8));
}
</pre>
<pre>
byte[] nounce = new byte[24];
for (int i=0;i<8;i++)
{
nounce[i]=(byte)(ts&0xff);
ts=ts>>8;
nounce[8+i]=(byte)(sk&0xff);
sk=sk>>8;
}
</pre>
3. count of all expressions with bitwise and. (names as all bit ands)
Than, results for jetty was:
all bit ands : 121
widening operator (semantics) : 10
widening operator (syntax) : 20
// some other counts, to compare with:
rethrow clause : 34
string in switch : 19
hibernate does not use bitwise and at all.
gwt-users have 2 entries of syntax pattern (actually this is reverseBytes
function).
Result for jdk I will publish tomorrow, when ones will be ready.
It was preliminary data (one from 3 packages use 'bitwise and') more
statistics and some analysis will be available throught few days (with
data about for-s and ERP in dataset).
Best Regards !
More information about the coin-dev
mailing list