{"record":{"id":"aaba61524672d24f","repo":"bumptech/glide","slug":"requestoptionsextensions-must-be-public-with-priv","errorCode":null,"errorMessage":"RequestOptionsExtensions must be public, with private constructors and only static methods. Found a non-private constructor in: {}","messagePattern":"RequestOptionsExtensions must be public, with private constructors and only static methods\\. Found a non-private constructor in: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java","lineNumber":82,"sourceCode":"      }\n    }\n  }\n\n  private static String getQualifiedMethodName(ExecutableElement executableElement) {\n    return getEnclosingClassName(executableElement) + \"#\" + getName(executableElement);\n  }\n\n  private static String getEnclosingClassName(Element element) {\n    return element.getEnclosingElement().toString();\n  }\n\n  private static String getName(Element element) {\n    return element.toString();\n  }\n\n  private static void validateExtensionConstructor(Element element) {\n    if (!element.getModifiers().contains(Modifier.PRIVATE)) {\n      throw new IllegalArgumentException(\n          \"RequestOptionsExtensions must be public, with private constructors and only static\"\n              + \" methods. Found a non-private constructor in: \"\n              + getEnclosingClassName(element));\n    }\n    ExecutableElement executableElement = (ExecutableElement) element;\n    if (!executableElement.getParameters().isEmpty()) {\n      throw new IllegalArgumentException(\n          \"RequestOptionsExtensions must be public, with private constructors and only static\"\n              + \" methods. Found parameters in the constructor of: \"\n              + getEnclosingClassName(element));\n    }\n  }\n\n  private void validateGlideOption(ExecutableElement executableElement) {\n    validateGlideOptionAnnotations(executableElement);\n    validateGlideOptionParameters(executableElement);\n    TypeMirror returnType = executableElement.getReturnType();\n    if (!isBaseRequestOptions(returnType)) {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java#L64-L100","documentation":"A @GlideExtension is a pure container of static methods, so its constructors must be private to prevent instantiation. validateExtensionConstructor rejects any constructor whose modifiers do not include PRIVATE. The enclosing class name is included so you can locate the offending constructor.","triggerScenarios":"GlideExtensionValidator.validateExtensionConstructor fires for each ElementKind.CONSTRUCTOR inside a @GlideExtension class; throws when `!element.getModifiers().contains(Modifier.PRIVATE)`. Hit by a class with an implicit public no-arg constructor (no explicit private constructor) or an explicitly package-private/protected/public constructor.","commonSituations":"Forgetting to add a private constructor to a utility-style extension class (Java inserts a default public one); Kotlin `class` without an explicit `private constructor()`; copying a normal utility class and adding @GlideExtension without privatizing the constructor.","solutions":["Add an explicit private no-arg constructor to the @GlideExtension class.","In Kotlin use `class MyGlideExtension private constructor()`.","Remove any additional non-private constructors; only private constructors are allowed."],"exampleFix":"// before\n@GlideExtension\npublic class MyGlideExtension {\n  // implicit public no-arg constructor -> rejected\n  @GlideOption public static RequestOptions cache(RequestOptions o) { ... }\n}\n\n// after\n@GlideExtension\npublic class MyGlideExtension {\n  private MyGlideExtension() {}\n  @GlideOption public static RequestOptions cache(RequestOptions o) { ... }\n}","handlingStrategy":"validation","validationCode":"@Test void glideExtensionConstructorsArePrivate() {\n  for (java.lang.reflect.Constructor<?> c : MyGlideExtension.class.getDeclaredConstructors()) {\n    assertTrue(\"constructor must be private: \" + c, java.lang.reflect.Modifier.isPrivate(c.getModifiers()));\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always add an explicit `private ConstructorName()` (Java) or `private constructor()` (Kotlin) to @GlideExtension classes.","Treat @GlideExtension classes as utility classes: no instantiation, no state."],"tags":["glide","annotation-processing","glideextension","constructor","visibility"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}