{"record":{"id":"91463c17723a5974","repo":"MuntashirAkon/AppManager","slug":"illegalaccessexception-when-unmarshalling-name","errorCode":null,"errorMessage":"IllegalAccessException when unmarshalling: \" + name","messagePattern":"IllegalAccessException when unmarshalling: \" \\+ name","errorType":"exception","errorClass":"BadParcelableException","httpStatus":null,"severity":"error","filePath":"libcore/io/src/main/java/aosp/android/content/pm/ParcelUtils.java","lineNumber":81,"sourceCode":"                                + \"class implements Parcelable\");\n                    }\n                    Field f = parcelableClass.getField(\"CREATOR\");\n                    if ((f.getModifiers() & Modifier.STATIC) == 0) {\n                        throw new BadParcelableException(\"Parcelable protocol requires \"\n                                + \"the CREATOR object to be static on class \" + name);\n                    }\n                    Class<?> creatorType = f.getType();\n                    if (!Parcelable.Creator.class.isAssignableFrom(creatorType)) {\n                        // Fail before calling Field.get(), not after, to avoid initializing\n                        // parcelableClass unnecessarily.\n                        throw new BadParcelableException(\"Parcelable protocol requires a \"\n                                + \"Parcelable.Creator object called \"\n                                + \"CREATOR on class \" + name);\n                    }\n                    creator = (Parcelable.Creator<?>) f.get(null);\n                } catch (IllegalAccessException e) {\n                    Log.e(TAG, \"Illegal access when unmarshalling: \" + name, e);\n                    throw new BadParcelableException(\n                            \"IllegalAccessException when unmarshalling: \" + name);\n                } catch (ClassNotFoundException e) {\n                    Log.e(TAG, \"Class not found when unmarshalling: \" + name, e);\n                    throw new BadParcelableException(\"ClassNotFoundException when unmarshalling: \" + name);\n                } catch (NoSuchFieldException e) {\n                    throw new BadParcelableException(\"Parcelable protocol requires a \"\n                            + \"Parcelable.Creator object called \"\n                            + \"CREATOR on class \" + name);\n                }\n                if (creator == null) {\n                    throw new BadParcelableException(\"Parcelable protocol requires a \"\n                            + \"non-null Parcelable.Creator object called \"\n                            + \"CREATOR on class \" + name);\n                }\n                map.put(name, creator);\n            }\n        }\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/io/src/main/java/aosp/android/content/pm/ParcelUtils.java#L63-L99","documentation":"When reflectively reading the CREATOR field via Field.get(null), an IllegalAccessException can occur if the field is not accessible; ParcelUtils logs the underlying exception and rethrows it as a BadParcelableException.","triggerScenarios":"The named class's CREATOR field exists but is non-public (e.g. package-private or protected), and reflection cannot access it from ParcelUtils' context.","commonSituations":"Hidden/restricted APIs on newer Android versions (blocklist reflection); CREATOR accidentally given default visibility; obfuscation tools (ProGuard/R8) changing visibility.","solutions":["Make the CREATOR field public","Check ProGuard/R8 keep rules so visibility of CREATOR is preserved (-keepclassmembers with public static CREATOR)","Verify the class isn't on the hidden-API blocklist for the target Android version"],"exampleFix":"// before\nstatic final Parcelable.Creator<MyData> CREATOR = ...;\n// after\npublic static final Parcelable.Creator<MyData> CREATOR = ...;\n// proguard\n-keepclassmembers class * implements android.os.Parcelable { public static ** CREATOR; }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    T p = ParcelUtils.readParcelable(parcel, loader);\n} catch (BadParcelableException e) {\n    if (e.getCause() instanceof IllegalAccessException) {\n        Log.e(TAG, \"CREATOR not accessible — check visibility/keep rules\", e);\n    }\n}","preventionTips":["Make CREATOR public","Add ProGuard/R8 keepclassmembers rules for Parcelable CREATOR fields","Test parcel round-trips under minified release builds"],"tags":["parcel","android","reflection","access"],"backgroundTag":"reflection-access-denied","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"}