ilya-klyuchnikov / faba

Fast Bytecode Analysis
15 stars 1 forks source link

Nullity propagation via constraints #30

Closed ilya-klyuchnikov closed 9 years ago

ilya-klyuchnikov commented 10 years ago

A fruitful and simple way to infer more @NotNull annotations. State has a set of values that should be not null at this point. Values are: parameters, values originated at some instruction.

Currently this propagation is for methods without cycles only. It is unclear yet about propagation for methods with cycles - since there are generalizations and we should apply generalization to constraints as well.

ilya-klyuchnikov commented 10 years ago

TODO:

Object x = foo();
Assert.notNull(x);
return x;
ilya-klyuchnikov commented 10 years ago

Current state: this approach is quite fast for inference of @NotNull methods - it seems that there are no problem to propagate all constraints (thanks to smart result origins analysis). The downside is that this approach is slower for inference of @Contract annotations. The reason is that in many cases work for inference of @Contract annotations is idle. It may require a separate research to elaborate some heuristics for filtering methods without @Contract annotations. Another approach is to process contract annotations offline. Usually contract annotations quite rare and they do not (usually) depend on other jars, so they may be calculated independently for jars.

ilya-klyuchnikov commented 9 years ago

merged in master manually