Skip to content

Conversation

@oetr
Copy link
Contributor

@oetr oetr commented Jan 21, 2026

  1. The users can now supply glob patterns to the @ValuePool annotation by using the new field String[] files---files matching the patterns will be loaded as byte []. The field uses the glob: syntax of java.nio.file.PathMatcher.

Example:

@ValuePool(files={"src/test/resources/**", "/home/user/fuzzing-corpus/compression/zip/**"})
  1. In addition, by setting the new field maxMutations, the users can now control up to how many times (by default 1) values selected from @ValuePool will be mutated by the underlying mutator in one mutation operation.

Copilot AI review requested due to automatic review settings January 21, 2026 12:37
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 PR extends the @ValuePool annotation to support two new capabilities: (1) loading files as byte arrays using glob patterns via a new files field, and (2) controlling mutation iterations via a new maxMutations field.

Changes:

  • Added files field to @ValuePool annotation for glob-based file loading
  • Added maxMutations field to control mutation iterations on pool values
  • Implemented file pattern matching and path resolution in ValuePoolRegistry
  • Updated mutation logic to apply multiple mutations based on maxMutations
  • Added caching for ArgumentsMutator instances and file reads
  • Comprehensive test coverage for file loading feature
  • Extensive documentation updates

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
src/main/java/com/code_intelligence/jazzer/mutation/annotation/ValuePool.java Added files and maxMutations fields to annotation with documentation
src/main/java/com/code_intelligence/jazzer/mutation/support/ValuePoolRegistry.java Implemented glob pattern matching, file loading, and maxMutations extraction with path resolution logic
src/main/java/com/code_intelligence/jazzer/mutation/mutator/lang/ValuePoolMutatorFactory.java Updated mutate/crossOver to apply multiple mutations based on maxMutations
src/test/java/com/code_intelligence/jazzer/mutation/support/ValuePoolsTest.java Added comprehensive tests for file loading patterns and updated test helpers
src/main/java/com/code_intelligence/jazzer/mutation/ArgumentsMutator.java Added caching for ArgumentsMutator instances to improve performance
src/main/java/com/code_intelligence/jazzer/junit/FuzzTestExecutor.java Set system property for baseDir to enable ValuePoolRegistry file resolution
docs/mutation-framework.md Added extensive documentation for ValuePool features including examples and usage patterns
Comments suppressed due to low confidence (1)

