Make Analyzer not require correct maxs or calculate maxs fast
I am writing bytecode using the tree api and want to analyze the code afterwards. I can't calculate maxs during that process. Basically I have to do it like this to avoid "Insufficient maximum ... size":
public static Frame<BasicValue>[] getFrames(ClassNode c, MethodNode m) {
m.maxStack = 999; // we don't want insufficient stack size
Analyzer<BasicValue> a = new Analyzer<>(new BasicInterpreter());
try {
a.analyze(c.name, m);
} catch (Throwable e) {
logger.error("Failed analysis in {}, {}", c.name, m.name);
return null;
}
return a.getFrames();
}
Always using a high max stack value causes the analyzer to be slow on many classes. I don't want to do a hacky try catch block recursion with if (String.valueOf(e.getMessage()).contains("Insufficient maximum")) { ... }
. Is there a fast way to calculate the maxs beforehand using the tree api, so i can use the correct values before analyzing, or would it be faster to update the analyzer to be independent from the defined max values? Is there something like a MaxsEvaluator?