in TransformCore/src/main/java/com/facebook/ads/injkit/benchmark/BenchmarkInjector.java [165:218]
protected void processImpl(ClassNode clsNode, Model model) throws AnnotationProcessingException {
List<MethodNode> newMethods = new ArrayList<>();
if (clsNode.methods == null) {
return;
}
// This will be used when computing the methodBenchmarkMetrics so make sure it is set
// before.
if (defaultMetrics == null) {
defaultMetrics = getDefaultMetrics(annotationClassDesc, model);
}
for (MethodNode methodNode : clsNode.methods) {
removeBenchmarkMetrics(methodNode);
// We don't forward abstract methods.
if (methodNode.instructions == null || methodNode.instructions.size() == 0) {
continue;
}
if (enabled) {
BenchmarkMetrics metrics = methodBenchmarkMetrics(clsNode, methodNode, model);
if (metrics != null) {
String moveMethodName = methodNode.name;
methodNode.name = METHOD_RENAME_PREFIX + methodNode.name;
// Make sure constructors' forward methods have valid names.
methodNode.name = methodNode.name.replace('<', '$');
methodNode.name = methodNode.name.replace('>', '$');
MethodNode newMethod = createForwardMethod(moveMethodName, clsNode, methodNode, metrics);
newMethods.add(newMethod);
if (AsmNameUtils.INIT.equals(moveMethodName)) {
InsnList newInstructions = extractSuperCall(methodNode.instructions, clsNode.superName);
if (newInstructions == null) {
throw new AnnotationProcessingException(
String.format(
Locale.US,
"Don't know what to do to transform method %s%s of "
+ "class %s for benchmarking",
moveMethodName,
methodNode.desc,
clsNode.name));
}
newMethod.instructions.insert(newInstructions);
}
}
}
}
clsNode.methods.addAll(newMethods);
}