Skip to content

Commit

Permalink
Add method signature when report method not found (#8185)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbempel authored Jan 13, 2025
1 parent 8bcee06 commit 9b8eee7
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
*/
public class DebuggerTransformer implements ClassFileTransformer {
private static final Logger log = LoggerFactory.getLogger(DebuggerTransformer.class);
private static final String CANNOT_FIND_METHOD = "Cannot find method %s::%s";
private static final String CANNOT_FIND_METHOD = "Cannot find method %s::%s%s";
private static final String INSTRUMENTATION_FAILS = "Instrumentation fails for %s";
private static final String CANNOT_FIND_LINE = "No executable code was found at %s:L%s";
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
Expand Down Expand Up @@ -536,20 +536,22 @@ private void handleInstrumentationResult(
private void reportLocationNotFound(
ProbeDefinition definition, String className, String methodName) {
if (methodName != null) {
reportErrorForAllProbes(singletonList(definition), CANNOT_FIND_METHOD, className, methodName);
String signature = definition.getWhere().getSignature();
signature = signature == null ? "" : signature;
String msg = String.format(CANNOT_FIND_METHOD, className, methodName, signature);
reportErrorForAllProbes(singletonList(definition), msg);
return;
}
// This is a line probe, so we don't report line not found because the line may be found later
// on a separate class files because probe was set on an inner/top-level class
}

private void reportInstrumentationFails(List<ProbeDefinition> definitions, String className) {
reportErrorForAllProbes(definitions, INSTRUMENTATION_FAILS, className, null);
String msg = String.format(INSTRUMENTATION_FAILS, className);
reportErrorForAllProbes(definitions, msg);
}

private void reportErrorForAllProbes(
List<ProbeDefinition> definitions, String format, String className, String location) {
String msg = String.format(format, className, location);
private void reportErrorForAllProbes(List<ProbeDefinition> definitions, String msg) {
DiagnosticMessage diagnosticMessage = new DiagnosticMessage(DiagnosticMessage.Kind.ERROR, msg);
for (ProbeDefinition definition : definitions) {
addDiagnostics(definition, singletonList(diagnosticMessage));
Expand Down

0 comments on commit 9b8eee7

Please sign in to comment.