Blankj/AndroidUtilCode · warning · UnsupportedOperationException
u can't instantiate me...
Error message
u can't instantiate me...
What it means
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.
Source
Thrown at lib/subutil/src/main/java/com/blankj/subutil/util/LunarUtils.java:14
package com.blankj.subutil.util;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/12/05
* desc : 日历相关工具类
* </pre>
*/
public final class LunarUtils {
private LunarUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/*
* |----4位闰月|-------------13位1为30天,0为29天|
*/
private static final int[] LUNAR_MONTH_DAYS = {1887, 0x1694, 0x16aa, 0x4ad5, 0xab6, 0xc4b7, 0x4ae, 0xa56, 0xb52a, 0x1d2a,
0xd54, 0x75aa, 0x156a, 0x1096d, 0x95c, 0x14ae, 0xaa4d, 0x1a4c, 0x1b2a, 0x8d55, 0xad4, 0x135a, 0x495d, 0x95c,
0xd49b, 0x149a, 0x1a4a, 0xbaa5, 0x16a8, 0x1ad4, 0x52da, 0x12b6, 0xe937, 0x92e, 0x1496, 0xb64b, 0xd4a, 0xda8,
0x95b5, 0x56c, 0x12ae, 0x492f, 0x92e, 0xcc96, 0x1a94, 0x1d4a, 0xada9, 0xb5a, 0x56c, 0x726e, 0x125c, 0xf92d,
0x192a, 0x1a94, 0xdb4a, 0x16aa, 0xad4, 0x955b, 0x4ba, 0x125a, 0x592b, 0x152a, 0xf695, 0xd94, 0x16aa, 0xaab5,
0x9b4, 0x14b6, 0x6a57, 0xa56, 0x1152a, 0x1d2a, 0xd54, 0xd5aa, 0x156a, 0x96c, 0x94ae, 0x14ae, 0xa4c, 0x7d26,
0x1b2a, 0xeb55, 0xad4, 0x12da, 0xa95d, 0x95a, 0x149a, 0x9a4d, 0x1a4a, 0x11aa5, 0x16a8, 0x16d4, 0xd2da,
0x12b6, 0x936, 0x9497, 0x1496, 0x1564b, 0xd4a, 0xda8, 0xd5b4, 0x156c, 0x12ae, 0xa92f, 0x92e, 0xc96, 0x6d4a,
0x1d4a, 0x10d65, 0xb58, 0x156c, 0xb26d, 0x125c, 0x192c, 0x9a95, 0x1a94, 0x1b4a, 0x4b55, 0xad4, 0xf55b,
0x4ba, 0x125a, 0xb92b, 0x152a, 0x1694, 0x96aa, 0x15aa, 0x12ab5, 0x974, 0x14b6, 0xca57, 0xa56, 0x1526,
0x8e95, 0xd54, 0x15aa, 0x49b5, 0x96c, 0xd4ae, 0x149c, 0x1a4c, 0xbd26, 0x1aa6, 0xb54, 0x6d6a, 0x12da,
0x1695d, 0x95a, 0x149a, 0xda4b, 0x1a4a, 0x1aa4, 0xbb54, 0x16b4, 0xada, 0x495b, 0x936, 0xf497, 0x1496,
0x154a, 0xb6a5, 0xda4, 0x15b4, 0x6ab6, 0x126e, 0x1092f, 0x92e, 0xc96, 0xcd4a, 0x1d4a, 0xd64, 0x956c, 0x155c,View on GitHub (pinned to 7b4caf9e54)
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.
Example fix
// before LunarUtils l = reflectNew(LunarUtils.class); // throws // after int[] lunar = LunarUtils.solar2Lunar(year, month, day);
Defensive patterns
Strategy: validation
Validate before calling
// LunarUtils is static-only; never instantiate. int[] lunar = LunarUtils.solar2Lunar(year, month, day);
Type guard
private static boolean isStaticUtility(Class<?> c) {
return Modifier.isFinal(c.getModifiers()) && hasOnlyStaticMethods(c);
} Prevention
- Use LunarUtils via its static methods only.
- Configure reflective frameworks to skip final utility classes.
- Remove reflective newInstance calls targeting utilities.
When it happens
Trigger: Reflective instantiation or unsafe allocation of LunarUtils instead of using its static methods.
Common situations: Reflection/serialization frameworks or tests that construct arbitrary classes; DI scanning utility packages.
Related errors
- u can't instantiate me...
- u can't instantiate me...
- u can't instantiate me...
- u can't instantiate me...
- u can't instantiate me...
AI-assisted analysis of Blankj/AndroidUtilCode@7b4caf9e54 (2026-08-14).
Data as JSON: /api/errors/e6671a7ec819e76c.
Report an issue: GitHub.