Class Autofuzz


  • public final class Autofuzz
    extends Object
    Static helper functions that allow Jazzer fuzz targets to use Autofuzz.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T1> void autofuzz​(FuzzedDataProvider data, Consumer1<T1> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T1,​T2>
      void
      autofuzz​(FuzzedDataProvider data, Consumer2<T1,​T2> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T1,​T2,​T3>
      void
      autofuzz​(FuzzedDataProvider data, Consumer3<T1,​T2,​T3> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T1,​T2,​T3,​T4>
      void
      autofuzz​(FuzzedDataProvider data, Consumer4<T1,​T2,​T3,​T4> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T1,​T2,​T3,​T4,​T5>
      void
      autofuzz​(FuzzedDataProvider data, Consumer5<T1,​T2,​T3,​T4,​T5> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T1,​R>
      R
      autofuzz​(FuzzedDataProvider data, Function1<T1,​R> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T1,​T2,​R>
      R
      autofuzz​(FuzzedDataProvider data, Function2<T1,​T2,​R> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T1,​T2,​T3,​R>
      R
      autofuzz​(FuzzedDataProvider data, Function3<T1,​T2,​T3,​R> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T1,​T2,​T3,​T4,​R>
      R
      autofuzz​(FuzzedDataProvider data, Function4<T1,​T2,​T3,​T4,​R> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T1,​T2,​T3,​T4,​T5,​R>
      R
      autofuzz​(FuzzedDataProvider data, Function5<T1,​T2,​T3,​T4,​T5,​R> func)
      Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.
      static <T> T consume​(FuzzedDataProvider data, Class<T> type)
      Attempts to construct an instance of type from the fuzzer input using only public methods available on the classpath.
    • Method Detail

      • autofuzz

        public static <T1,​R> R autofuzz​(FuzzedDataProvider data,
                                              Function1<T1,​R> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Function1 with (partially) specified type variables, e.g. (Function1<String, ?>) String::new.
        Returns:
        the return value of func, or null if autofuzz failed to invoke the function.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • autofuzz

        public static <T1,​T2,​R> R autofuzz​(FuzzedDataProvider data,
                                                       Function2<T1,​T2,​R> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Function2 with (partially) specified type variables.
        Returns:
        the return value of func, or null if autofuzz failed to invoke the function.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • autofuzz

        public static <T1,​T2,​T3,​R> R autofuzz​(FuzzedDataProvider data,
                                                                Function3<T1,​T2,​T3,​R> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Function3 with (partially) specified type variables.
        Returns:
        the return value of func, or null if autofuzz failed to invoke the function.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • autofuzz

        public static <T1,​T2,​T3,​T4,​R> R autofuzz​(FuzzedDataProvider data,
                                                                         Function4<T1,​T2,​T3,​T4,​R> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Function4 with (partially) specified type variables.
        Returns:
        the return value of func, or null if autofuzz failed to invoke the function.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • autofuzz

        public static <T1,​T2,​T3,​T4,​T5,​R> R autofuzz​(FuzzedDataProvider data,
                                                                                  Function5<T1,​T2,​T3,​T4,​T5,​R> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Function5 with (partially) specified type variables.
        Returns:
        the return value of func, or null if autofuzz failed to invoke the function.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • autofuzz

        public static <T1> void autofuzz​(FuzzedDataProvider data,
                                         Consumer1<T1> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Consumer1 with explicitly specified type variable.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • autofuzz

        public static <T1,​T2> void autofuzz​(FuzzedDataProvider data,
                                                  Consumer2<T1,​T2> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Consumer2 with (partially) specified type variables.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • autofuzz

        public static <T1,​T2,​T3> void autofuzz​(FuzzedDataProvider data,
                                                           Consumer3<T1,​T2,​T3> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Consumer3 with (partially) specified type variables.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • autofuzz

        public static <T1,​T2,​T3,​T4> void autofuzz​(FuzzedDataProvider data,
                                                                    Consumer4<T1,​T2,​T3,​T4> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Consumer4 with (partially) specified type variables.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • autofuzz

        public static <T1,​T2,​T3,​T4,​T5> void autofuzz​(FuzzedDataProvider data,
                                                                             Consumer5<T1,​T2,​T3,​T4,​T5> func)
        Attempts to invoke func with arguments created automatically from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to execute func in meaningful ways for a number of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        func - a method reference for the function to autofuzz. If there are multiple overloads, resolve ambiguities by explicitly casting to Consumer5 with (partially) specified type variables.
        Throws:
        Throwable - any Throwable thrown by func, or an AutofuzzConstructionException if autofuzz failed to construct the arguments for the call. The Throwable is thrown unchecked.
      • consume

        public static <T> T consume​(FuzzedDataProvider data,
                                    Class<T> type)
        Attempts to construct an instance of type from the fuzzer input using only public methods available on the classpath.

        Note: This function is inherently heuristic and may fail to return meaningful values for a variety of reasons.

        Parameters:
        data - the FuzzedDataProvider instance provided to fuzzerTestOneInput.
        type - the Class to construct an instance of.
        Returns:
        an instance of type constructed from the fuzzer input, or null if autofuzz failed to create an instance.