Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.23] jazzer junit switched to a runtime api dependency #919

Open
ben-manes opened this issue Dec 21, 2024 · 2 comments
Open

[0.23] jazzer junit switched to a runtime api dependency #919

ben-manes opened this issue Dec 21, 2024 · 2 comments

Comments

@ben-manes
Copy link

I am a little confused as to why this would be intentional or if I am misusing your library. The 0.22.1 pom has jazzer-api as a compile time dependency, whereas the 0.23 pom moves all of its dependencies as runtime. Therefore, when upgrading I receive the following error.

> Task :caffeine:compileTestJava
/Users/ben/projects/caffeine/caffeine/src/test/java/com/github/benmanes/caffeine/fuzz/CaffeineSpecFuzzer.java:18: error: package com.code_intelligence.jazzer.api does not exist
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
                                       ^
/Users/ben/projects/caffeine/caffeine/src/test/java/com/github/benmanes/caffeine/fuzz/CaffeineSpecFuzzer.java:31: error: cannot find symbol
  public void parse(FuzzedDataProvider data) {
                    ^
  symbol:   class FuzzedDataProvider
  location: class CaffeineSpecFuzzer

A runtime dependency typically means that users should not use those classes themselves as an implementation detail. For example using the JDBC api with a runtime Postgres driver, or SLF4J with a runtime Logback provider. If an API should be used by consumers then that would be a compile time dependency. This does not seem to be the case unless my tests are an incorrect usage,

package com.github.benmanes.caffeine.fuzz;

import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import com.code_intelligence.jazzer.junit.FuzzTest;
import com.github.benmanes.caffeine.cache.CaffeineSpec;

/**
 * @author [email protected] (Ben Manes)
 */
public final class CaffeineSpecFuzzer {

  // These tests require the environment variable JAZZER_FUZZ=1 to try new input arguments

  @FuzzTest(maxDuration = "5m")
  @SuppressWarnings("CheckReturnValue")
  public void parse(FuzzedDataProvider data) {
    try {
      CaffeineSpec.parse(data.consumeRemainingAsString());
    } catch (IllegalArgumentException expected) { /* ignored */ }
  }
}

The easy workaround is to simply add the API dependency explicitly and that is fine. However the release notes do not state anything about this change if intentional, the junit example uses an outdated version, and it just looks like an accidental goof than an expected change.

@ben-manes
Copy link
Author

ben-manes commented Dec 21, 2024

It looks as though 0.23 enhanced the integration to support, or at least now document (old, new), that basic types like String can be provided instead. That is a nice change, but may require the annotations that would likewise require an explicit dependency as jazzer is now runtime. All of this is to say that your releases deserve better communication.

@ben-manes
Copy link
Author

Thanks for releasing a fix! I updated to v0.24.0 and was able to remove the extra dependency. I consider this resolved but since the PRs all state Work towards #919, please close when you consider it done.

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

No branches or pull requests

1 participant