{"record":{"id":"a041f6837d4f3c71","repo":"Bigkoo/Android-PickerView","slug":"type-length-is-not-6","errorCode":null,"errorMessage":"type[] length is not 6","messagePattern":"type\\[\\] length is not 6","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pickerview/src/main/java/com/bigkoo/pickerview/view/WheelTime.java","lineNumber":219,"sourceCode":"                }\n\n                if (currentIndex > maxItem - 1) {\n                    wv_day.setCurrentItem(maxItem - 1);\n                }\n\n                if (mSelectChangeCallback != null) {\n                    mSelectChangeCallback.onTimeSelectChanged();\n                }\n            }\n        });\n\n        setChangedListener(wv_day);\n        setChangedListener(wv_hours);\n        setChangedListener(wv_minutes);\n        setChangedListener(wv_seconds);\n\n        if (type.length != 6) {\n            throw new RuntimeException(\"type[] length is not 6\");\n        }\n        wv_year.setVisibility(type[0] ? View.VISIBLE : View.GONE);\n        wv_month.setVisibility(type[1] ? View.VISIBLE : View.GONE);\n        wv_day.setVisibility(type[2] ? View.VISIBLE : View.GONE);\n        wv_hours.setVisibility(type[3] ? View.VISIBLE : View.GONE);\n        wv_minutes.setVisibility(type[4] ? View.VISIBLE : View.GONE);\n        wv_seconds.setVisibility(type[5] ? View.VISIBLE : View.GONE);\n        setContentTextSize();\n    }\n\n    /**\n     * 设置公历\n     *\n     * @param year\n     * @param month\n     * @param day\n     * @param h\n     * @param m","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/Bigkoo/Android-PickerView/blob/e200d8c063aa2568d728854c048340ad2e4e0c0b/pickerview/src/main/java/com/bigkoo/pickerview/view/WheelTime.java#L201-L237","documentation":"WheelTime.setLunar throws an uncaught RuntimeException when the boolean[] type array configuring which wheels (year, month, day, hours, minutes, seconds) are visible does not have exactly 6 elements. The array is indexed element-by-element, so any other length is invalid.","triggerScenarios":"Calling setLunar with a boolean[] shorter or longer than 6, e.g. new boolean[]{true,true,true} to show only y/m/d, or building the array dynamically with a variable count.","commonSituations":"Wanting to hide some units and assuming a shorter array means 'show only these'; copying a snippet with a 3- or 5-element array; refactoring the type array without updating all initializers.","solutions":["Always pass a 6-element boolean[] in order year, month, day, hours, minutes, seconds","Use the Builder's setType(boolean...) and pass all 6 flags, using false for wheels you want hidden","Note this variant throws RuntimeException (not IllegalArgumentException) — don't rely on catching the declared type"],"exampleFix":"// before\ntimePicker.setType(new boolean[]{true, true, true}); // throws\n// after\ntimePicker.setType(new boolean[]{true, true, true, false, false, false});","handlingStrategy":"validation","validationCode":"static boolean isValidTypeArray(boolean[] type) {\n    return type != null && type.length == 6;\n}","typeGuard":"static boolean[] requireSixFlags(boolean[] type) {\n    if (type == null || type.length != 6)\n        throw new IllegalArgumentException(\"type must have 6 flags: year,month,day,hours,minutes,seconds\");\n    return type;\n}","tryCatchPattern":"try {\n    wheelTime.setLunar(type);\n} catch (RuntimeException e) {\n    wheelTime.setLunar(new boolean[]{true,true,true,true,true,true});\n}","preventionTips":["Always build the type array with exactly 6 entries (year, month, day, hours, minutes, seconds)","Use false, not a shorter array, to hide wheels","Define a shared constant like ALL_SIX = {true,true,true,true,true,true}"],"tags":["android","timepicker","configuration","array-length"],"backgroundTag":"array-length-mismatch","analyzedSha":"e200d8c063aa2568d728854c048340ad2e4e0c0b","analyzedAt":"2026-09-07T23:07:09.243Z","contentChangedAt":"2026-09-07T23:07:09.243Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}