Skip to content

feat: ValuePool can now reference suppliers in any class#1046

Open
oetr wants to merge 2 commits intomainfrom
CIF-1906-allow-source-methods-in-other-classes
Open

feat: ValuePool can now reference suppliers in any class#1046
oetr wants to merge 2 commits intomainfrom
CIF-1906-allow-source-methods-in-other-classes

Conversation

@oetr
Copy link
Contributor

@oetr oetr commented Feb 18, 2026

When specifying supplier methods for @ValuePool annotation, it is now possible to use fully qualified names to access methods of any class, not just the fuzz test class. E.g.:

@ValuePool(value = {"mySupplier", "anotherSupplier", 
                    "com.example.MyClass#mySupplierMethod",
                    "com.example.OuterClass$InnerClass#mySupplierMethod"})

@oetr oetr force-pushed the CIF-1906-allow-source-methods-in-other-classes branch 3 times, most recently from 9bfcd68 to 3a489f3 Compare February 19, 2026 16:39
@oetr oetr force-pushed the CIF-1906-allow-source-methods-in-other-classes branch from 3a489f3 to e9fcaad Compare February 19, 2026 17:11
@oetr oetr marked this pull request as ready for review February 19, 2026 17:11
Copilot AI review requested due to automatic review settings February 19, 2026 17:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the @ValuePool annotation to support supplier methods from any class, not just the fuzz test class. Previously, users could only reference supplier methods by their simple name within the same test class. Now, they can use fully qualified references with the format com.example.ClassName#methodName or com.example.OuterClass$InnerClass#methodName for nested classes.

Changes:

  • Added support for fully qualified supplier method references in the format ClassName#methodName
  • Refactored ValuePoolRegistry to resolve and load supplier methods from any class with fallback class loader strategy
  • Added comprehensive test coverage for external supplier references, nested classes, validation, and edge cases
  • Updated documentation in both Javadoc and markdown files with examples and usage guidelines

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/main/java/com/code_intelligence/jazzer/mutation/support/ValuePoolRegistry.java Refactored supplier resolution to support fully qualified method references with dynamic class loading and validation
src/main/java/com/code_intelligence/jazzer/mutation/annotation/ValuePool.java Updated Javadoc to document the new fully qualified reference syntax
src/test/java/com/code_intelligence/jazzer/mutation/support/ValuePoolRegistry.java Added new test support class with external supplier methods for testing cross-class references
src/test/java/com/code_intelligence/jazzer/mutation/support/ValuePoolsTest.java Added 15 new test cases covering external suppliers, nested classes, validation, caching, and error scenarios
src/test/java/com/code_intelligence/jazzer/mutation/support/BUILD.bazel Added the new test support file to the build configuration
docs/mutation-framework.md Updated documentation with examples of fully qualified supplier references and improved clarity on type propagation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// - 'input' gets Strings from two suppliers: 'edgeCases()' and 'justStrings()'
// - 'config' keys get Strings, values get Integers, Map itself gets the `map` objects, all from supplier method 'edgeCases()'
// - 'data' gets byte arrays from both edgeCases() and *.bin files
// In addition, the Integer values of the Map 'config' have a different configuaration:
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "configuaration" should be "configuration"

Suggested change
// In addition, the Integer values of the Map 'config' have a different configuaration:
// In addition, the Integer values of the Map 'config' have a different configuration:

Copilot uses AI. Check for mistakes.
// - 'config' keys get Strings, values get Integers, Map itself gets the `map` objects, all from supplier method 'edgeCases()'
// - 'data' gets byte arrays from both edgeCases() and *.bin files
// In addition, the Integer values of the Map 'config' have a different configuaration:
// the values from the value pool will be take with probability 0.01,
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "take" should be "taken"

Suggested change
// the values from the value pool will be take with probability 0.01,
// the values from the value pool will be taken with probability 0.01,

Copilot uses AI. Check for mistakes.
Map<String, Integer> map = new HashMap<>();
map.put("one", 1);
map.put("two", 2);

Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains a tab character for indentation. The rest of the codebase uses spaces for indentation in code examples. This should be replaced with spaces for consistency.

Suggested change

Copilot uses AI. Check for mistakes.

// Supplier method is in the fuzz test class
if (hashIndex == -1) {
return resolveSupplier(fuzzTestMethod.getDeclaringClass(), supplierRef);
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with fully qualified supplier references (which trim whitespace at lines 137-138), local supplier method names should also be trimmed before resolution. Currently, a reference like "@valuepool(" myPool ")" would fail to find the method, while "@valuepool("com.example.MyClass# myPool ")" would succeed after trimming. Consider adding ".trim()" to supplierRef at line 122 for consistent behavior.

Suggested change
return resolveSupplier(fuzzTestMethod.getDeclaringClass(), supplierRef);
return resolveSupplier(fuzzTestMethod.getDeclaringClass(), supplierRef.trim());

Copilot uses AI. Check for mistakes.
"@ValuePool: supplier method '"
+ supplierRef
+ "' must return a Stream<?> in fuzz test method "
+ supplier.getName());
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message incorrectly references "supplier.getName()" instead of "fuzzTestMethod.getName()". This results in an inconsistent error message format that shows the supplier method name where the fuzz test method name is expected. The error message should follow the same pattern as line 202, which correctly uses "fuzzTestMethod.getName()".

Suggested change
+ supplier.getName());
+ fuzzTestMethod.getName());

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments