{"record":{"id":"d515fe5d44bc83bf","repo":"Blankj/AndroidUtilCode","slug":"u-can-t-instantiate-me-d515fe","errorCode":null,"errorMessage":"u can't instantiate me...","messagePattern":"u can't instantiate me\\.\\.\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"info","filePath":"lib/utilcode/src/main/java/com/blankj/utilcode/util/ClickUtils.java","lineNumber":53,"sourceCode":"public class ClickUtils {\n\n    private static final int   PRESSED_VIEW_SCALE_TAG           = -1;\n    private static final float PRESSED_VIEW_SCALE_DEFAULT_VALUE = -0.06f;\n\n    private static final int   PRESSED_VIEW_ALPHA_TAG           = -2;\n    private static final int   PRESSED_VIEW_ALPHA_SRC_TAG       = -3;\n    private static final float PRESSED_VIEW_ALPHA_DEFAULT_VALUE = 0.8f;\n\n    private static final int   PRESSED_BG_ALPHA_STYLE         = 4;\n    private static final float PRESSED_BG_ALPHA_DEFAULT_VALUE = 0.9f;\n\n    private static final int   PRESSED_BG_DARK_STYLE         = 5;\n    private static final float PRESSED_BG_DARK_DEFAULT_VALUE = 0.9f;\n\n    private static final long DEBOUNCING_DEFAULT_VALUE = 1000;\n\n    private ClickUtils() {\n        throw new UnsupportedOperationException(\"u can't instantiate me...\");\n    }\n\n    /**\n     * Apply scale animation for the views' click.\n     *\n     * @param views The views.\n     */\n    public static void applyPressedViewScale(final View... views) {\n        applyPressedViewScale(views, null);\n    }\n\n    /**\n     * Apply scale animation for the views' click.\n     *\n     * @param views        The views.\n     * @param scaleFactors The factors of scale for the views.\n     */\n    public static void applyPressedViewScale(final View[] views, final float[] scaleFactors) {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/Blankj/AndroidUtilCode/blob/7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809/lib/utilcode/src/main/java/com/blankj/utilcode/util/ClickUtils.java#L35-L71","documentation":"ClickUtils is a final utility class providing static click/press-effect helpers; its private constructor throws UnsupportedOperationException('u can't instantiate me...') to prevent construction. The throw is an intentional guard reachable only via reflection, because the class is final and the constructor is private.","triggerScenarios":"Reflectively invoking the private constructor (setAccessible(true) + newInstance()); coverage or generic reflection tooling that instantiates every class; UI frameworks that auto-construct helper classes.","commonSituations":"Code-coverage tools (JaCoCo/Cobertura) covering private constructors; blanket reflection tests across a package; DI/serialization frameworks attempting default construction.","solutions":["Call static methods directly (e.g., ClickUtils.applyPressedViewScale(view)) and never instantiate.","Exclude the constructor from coverage or rely on the coverage helper.","If testing the guard, assert UnsupportedOperationException rather than trying to succeed.","Remove reflective newInstance() calls against ClickUtils.class."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Never instantiate; call static methods directly.\nClickUtils.applyPressedViewScale(view);","typeGuard":null,"tryCatchPattern":"try {\n    Constructor<ClickUtils> c = ClickUtils.class.getDeclaredConstructor();\n    c.setAccessible(true);\n    c.newInstance();\n} catch (UnsupportedOperationException | InvocationTargetException e) {\n    // expected: instantiation is forbidden by design\n}","preventionTips":["Call ClickUtils static methods directly; never reflectively instantiate it.","Exclude private constructors from coverage tooling that auto-instantiates.","For guard tests, assert UnsupportedOperationException instead of trying to succeed."],"tags":["utility-class","private-constructor","reflection","clickutils","android","java"],"backgroundTag":null,"analyzedSha":"7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809","analyzedAt":"2026-08-14T02:26:54.956Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}