We now analyze enum classes static initializers as many others - with a complete analysis of $VALUES array initialization, static fields for enum constants, ordinal, names, etc. But often this analysis is unnecessary - most of the enums do not have complex logic and could be just extracted from runtime. Such extraction can highly improve performance for methods with enum usage.
Actual behavior
Enum values are not processed concretely, and UtBotJava generate 0 executions for method useEnumInDifficultIf below:
public int useEnumInDifficultIf(String s) {
if ("TRYIF".equalsIgnoreCase(s)) {
final ManyConstantsEnum[] values = ManyConstantsEnum.values();
return foo(values[0]);
} else {
final ManyConstantsEnum b = B;
return foo(b);
}
}
private int foo(ManyConstantsEnum e) {
if (e.equals(A)) {
return 1;
} else {
return 2;
}
}
enum ManyConstantsEnum {
A, B, C, D, E, F, G, H, I, J, K
}
Expected behavior:
Simple enums are processed concretely, and 2 executions with 1 and 2 returned values are generated for method useEnumInDifficultIf.
We now analyze enum classes static initializers as many others - with a complete analysis of $VALUES array initialization, static fields for enum constants, ordinal, names, etc. But often this analysis is unnecessary - most of the enums do not have complex logic and could be just extracted from runtime. Such extraction can highly improve performance for methods with enum usage.
Actual behavior
Enum values are not processed concretely, and UtBotJava generate 0 executions for method
useEnumInDifficultIfbelow:Expected behavior:
Simple enums are processed concretely, and 2 executions with 1 and 2 returned values are generated for method
useEnumInDifficultIf.