aboutsummaryrefslogtreecommitdiff
path: root/agent/src/main/java/com
diff options
context:
space:
mode:
authorFabian Meumertzheim <meumertzheim@code-intelligence.com>2021-10-19 21:58:02 +0200
committerKhaled Yakdan <yakdan@code-intelligence.de>2021-10-20 17:16:47 +0200
commitaf4ca0be2def2acfe06d39638dbf38928c430c44 (patch)
tree0ad300210ccae9da3945381c27868bf37184e8ef /agent/src/main/java/com
parentb13b2c9e97bbced1691f6bdcfd7d136a41dd5e4d (diff)
downloadjazzer-api-af4ca0be2def2acfe06d39638dbf38928c430c44.tar.gz
Improve error messages in Autofuzz fuzz target
Diffstat (limited to 'agent/src/main/java/com')
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java62
1 files changed, 41 insertions, 21 deletions
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java
index c9c0339f..87972a89 100644
--- a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java
@@ -81,7 +81,8 @@ public class FuzzTarget {
return;
}
- if (methodName.equals("new")) {
+ boolean isConstructor = methodName.equals("new");
+ if (isConstructor) {
targetExecutables =
Arrays.stream(targetClass.getConstructors())
.filter(constructor
@@ -98,27 +99,46 @@ public class FuzzTarget {
.toArray(Executable[] ::new);
}
if (targetExecutables.length == 0) {
- if (descriptor == null) {
- System.err.printf("Failed to find accessible methods named %s in class %s for autofuzz.%n"
- + "Accessible methods:%n%s",
- methodName, className,
- Arrays.stream(targetClass.getMethods())
- .map(method
- -> String.format(
- "%s::%s", method.getDeclaringClass().getName(), method.getName()))
- .distinct()
- .collect(Collectors.joining(System.lineSeparator())));
+ if (isConstructor) {
+ if (descriptor == null) {
+ System.err.printf(
+ "Failed to find accessible constructors in class %s for autofuzz.%n", className);
+ } else {
+ System.err.printf(
+ "Failed to find accessible constructors with signature %s in class %s for autofuzz.%n"
+ + "Accessible constructors:%n%s",
+ descriptor, className,
+ Arrays.stream(targetClass.getConstructors())
+ .map(method
+ -> String.format("%s::new%s", method.getDeclaringClass().getName(),
+ Utils.getReadableDescriptor(method)))
+ .distinct()
+ .collect(Collectors.joining(System.lineSeparator())));
+ }
} else {
- System.err.printf("Failed to find accessible methods named %s in class %s for autofuzz.%n"
- + "Accessible methods with that name:%n%s",
- methodName, className,
- Arrays.stream(targetClass.getMethods())
- .filter(method -> method.getName().equals(methodName))
- .map(method
- -> String.format("%s::%s%s", method.getDeclaringClass().getName(),
- method.getName(), Utils.getReadableDescriptor(method)))
- .distinct()
- .collect(Collectors.joining(System.lineSeparator())));
+ if (descriptor == null) {
+ System.err.printf("Failed to find accessible methods named %s in class %s for autofuzz.%n"
+ + "Accessible methods:%n%s",
+ methodName, className,
+ Arrays.stream(targetClass.getMethods())
+ .map(method
+ -> String.format(
+ "%s::%s", method.getDeclaringClass().getName(), method.getName()))
+ .distinct()
+ .collect(Collectors.joining(System.lineSeparator())));
+ } else {
+ System.err.printf(
+ "Failed to find accessible methods named %s with signature %s in class %s for autofuzz.%n"
+ + "Accessible methods with that name:%n%s",
+ methodName, descriptor, className,
+ Arrays.stream(targetClass.getMethods())
+ .filter(method -> method.getName().equals(methodName))
+ .map(method
+ -> String.format("%s::%s%s", method.getDeclaringClass().getName(),
+ method.getName(), Utils.getReadableDescriptor(method)))
+ .distinct()
+ .collect(Collectors.joining(System.lineSeparator())));
+ }
}
System.exit(1);
}