{"record":{"id":"9a270a45cd507cea","repo":"redis/jedis","slug":"must-not-instantiate-this-class-9a270a","errorCode":null,"errorMessage":"Must not instantiate this class","messagePattern":"Must not instantiate this class","errorType":"exception","errorClass":"InstantiationError","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/search/querybuilder/Values.java","lineNumber":13,"sourceCode":"package redis.clients.jedis.search.querybuilder;\n\nimport redis.clients.jedis.GeoCoordinate;\nimport redis.clients.jedis.args.GeoUnit;\n\nimport java.util.StringJoiner;\n\n/**\n * Created by mnunberg on 2/23/18.\n */\npublic class Values {\n  private Values() {\n    throw new InstantiationError(\"Must not instantiate this class\");\n  }\n\n  private abstract static class ScalableValue extends Value {\n    @Override\n    public boolean isCombinable() {\n      return true;\n    }\n  }\n\n  public static Value value(String s) {\n    return new ScalableValue() {\n      @Override\n      public String toString() {\n        return s;\n      }\n    };\n  }\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/search/querybuilder/Values.java#L1-L31","documentation":"Values is a static utility class for building RediSearch filter Values (numeric ranges, tags). Its private constructor throws java.lang.InstantiationError to signal that the class must never be instantiated; it only exposes static factory methods such as Values.gt, Values.eq, Values.tags.","triggerScenarios":"Instantiating the class through reflection (Constructor.newInstance on the private constructor), code generation, or tooling that constructs every class in the package; direct instantiation is a compile error.","commonSituations":"Coverage or mocking frameworks instantiating utility classes for completeness; reflection-driven plugins; copy-pasted code that attempts `new Values()` in dynamically compiled snippets.","solutions":["Call the static methods directly, e.g. Values.gt(10) or Values.tags(\"a\",\"b\"), instead of constructing Values.","Exclude utility classes from reflective instantiation lists in your tooling configuration.","Wrap needed helpers in your own class if you require an object-oriented handle."],"exampleFix":"// before\nValues v = new Values(); // InstantiationError\n// after\nValue v = Values.between(1, 10); // static factory","handlingStrategy":"try-catch","validationCode":"if (clazz == Values.class) {\n  throw new IllegalStateException(\"Values is a utility class; use its static methods\");\n}","typeGuard":"boolean isUtilityClass(Class<?> c) {\n  return c == Values.class;\n}","tryCatchPattern":"try {\n  ctor.setAccessible(true);\n  ctor.newInstance();\n} catch (java.lang.InstantiationError e) {\n  log.warn(\"Values must not be instantiated; use static factories like Values.gt()\");\n}","preventionTips":["Use Values.gt/eq/tags static factories instead of constructing the class.","Skip utility classes in reflection-based instantiation sweeps.","Document utility classes as non-instantiable in team coding guidelines."],"tags":["java","reflection","utility-class","search"],"backgroundTag":"internal-invariant-violation","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}