{"record":{"id":"0ef3e979d4454f82","repo":"Blankj/AndroidUtilCode","slug":"u-can-t-instantiate-me-0ef3e9","errorCode":null,"errorMessage":"u can't instantiate me...","messagePattern":"u can't instantiate me\\.\\.\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"lib/subutil/src/main/java/com/blankj/subutil/util/PinyinUtils.java","lineNumber":16,"sourceCode":"package com.blankj.subutil.util;\n\nimport androidx.collection.SimpleArrayMap;\n\n/**\n * <pre>\n *     author: Blankj\n *     blog  : http://blankj.com\n *     time  : 16/11/16\n *     desc  : 拼音相关工具类\n * </pre>\n */\npublic final class PinyinUtils {\n\n    private PinyinUtils() {\n        throw new UnsupportedOperationException(\"u can't instantiate me...\");\n    }\n\n    /**\n     * 汉字转拼音\n     *\n     * @param ccs 汉字字符串(Chinese characters)\n     * @return 拼音\n     */\n    public static String ccs2Pinyin(final CharSequence ccs) {\n        return ccs2Pinyin(ccs, \"\");\n    }\n\n    /**\n     * 汉字转拼音\n     *\n     * @param ccs   汉字字符串(Chinese characters)\n     * @param split 汉字拼音之间的分隔符\n     * @return 拼音","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/Blankj/AndroidUtilCode/blob/7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809/lib/subutil/src/main/java/com/blankj/subutil/util/PinyinUtils.java#L1-L34","documentation":"PinyinUtils is a final utility class with a private constructor that throws UnsupportedOperationException. All Chinese-to-Pinyin helpers are static; instantiation is forbidden by design.","triggerScenarios":"Reflective instantiation or unsafe allocation of PinyinUtils rather than calling its static methods.","commonSituations":"Reflection/DI/serialization frameworks that build arbitrary classes; tests that reflectively scaffold utilities.","solutions":["Call the static methods, e.g. PinyinUtils.ccs2Pinyin(text) / PinyinUtils.getPinyinFirstLetter(c); never instantiate.","Exclude PinyinUtils from reflective scanning.","Remove newInstance paths targeting the class."],"exampleFix":"// before\nPinyinUtils p = reflectNew(PinyinUtils.class); // throws\n\n// after\nString py = PinyinUtils.ccs2Pinyin(\"你好\");","handlingStrategy":"validation","validationCode":"// PinyinUtils is static-only; never instantiate.\nString py = PinyinUtils.ccs2Pinyin(text);","typeGuard":"private static boolean isStaticUtility(Class<?> c) {\n    return Modifier.isFinal(c.getModifiers()) && hasOnlyStaticMethods(c);\n}","tryCatchPattern":null,"preventionTips":["Use PinyinUtils via its static methods only.","Exclude PinyinUtils from reflective scanning.","Remove newInstance paths targeting the class."],"tags":["android","utility","instantiation","reflection","i18n"],"backgroundTag":null,"analyzedSha":"7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809","analyzedAt":"2026-08-14T02:26:54.956Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}