1919import static com .code_intelligence .jazzer .mutation .support .Preconditions .require ;
2020
2121import com .code_intelligence .jazzer .mutation .annotation .ValuePool ;
22- import com .code_intelligence .jazzer .utils .Log ;
2322import java .io .IOException ;
2423import java .lang .reflect .AnnotatedType ;
2524import java .lang .reflect .InvocationTargetException ;
@@ -102,9 +101,9 @@ public Stream<?> extractUserValues(AnnotatedType type) {
102101 Supplier <Stream <?>> supplier = pools .get (name );
103102 if (supplier == null ) {
104103 throw new IllegalStateException (
105- "No method named '"
104+ "@ValuePool: No method named '"
106105 + name
107- + "' found for @ValuePool on type "
106+ + "' found for type "
108107 + type .getType ().getTypeName ()
109108 + " in fuzz test method "
110109 + fuzzTestMethod .getName ()
@@ -136,9 +135,9 @@ private Stream<byte[]> extractByteArraysFromPatterns(AnnotatedType type) {
136135 List <Path > paths = GlobUtils .collectPathsForGlob (baseDir , glob );
137136 if (paths .isEmpty ()) {
138137 throw new IllegalStateException (
139- "No files matched glob pattern '"
138+ "@ValuePool: No files matched glob pattern '"
140139 + glob
141- + "' for @ValuePool on type "
140+ + "' for type "
142141 + type .getType ().getTypeName ()
143142 + " in fuzz test method "
144143 + fuzzTestMethod .getName ()
@@ -193,8 +192,10 @@ public Stream<?> get() {
193192 }
194193 }
195194 if (cachedData .isEmpty ()) {
196- Log .warn ("@ValuePool method " + method .getName () + " provided no values." );
197- return Stream .empty ();
195+ throw new IllegalStateException (
196+ "@ValuePool: method '"
197+ + method .getName ()
198+ + "' returned no values. Value pool methods must return at least one value." );
198199 }
199200 }
200201 return cachedData .stream ();
@@ -208,9 +209,12 @@ private static List<Object> loadDataFromMethod(Method method) {
208209 Stream <?> stream = (Stream <?>) method .invoke (null );
209210 return stream .collect (Collectors .toList ());
210211 } catch (IllegalAccessException e ) {
211- throw new IllegalStateException ( "Cannot access method " + method .getName (), e );
212+ throw new RuntimeException ( "@ValuePool: Access denied for method " + method .getName (), e );
212213 } catch (InvocationTargetException e ) {
213- throw new RuntimeException ("Error invoking method " + method .getName (), e .getCause ());
214+ Throwable cause = e .getCause ();
215+ throw new RuntimeException (
216+ "@ValuePool: Method " + method .getName () + " threw an exception" ,
217+ cause != null ? cause : e );
214218 }
215219 }
216220}
0 commit comments