{"record":{"id":"7cc05417f3d87b63","repo":"MuntashirAkon/AppManager","slug":"can-t-unparcel-type-actual-getname-in-list-of-type-expected","errorCode":null,"errorMessage":"Can't unparcel type \" + actual.getName() + \" in list of type \" + (expected == null ? null : expected.getName())","messagePattern":"Can't unparcel type \" \\+ actual\\.getName\\(\\) \\+ \" in list of type \" \\+ \\(expected == null \\? null : expected\\.getName\\(\\)\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"libcore/io/src/main/java/aosp/android/content/pm/BaseParceledListSlice.java","lineNumber":125,"sourceCode":"            }\n            reply.recycle();\n            data.recycle();\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private T readCreator(Parcelable.Creator<?> creator, Parcel p, @Nullable ClassLoader loader) {\n        if (creator instanceof Parcelable.ClassLoaderCreator<?>) {\n            Parcelable.ClassLoaderCreator<?> classLoaderCreator =\n                    (Parcelable.ClassLoaderCreator<?>) creator;\n            return (T) classLoaderCreator.createFromParcel(p, loader);\n        }\n        return (T) creator.createFromParcel(p);\n    }\n\n    private static void verifySameType(@Nullable final Class<?> expected, @NonNull final Class<?> actual) {\n        if (!actual.equals(expected)) {\n            throw new IllegalArgumentException(\"Can't unparcel type \"\n                    + actual.getName() + \" in list of type \"\n                    + (expected == null ? null : expected.getName()));\n        }\n    }\n\n    public List<T> getList() {\n        return mList;\n    }\n\n    /**\n     * Set a limit on the maximum number of entries in the array that will be included\n     * inline in the initial parcelling of this object.\n     */\n    public void setInlineCountLimit(int maxCount) {\n        mInlineCountLimit = maxCount;\n    }\n\n    /**","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/io/src/main/java/aosp/android/content/pm/BaseParceledListSlice.java#L107-L143","documentation":"BaseParceledListSlice.verifySameType enforces that every element unparceled from a Parcel has exactly the same concrete class as the first element (the declared list element type). A mixed-type list would break the typed List<T> contract, so an IllegalArgumentException naming actual vs expected type is thrown.","triggerScenarios":"Reading a BaseParceledListSlice/ListSlice from a Parcel where a subsequent element's CREATOR returns a different class than the first element's class — i.e. the sender wrote heterogeneous types, or an older/newer process version writes a changed element class mid-list.","commonSituations":"IPC between app and system/server code at different versions where the slice's element class changed; custom ParcelableCreators that return subclasses; corrupted or hand-crafted parcels.","solutions":["Ensure all elements written to the slice are instances of the exact same class (no subclasses with their own CREATOR)","Synchronize the element Parcelable class across both sides of the IPC (same app/library version)","If heterogeneous types are needed, wrap them in a common envelope Parcelable type"],"exampleFix":"// before: mixing types in one slice\nslice.append(new Item(...)); slice.append(new SpecialItem(...)); // throws on read\n// after: single element type, or a common wrapper\nslice.append(new Item(...)); slice.append(Item.from(special));","handlingStrategy":"try-catch","validationCode":"// Sender side: assert homogeneity before writing\nfor (Object o : list) {\n    if (o.getClass() != list.get(0).getClass())\n        throw new IllegalArgumentException(\"Mixed types in slice: \" + o.getClass());\n}","typeGuard":"boolean isHomogeneousList(List<?> list) {\n    return list.isEmpty() || list.stream().allMatch(o -> o.getClass() == list.get(0).getClass());\n}","tryCatchPattern":"try {\n    List<T> items = slice.getList();\n} catch (IllegalArgumentException e) {\n    Log.e(TAG, \"Slice type mismatch across IPC — check version skew\", e);\n    items = Collections.emptyList();\n}","preventionTips":["Never mix subclasses with distinct CREATORs in one parceled list","Keep parcelable element classes in sync across both IPC sides","Use a common wrapper type for heterogeneous payloads"],"tags":["parcel","android","ipc","serialization"],"backgroundTag":"type-mismatch","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}