{"record":{"id":"9b3831d3444fa232","repo":"microg/GmsCore","slug":"binder-object-is-null","errorCode":null,"errorMessage":"Binder object is null.","messagePattern":"Binder object is null\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-basement/src/main/java/com/google/android/gms/dynamic/ObjectWrapper.java","lineNumber":76,"sourceCode":"            }\n\n            if (field == null) {\n                field = currentField;\n            } else {\n                throw new IllegalArgumentException(\"Too many non-synthetic fields were found\");\n            }\n        }\n\n        if (field == null) {\n            throw new IllegalArgumentException(\"No non-synthetic fields were found\");\n        }\n\n        if (!field.isAccessible()) {\n            field.setAccessible(true);\n            try {\n                return field.get(binder);\n            } catch (NullPointerException localNullPointerException) {\n                throw new IllegalArgumentException(\"Binder object is null.\",\n                        localNullPointerException);\n            } catch (IllegalArgumentException localIllegalArgumentException) {\n                throw new IllegalArgumentException(\"remoteBinder is the wrong class.\",\n                        localIllegalArgumentException);\n            } catch (IllegalAccessException localIllegalAccessException) {\n                throw new IllegalArgumentException(\"Could not access the field in remoteBinder.\",\n                        localIllegalAccessException);\n            }\n        } else {\n            throw new IllegalArgumentException();\n        }\n    }\n\n    @Nullable\n    public static <T> T unwrapTyped(IObjectWrapper obj, Class<T> clazz) {\n        try {\n            return clazz.cast(unwrap(obj));\n        } catch (ClassCastException e) {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-basement/src/main/java/com/google/android/gms/dynamic/ObjectWrapper.java#L58-L94","documentation":"During ObjectWrapper.unwrap, field.get(binder) threw a NullPointerException, which the library rethrows as IllegalArgumentException('Binder object is null.'). This means the field holding the wrapped object is null on that binder instance — effectively the wrapper wraps nothing (null) and the code path assumes non-null.","triggerScenarios":"ObjectWrapper.wrap(null) or an ObjectWrapper constructed with a null field value, then passed across the binder interface and later unwrapped with unwrap()/unwrapTyped().","commonSituations":"Upstream API returning null wrapped in an ObjectWrapper; a field that failed to initialize before being wrapped; Optional-style flows where 'absent' is encoded as a null wrapper.","solutions":["Ensure the object passed to ObjectWrapper.wrap is non-null, or skip the call when you know it's null","Null-check the field value before wrapping: if (obj == null) return; ","Catch IllegalArgumentException from unwrap* and treat it as 'value absent'","Return an Optional/nullable result instead of wrapping null"],"exampleFix":"// before\nreturn ObjectWrapper.unwrapTyped(w, MyType.class); // NPE if w wraps null\n// after\nif (w == null) return null;\ntry {\n    return ObjectWrapper.unwrapTyped(w, MyType.class);\n} catch (IllegalArgumentException e) {\n    return null;\n}","handlingStrategy":"type-guard","validationCode":"if (wrapper == null) return null;\nIBinder b = wrapper.asBinder();\nfor (Field f : b.getClass().getDeclaredFields()) {\n    if (!f.isSynthetic()) { f.setAccessible(true); if (f.get(b) == null) return null; }\n}","typeGuard":"boolean isNonNullWrapper(IObjectWrapper w) {\n    if (w == null) return false;\n    try { ObjectWrapper.unwrap(w); return true; }\n    catch (IllegalArgumentException e) { return false; }\n}","tryCatchPattern":"try {\n    T value = ObjectWrapper.unwrapTyped(wrapper, T.class);\n} catch (IllegalArgumentException e) {\n    value = null; // wrapped object was null\n}","preventionTips":["Never call ObjectWrapper.wrap(null)","Return Optional/null early instead of wrapping absent values","Validate producer outputs before crossing the binder boundary"],"tags":["android","binder","null","reflection"],"backgroundTag":"null-argument","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}