{"record":{"id":"b330a2d4bb7dfe73","repo":"didi/DoKit","slug":"name-was-null","errorCode":null,"errorMessage":"name + \" was null!\"","messagePattern":"name \\+ \" was null!\"","errorType":"validation","errorClass":"ReflectedException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/util/Reflector.java","lineNumber":101,"sourceCode":"        try {\n            return (R) mConstructor.newInstance(initargs);\n        } catch (InvocationTargetException e) {\n            throw new ReflectedException(\"Oops!\", e.getTargetException());\n        } catch (Throwable e) {\n            throw new ReflectedException(\"Oops!\", e);\n        }\n    }\n    \n    protected Object checked(@Nullable Object caller) throws ReflectedException {\n        if (caller == null || mType.isInstance(caller)) {\n            return caller;\n        }\n        throw new ReflectedException(\"Caller [\" + caller + \"] is not a instance of type [\" + mType + \"]!\");\n    }\n    \n    protected void check(@Nullable Object caller, @Nullable Member member, @NonNull String name) throws ReflectedException {\n        if (member == null) {\n            throw new ReflectedException(name + \" was null!\");\n        }\n        if (caller == null && !Modifier.isStatic(member.getModifiers())) {\n            throw new ReflectedException(\"Need a caller!\");\n        }\n        checked(caller);\n    }\n    \n    public Reflector bind(@Nullable Object caller) throws ReflectedException {\n        mCaller = checked(caller);\n        return this;\n    }\n    \n    public Reflector unbind() {\n        mCaller = null;\n        return this;\n    }\n    \n    public Reflector field(@NonNull String name) throws ReflectedException {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/util/Reflector.java#L83-L119","documentation":"Reflector.check(caller, member, name) throws '<name> was null!' (e.g. 'Field was null!' / 'Method was null!') when the member passed in is null. For field/method operations this means field(...) or method(...) was never called (or was reset by a subsequent constructor()/method()/field() call), so mField/mMethod is null at get/set/call time.","triggerScenarios":"Calling get()/set() without a prior successful field(name); calling call()/callByCaller() without method(name); calling .constructor(...) after .field(...) (resets mField to null) and then get(); a failed field()/method() lookup that threw and left the old member cleared on a partially mutated instance.","commonSituations":"Fluent chains reordered or split across helper methods; swallowing a ReflectedException from field() and continuing to get(); interleaving multiple member lookups on one Reflector instance.","solutions":["Chain the lookup and the operation together: on(cls).field(\"x\").get() — don't split them","Never continue after a field()/method() call has thrown; the instance may hold null members","Create a separate Reflector instance per member you need"],"exampleFix":"// before\nReflector r = Reflector.on(cls);\nr.get(); // Field was null!\n\n// after\nObject v = Reflector.on(cls).field(\"mName\").get();","handlingStrategy":"validation","validationCode":"// one member per instance, chained immediately\nReflector r = Reflector.on(cls).field(\"name\"); // then r.get() — never reuse r for other members","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never reuse a Reflector across constructor()/field()/method() — each resets the others","Do not continue using a reflector after a lookup threw"],"tags":["reflection","null-guard","ordering","api-misuse"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}