src/test/java/com/code_intelligence/jazzer/mutation/support/ValuePoolsTest.java:415

  • The test helper withValuePoolImplementation is missing the maxMutations() method implementation. Since maxMutations() is now part of the @valuepool annotation interface, this anonymous implementation must override it. Without this method, using this test helper will result in runtime errors when the annotation's maxMutations() method is called.
    return new ValuePool() {
      @Override
      public String[] value() {
        return value;
      }

      @Override
      public String[] files() {
        return files;
      }

      @Override
      public double p() {
        return p;
      }

      @Override
      public String constraint() {
        return constraint;
      }

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

@oetr oetr force-pushed the CIF-1907-add-glob-pattern-to-value-pool branch 4 times, most recently from ed09c59 to e2cc773 Compare January 21, 2026 19:08
@oetr oetr marked this pull request as draft January 21, 2026 19:08
@oetr oetr force-pushed the CIF-1907-add-glob-pattern-to-value-pool branch 3 times, most recently from 6d874ba to 112ab04 Compare January 22, 2026 07:16
@oetr oetr marked this pull request as ready for review January 22, 2026 07:48
@oetr oetr requested review from a team and Copilot January 22, 2026 07:49
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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.


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

@oetr oetr force-pushed the CIF-1907-add-glob-pattern-to-value-pool branch from 112ab04 to 49403fd Compare January 22, 2026 14:38
Copy link
Contributor

@Marcono1234 Marcono1234 left a comment

Choose a reason for hiding this comment

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

Hopefully these comments are useful. Feel free to consider them only as suggestions or ignore them completely.

Please let me know if these comments are not useful or if you consider them disruptive.

@oetr
Copy link
Contributor Author

oetr commented Jan 23, 2026

Hopefully these comments are useful. Feel free to consider them only as suggestions or ignore them completely.

Please let me know if these comments are not useful or if you consider them disruptive.

@Marcono1234 Your reviews are welcome, and helpful 😄 Thanks!

@oetr oetr force-pushed the CIF-1907-add-glob-pattern-to-value-pool branch 2 times, most recently from 4818c8e to a16453d Compare February 2, 2026 09:30
@oetr oetr marked this pull request as draft February 2, 2026 11:17
@oetr oetr force-pushed the CIF-1907-add-glob-pattern-to-value-pool branch 2 times, most recently from 23d9b67 to d7004da Compare February 4, 2026 08:37
@oetr oetr marked this pull request as ready for review February 4, 2026 09:22
oetr added 5 commits February 10, 2026 15:01
The number of fields in ValuePool is getting large, so that
construction using positional args is becoming confusing.

Using a builder simplifies the tests.
Don't generate the same mutator for the same fuzz test method multiple
times. Before this change, a mutator was generated for each crash file
in fuzzing mode.
@oetr oetr force-pushed the CIF-1907-add-glob-pattern-to-value-pool branch from d7004da to 928c9a2 Compare February 10, 2026 14:01
Copy link
Contributor

@simonresch simonresch left a comment

Choose a reason for hiding this comment

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

Looks good!

Very thorough test coverage. As with our C++ detour I keep getting surprised how complicated it is to do a simple file glob. 😄 But this might come in handy in the future.

private final Method method;
private final InPlaceProductMutator productMutator;

private static final Map<Method, ArgumentsMutator> mutatorsCache = new ConcurrentHashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

We might be able to fix the JUnit integration to not create multiple mutators for the same method since it already has a store. I believe the problem is the ExecutionContext in https://github.com/CodeIntelligenceTesting/jazzer/blob/main/src/main/java/com/code_intelligence/jazzer/junit/FuzzTestExtensions.java#L198 which is the invocation context and not the test execution context. This seems to cause the serializer not to be cached correctly. Changing it to

  private static SeedSerializer getOrCreateSeedSerializer(ExtensionContext extensionContext) {
    Method method = extensionContext.getRequiredTestMethod();
    // Use the parent context (test method level) to share the store across all invocations
    // of the same test method. Each invocation gets its own ExtensionContext, so using
    // the current context would create a new SeedSerializer for each seed.
    ExtensionContext methodContext =
        extensionContext.getParent().orElse(extensionContext);
  ...

seems to fix multiple mutators being created for each crash file.

return SPECIAL_CHARS.indexOf(c) != -1;
}

protected static Path unescapeGlobChars(Path glob) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be unused.

*
* <p>Relative glob patterns are resolved against the working directory.
*
* <p>Patterns that start with <code>{</code> or <code>[</code>@code are treated as relative to
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible typo: @code

* @param glob
* @return true if the glob contains unescaped "**"
*/
protected static boolean isRecursive(String glob) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to be unused.


private static final boolean ON_WINDOWS = FileSystems.getDefault().getSeparator().equals("\\");

public static void mockSourceDirectory(Path base) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT about moving this into the GlobUtilsTest? Here it seems quite far away from where this specific directory structure is used.

Comment on lines +440 to +443
Map<String, Integer> map = new HashMap<>();
map.put("one", 1);
map.put("two", 2);
static Stream<?> edgeCases() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Map<String, Integer> map = new HashMap<>();
map.put("one", 1);
map.put("two", 2);
static Stream<?> edgeCases() {
static Stream<?> edgeCases() {
Map<String, Integer> map = new HashMap<>();
map.put("one", 1);
map.put("two", 2);

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.

3 participants