{"record":{"id":"a3520a1e99428761","repo":"Justson/AgentWeb","slug":"u-can-t-instantiate-me","errorCode":null,"errorMessage":"u can't instantiate me...","messagePattern":"u can't instantiate me\\.\\.\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"agentweb-core/src/main/java/com/just/agentweb/RomUtils.java","lineNumber":34,"sourceCode":"\n/**\n * <pre>\n *     author: Blankj\n *     blog  : http://blankj.com\n *     time  : 2018/07/04\n *     desc  : utils about rom\n * </pre>\n */\npublic final class RomUtils {\n\n    private static final String[] ROM_HUAWEI    = {\"huawei\"};\n    private static final String VERSION_PROPERTY_HUAWEI  = \"ro.build.version.emui\";\n    private final static String UNKNOWN                  = \"unknown\";\n\n    private static RomInfo bean = null;\n\n    private RomUtils() {\n        throw new UnsupportedOperationException(\"u can't instantiate me...\");\n    }\n\n    /**\n     * Return whether the rom is made by huawei.\n     *\n     * @return {@code true}: yes<br>{@code false}: no\n     */\n    public static boolean isHuawei() {\n        return ROM_HUAWEI[0].equals(getRomInfo().name);\n    }\n\n    /**\n     * Return the rom's information.\n     *\n     * @return the rom's information\n     */\n    public static RomInfo getRomInfo() {\n        if (bean != null) return bean;","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/Justson/AgentWeb/blob/8f7f6adbf01010e9b2b44638f31edf10e1ba53f7/agentweb-core/src/main/java/com/just/agentweb/RomUtils.java#L16-L52","documentation":"RomUtils is a static utility class for ROM/vendor detection (Huawei EMUI, etc.); its private constructor throws UnsupportedOperationException. It exists only to expose static methods, so instantiation is intentionally blocked.","triggerScenarios":"Calling `new RomUtils()` in application code, or reflection-based construction (newInstance, serialization, bytecode tools) that invokes the private constructor.","commonSituations":"Instantiating utility classes by habit; frameworks or test tooling that reflectively construct all classes; misuse after refactoring instance-style helpers into static ones.","solutions":["Use the static methods directly, e.g. RomUtils.isHuawei() (no instance needed)","Exclude RomUtils from any reflection-based instantiation/coverage tooling","Copy the needed static helper into your own code if you require an instance-style API"],"exampleFix":"// before\nRomUtils romUtils = new RomUtils();\nboolean huawei = romUtils.isHuawei();\n// after\nboolean huawei = RomUtils.isHuawei();","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    new RomUtils();\n} catch (UnsupportedOperationException e) {\n    // utility class: use static methods like RomUtils.isHuawei()\n}","preventionTips":["Use RomUtils static methods without creating instances","Do not run reflective instantiation over library classes","Check class javadoc for utility-class intent before wrapping it in an instance API","Exclude third-party utility classes from DI/serialization scanning"],"tags":["java","android","instantiation","utility-class"],"backgroundTag":"unsupported-operation","analyzedSha":"8f7f6adbf01010e9b2b44638f31edf10e1ba53f7","analyzedAt":"2026-09-11T10:05:24.337Z","contentChangedAt":"2026-09-11T10:05:24.337Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}