Optimizing class casts away

Dear all,

I am trying to remove some instanceof tests from bc code that is produced by vmkit. For instance:

1 if (o instanceof String) {
2 String s = (String)o;
3 }

Vmkit seems to be inserting two tests into the bc code: one for the test in line 1, and another, implicit, that would lunch perhaps JavaClassCastException if the cast fails at runtime.
Would it be possible for some of you guys more familiar with vmkit to explain me how it produces code for these casts and tests? I have separated two CFG’s. The first here is for the program below:

public class J2 {
Object o = new String;
}

The second CFG here is for the same program, without the cast:

public class J1 {
Object o = new String;
String s = (String)o;
}

Could some of you give me an idea of how the extra code would look like? It seems that the CFG’s are a bit big for such small programs.

All the best,
Alysson