{"record":{"id":"65345308e30a01fe","repo":"bumptech/glide","slug":"accidentally-attempting-to-override-a-method-in-ba","errorCode":null,"errorMessage":"Accidentally attempting to override a method in BaseRequestOptions. Add an 'override' value in the @GlideOption annotation if this is intentional. Offending method: {}","messagePattern":"Accidentally attempting to override a method in BaseRequestOptions\\. Add an 'override' value in the @GlideOption annotation if this is intentional\\. Offending method: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java","lineNumber":154,"sourceCode":"    }\n  }\n\n  private boolean isBaseRequestOptions(TypeMirror typeMirror) {\n    if (useLegacyTypeComparison) {\n      return typeMirror.toString().equals(\"com.bumptech.glide.request.BaseRequestOptions<?>\");\n    }\n    return typeMirror instanceof DeclaredType declaredType\n        && declaredType.asElement() instanceof TypeElement typeElement\n        && typeElement\n            .getQualifiedName()\n            .contentEquals(\"com.bumptech.glide.request.BaseRequestOptions\");\n  }\n\n  private void validateGlideOptionOverride(ExecutableElement element) {\n    int overrideType = processorUtil.getOverrideType(element);\n    boolean isOverridingBaseRequestOptionsMethod = isMethodInBaseRequestOptions(element);\n    if (isOverridingBaseRequestOptionsMethod && overrideType == GlideOption.OVERRIDE_NONE) {\n      throw new IllegalArgumentException(\n          \"Accidentally attempting to override a method in\"\n              + \" BaseRequestOptions. Add an 'override' value in the @GlideOption annotation\"\n              + \" if this is intentional. Offending method: \"\n              + getQualifiedMethodName(element));\n    } else if (!isOverridingBaseRequestOptionsMethod && overrideType != GlideOption.OVERRIDE_NONE) {\n      throw new IllegalArgumentException(\n          \"Requested to override an existing method in\"\n              + \" BaseRequestOptions, but no such method was found. Offending method: \"\n              + getQualifiedMethodName(element));\n    }\n  }\n\n  private boolean isMethodInBaseRequestOptions(ExecutableElement toFind) {\n    // toFind is a method in a GlideExtension whose first argument is a BaseRequestOptions<?> type.\n    // Since we're comparing against methods in BaseRequestOptions itself, we need to drop that\n    // first type.\n    TypeElement requestOptionsType =\n        processingEnvironment","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java#L136-L172","documentation":"@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.","triggerScenarios":"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`.","commonSituations":"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.","solutions":["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).","If you did not intend to collide, rename your method to something not present in BaseRequestOptions (e.g. `circleCropAvatar`)."],"exampleFix":"// before\n@GlideOption\npublic static RequestOptions centerCrop(RequestOptions options) {\n  return options.centerCropTransform();\n}\n\n// after (intentional override)\n@GlideOption(override = GlideOption.OVERRIDE_REPLACE)\npublic static RequestOptions centerCrop(RequestOptions options) {\n  return options.centerCropTransform();\n}","handlingStrategy":"validation","validationCode":"// Before building, scan for name collisions with BaseRequestOptions methods:\n@Test void glideOptionOverridesAreDeclared() throws Exception {\n  java.util.Set<String> base = new java.util.HashSet<>();\n  for (java.lang.reflect.Method m : com.bumptech.glide.request.BaseRequestOptions.class.getDeclaredMethods()) {\n    base.add(m.getName());\n  }\n  for (java.lang.reflect.Method m : MyGlideExtension.class.getDeclaredMethods()) {\n    com.bumptech.glide.annotation.GlideOption o = m.getAnnotation(com.bumptech.glide.annotation.GlideOption.class);\n    if (o != null && base.contains(m.getName())) {\n      assertTrue(\"@GlideOption(\" + m + \") collides and must set override != OVERRIDE_NONE\", o.override() != com.bumptech.glide.annotation.GlideOption.OVERRIDE_NONE);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid naming @GlideOption methods after BaseRequestOptions methods (centerCrop, placeholder, override, format, ...).","If you must collide, explicitly set `@GlideOption(override = OVERRIDE_EXTEND|OVERRIDE_REPLACE)`."],"tags":["glide","annotation-processing","glideoption","override"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}