google/guava · error · ConflictingRequirementsException
Annotation explicitly or implicitly requires one or more fea
Error message
Annotation explicitly or implicitly requires one or more features to be both present and absent.
What it means
Thrown as ConflictingRequirementsException when a single tester annotation requires a feature to be both present (via value()) and absent (via absent()), after implied-feature expansion. The library treats presence and absence of the same feature as an unsatisfiable constraint, so the test cannot be meaningfully run.
Source
Thrown at android/guava-testlib/src/com/google/common/collect/testing/features/FeatureUtil.java:195
* @param testerAnnotation a tester annotation
* @return the requirements specified by the annotation
* @throws ConflictingRequirementsException if the requirements are mutually inconsistent.
*/
private static TesterRequirements buildTesterRequirements(Annotation testerAnnotation)
throws ConflictingRequirementsException {
Class<? extends Annotation> annotationClass = testerAnnotation.annotationType();
Feature<?>[] presentFeatures;
Feature<?>[] absentFeatures;
try {
presentFeatures = (Feature<?>[]) annotationClass.getMethod("value").invoke(testerAnnotation);
absentFeatures = (Feature<?>[]) annotationClass.getMethod("absent").invoke(testerAnnotation);
} catch (Exception e) {
throw new IllegalArgumentException("Error extracting features from tester annotation.", e);
}
Set<Feature<?>> allPresentFeatures = addImpliedFeatures(copyToSet(presentFeatures));
Set<Feature<?>> allAbsentFeatures = copyToSet(absentFeatures);
if (!disjoint(allPresentFeatures, allAbsentFeatures)) {
throw new ConflictingRequirementsException(
"Annotation explicitly or "
+ "implicitly requires one or more features to be both present "
+ "and absent.",
intersection(allPresentFeatures, allAbsentFeatures),
testerAnnotation);
}
return new TesterRequirements(allPresentFeatures, allAbsentFeatures);
}
/**
* Construct the set of requirements specified by annotations directly on a tester class or
* method.
*
* @param classOrMethod a tester class or a test method thereof
* @return all the constraints implicitly or explicitly required by annotations on the class or
* method.
* @throws ConflictingRequirementsException if the requirements are mutually inconsistent.
*/View on GitHub (pinned to 94f39958ba)
Solutions
- Inspect the exception's getConflicts() set to see exactly which features are present and absent simultaneously.
- Remove the feature from either value() or absent() so the two sets are disjoint after implied-feature expansion.
- If the conflict comes from implied features, replace the compound feature with the specific sub-features you actually want.
Example fix
// before
@MapFeature.Require(value = {SUPPORTS_PUT}, absent = {SUPPORTS_PUT})
public void testPut() { ... }
// after
@MapFeature.Require(SUPPORTS_PUT)
public void testPut() { ... } Defensive patterns
Strategy: validation
Validate before calling
// Before declaring a tester annotation, check value/absent disjointness after implication.
Set<Feature<?>> present = addImpliedFeatures(copyToSet(req.value()));
Set<Feature<?>> absent = copyToSet(req.absent());
if (!Collections.disjoint(present, absent))
throw new IllegalArgumentException("annotation present/absent overlap: " + Sets.intersection(present, absent)); Prevention
- Never list the same feature in both value() and absent().
- Remember compound features imply their members; avoid combining a compound in value with a member in absent.
When it happens
Trigger: A @Feature.Require that lists a feature in value() and the same (or an implying/implied) feature in absent(); or a feature whose implied set overlaps the absent set after addImpliedFeatures runs.
Common situations: Copy-pasting an annotation and editing only one side; listing a compound feature (e.g. GENERAL_PURPOSE) in value while listing an implied sub-feature in absent; feature-enum changes that add new implications across versions.
Related errors
- Annotation requires to be %s features that earlier annotatio
- Error extracting features from tester annotation.
- Call withFeatures() before createTestSuite().
- %s: no CollectionSizes specified (check the argument to Feat
- A compound CollectionSize doesn't specify a number of elemen
AI-assisted analysis of google/guava@94f39958ba (2026-08-13).
Data as JSON: /api/errors/57a5c22346363090.
Report an issue: GitHub.