bumptech/glide · error · IllegalArgumentException

Accidentally attempting to override a method in BaseRequestO

Error message

Accidentally attempting to override a method in BaseRequestOptions. Add an 'override' value in the @GlideOption annotation if this is intentional. Offending method: {}

What it means

@GlideOption's `override` defaults to OVERRIDE_NONE, meaning the method adds new functionality. If your method's name and trailing-argument types happen to match an existing method in BaseRequestOptions (detected by isMethodInBaseRequestOptions), the processor assumes you may be clobbering a real method by accident and requires you to declare intent via OVERRIDE_EXTEND or OVERRIDE_REPLACE. This prevents accidental silent overrides.

Source

Thrown at annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java:154

    }
  }

  private boolean isBaseRequestOptions(TypeMirror typeMirror) {
    if (useLegacyTypeComparison) {
      return typeMirror.toString().equals("com.bumptech.glide.request.BaseRequestOptions<?>");
    }
    return typeMirror instanceof DeclaredType declaredType
        && declaredType.asElement() instanceof TypeElement typeElement
        && typeElement
            .getQualifiedName()
            .contentEquals("com.bumptech.glide.request.BaseRequestOptions");
  }

  private void validateGlideOptionOverride(ExecutableElement element) {
    int overrideType = processorUtil.getOverrideType(element);
    boolean isOverridingBaseRequestOptionsMethod = isMethodInBaseRequestOptions(element);
    if (isOverridingBaseRequestOptionsMethod && overrideType == GlideOption.OVERRIDE_NONE) {
      throw new IllegalArgumentException(
          "Accidentally attempting to override a method in"
              + " BaseRequestOptions. Add an 'override' value in the @GlideOption annotation"
              + " if this is intentional. Offending method: "
              + getQualifiedMethodName(element));
    } else if (!isOverridingBaseRequestOptionsMethod && overrideType != GlideOption.OVERRIDE_NONE) {
      throw new IllegalArgumentException(
          "Requested to override an existing method in"
              + " BaseRequestOptions, but no such method was found. Offending method: "
              + getQualifiedMethodName(element));
    }
  }

  private boolean isMethodInBaseRequestOptions(ExecutableElement toFind) {
    // toFind is a method in a GlideExtension whose first argument is a BaseRequestOptions<?> type.
    // Since we're comparing against methods in BaseRequestOptions itself, we need to drop that
    // first type.
    TypeElement requestOptionsType =
        processingEnvironment

View on GitHub (pinned to eb14a895d8)

Solutions

  1. If you genuinely want to extend or replace the built-in, set `@GlideOption(override = GlideOption.OVERRIDE_EXTEND)` (call super then add) or `OVERRIDE_REPLACE` (replace entirely).
  2. If you did not intend to collide, rename your method to something not present in BaseRequestOptions (e.g. `circleCropAvatar`).

Example fix

// before
@GlideOption
public static RequestOptions centerCrop(RequestOptions options) {
  return options.centerCropTransform();
}

// after (intentional override)
@GlideOption(override = GlideOption.OVERRIDE_REPLACE)
public static RequestOptions centerCrop(RequestOptions options) {
  return options.centerCropTransform();
}
Defensive patterns

Strategy: validation

Validate before calling

// Before building, scan for name collisions with BaseRequestOptions methods:
@Test void glideOptionOverridesAreDeclared() throws Exception {
  java.util.Set<String> base = new java.util.HashSet<>();
  for (java.lang.reflect.Method m : com.bumptech.glide.request.BaseRequestOptions.class.getDeclaredMethods()) {
    base.add(m.getName());
  }
  for (java.lang.reflect.Method m : MyGlideExtension.class.getDeclaredMethods()) {
    com.bumptech.glide.annotation.GlideOption o = m.getAnnotation(com.bumptech.glide.annotation.GlideOption.class);
    if (o != null && base.contains(m.getName())) {
      assertTrue("@GlideOption(" + m + ") collides and must set override != OVERRIDE_NONE", o.override() != com.bumptech.glide.annotation.GlideOption.OVERRIDE_NONE);
    }
  }
}

Prevention

When it happens

Trigger: GlideExtensionValidator.validateGlideOptionOverride computes `isOverridingBaseRequestOptionsMethod = isMethodInBaseRequestOptions(element)` (matching simple name + comparable parameter types after dropping the first RequestOptions arg) and `overrideType = processorUtil.getOverrideType(element)`; throws when both `isOverridingBaseRequestOptionsMethod` and `overrideType == GlideOption.OVERRIDE_NONE`. Hit by naming a @GlideOption method `placeholder`, `centerCrop`, `diskCacheStrategy`, etc. without setting `override`.

Common situations: Writing a `@GlideOption static RequestOptions centerCrop(RequestOptions o)` that shadows the built-in; redefining `fitCenter`/`override`/`format` to tweak behavior without intending to replace the original.

Related errors


AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14). Data as JSON: /api/errors/65345308e30a01fe. Report an issue: GitHub.