Sable/soot — pull request #8 by ThomasGP (2012-10-08 16:45:44+00:00)
Title: correctly handle edge case in tableswitch, where highIndex is Integer.MAX_VALUE

The toString()-Methods of JTableSwitchStmt and BTableSwitchInst do not handle an edge case, where the highIndex is Integer.MAX_VALUE: A for loop wraps around to Integer.MIN_VALUE, leading to ArrayIndexOutOfBoundsException or an infinite loop.

I came across this while recreating a [bug](http://code.google.com/p/android/issues/detail?id=22344) in Android with Jimple. The example there leads to a LookupSwitchStmt, but one can easily reproduce the situation mentioned above with this Java code:

```java
switch (0x7fffffff) {
case 0x7fffffff - 1:
case 0x7fffffff:
break;
default:
throw new AssertionError();
}
```

I'm not sure if the incorrect handling of Integer.MAX_VALUE as highIndex is present in other classes than JTableSwitchStmt and BTableSwitchInst because I'm not familiar with all the intermediate representations in Soot. Someone with that knowledge should check for similiar "edgy" uses of highIndex for a TableSwitch.

Note that the JVM spec permits the "low" and "high" tableswitch indices to range from Integer.MIN_VALUE to Integer.MAX_VALUE, so I guess there is no other solution than the one proposed, to check for one of the edge cases, in my case for highIndex == Integer.MAX_VALUE