{"record":{"id":"e6671a7ec819e76c","repo":"Blankj/AndroidUtilCode","slug":"u-can-t-instantiate-me-e6671a","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/LunarUtils.java","lineNumber":14,"sourceCode":"package com.blankj.subutil.util;\n\n/**\n * <pre>\n *     author: Blankj\n *     blog  : http://blankj.com\n *     time  : 2016/12/05\n *     desc  : 日历相关工具类\n * </pre>\n */\npublic final class LunarUtils {\n\n    private LunarUtils() {\n        throw new UnsupportedOperationException(\"u can't instantiate me...\");\n    }\n\n    /*\n     * |----4位闰月|-------------13位1为30天，0为29天|\n     */\n    private static final int[] LUNAR_MONTH_DAYS = {1887, 0x1694, 0x16aa, 0x4ad5, 0xab6, 0xc4b7, 0x4ae, 0xa56, 0xb52a, 0x1d2a,\n            0xd54, 0x75aa, 0x156a, 0x1096d, 0x95c, 0x14ae, 0xaa4d, 0x1a4c, 0x1b2a, 0x8d55, 0xad4, 0x135a, 0x495d, 0x95c,\n            0xd49b, 0x149a, 0x1a4a, 0xbaa5, 0x16a8, 0x1ad4, 0x52da, 0x12b6, 0xe937, 0x92e, 0x1496, 0xb64b, 0xd4a, 0xda8,\n            0x95b5, 0x56c, 0x12ae, 0x492f, 0x92e, 0xcc96, 0x1a94, 0x1d4a, 0xada9, 0xb5a, 0x56c, 0x726e, 0x125c, 0xf92d,\n            0x192a, 0x1a94, 0xdb4a, 0x16aa, 0xad4, 0x955b, 0x4ba, 0x125a, 0x592b, 0x152a, 0xf695, 0xd94, 0x16aa, 0xaab5,\n            0x9b4, 0x14b6, 0x6a57, 0xa56, 0x1152a, 0x1d2a, 0xd54, 0xd5aa, 0x156a, 0x96c, 0x94ae, 0x14ae, 0xa4c, 0x7d26,\n            0x1b2a, 0xeb55, 0xad4, 0x12da, 0xa95d, 0x95a, 0x149a, 0x9a4d, 0x1a4a, 0x11aa5, 0x16a8, 0x16d4, 0xd2da,\n            0x12b6, 0x936, 0x9497, 0x1496, 0x1564b, 0xd4a, 0xda8, 0xd5b4, 0x156c, 0x12ae, 0xa92f, 0x92e, 0xc96, 0x6d4a,\n            0x1d4a, 0x10d65, 0xb58, 0x156c, 0xb26d, 0x125c, 0x192c, 0x9a95, 0x1a94, 0x1b4a, 0x4b55, 0xad4, 0xf55b,\n            0x4ba, 0x125a, 0xb92b, 0x152a, 0x1694, 0x96aa, 0x15aa, 0x12ab5, 0x974, 0x14b6, 0xca57, 0xa56, 0x1526,\n            0x8e95, 0xd54, 0x15aa, 0x49b5, 0x96c, 0xd4ae, 0x149c, 0x1a4c, 0xbd26, 0x1aa6, 0xb54, 0x6d6a, 0x12da,\n            0x1695d, 0x95a, 0x149a, 0xda4b, 0x1a4a, 0x1aa4, 0xbb54, 0x16b4, 0xada, 0x495b, 0x936, 0xf497, 0x1496,\n            0x154a, 0xb6a5, 0xda4, 0x15b4, 0x6ab6, 0x126e, 0x1092f, 0x92e, 0xc96, 0xcd4a, 0x1d4a, 0xd64, 0x956c, 0x155c,","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/Blankj/AndroidUtilCode/blob/7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809/lib/subutil/src/main/java/com/blankj/subutil/util/LunarUtils.java#L1-L32","documentation":"LunarUtils is a final utility class whose private constructor throws UnsupportedOperationException. It provides only static lunar-calendar helpers backed by static lookup tables, so instances are meaningless.","triggerScenarios":"Reflective instantiation or unsafe allocation of LunarUtils instead of using its static methods.","commonSituations":"Reflection/serialization frameworks or tests that construct arbitrary classes; DI scanning utility packages.","solutions":["Use the static methods, e.g. LunarUtils.lunar2Solar(...) / LunarUtils.solar2Lunar(...); never hold an instance.","Configure reflective frameworks to skip final utility classes.","Remove reflective newInstance calls targeting LunarUtils."],"exampleFix":"// before\nLunarUtils l = reflectNew(LunarUtils.class); // throws\n\n// after\nint[] lunar = LunarUtils.solar2Lunar(year, month, day);","handlingStrategy":"validation","validationCode":"// LunarUtils is static-only; never instantiate.\nint[] lunar = LunarUtils.solar2Lunar(year, month, day);","typeGuard":"private static boolean isStaticUtility(Class<?> c) {\n    return Modifier.isFinal(c.getModifiers()) && hasOnlyStaticMethods(c);\n}","tryCatchPattern":null,"preventionTips":["Use LunarUtils via its static methods only.","Configure reflective frameworks to skip final utility classes.","Remove reflective newInstance calls targeting utilities."],"tags":["android","utility","instantiation","reflection","calendar"],"backgroundTag":null,"analyzedSha":"7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809","analyzedAt":"2026-08-14T02:26:54.956Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}