Get return statements in a java method -


how can possible return values of method in java?

example:

object onevent() {  if (condition) {      return "a";  }   if (condition2) {     return "b";  }   if (condition3) {      return "c";  }   } 

i need this:

string[] returns = utils.getreturnstatements("object.onevent()"); returns = ["a", "b", "c"] 

if need analyse simple methods return constant values such 1 in example, can relatively via static analysis using asm or similar bytecode toolkit.

for methods matching structure of example (i.e directly return constants) need pattern

ldc ??? areturn 

and collect constants loaded ldc. straightforward.

if methods can more complex, e.g if return values assigned variables, need perform flow analysis. more work, asm provides support.

if methods analysing return values other simple constants incredibly difficult/impossible via static analysis.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -