Why does this work?
AssetManager* am = (AssetManager*)env->GetIntField(obj, gAssetManagerOffsets.mObject);
env->env->GetIntField() returns an Int. Why can it be converted to an AssetManager? This code is from the file android_util_AssetManager.cpp.
The int being returned is a pointer to an AssetManager. The
(AssetManager*)tells you that it’s a pointer to an AssetManager.So, it’s returning an int, which happens to be a pointer to an AssetManager. It’s not returning an AssetManager.
This Tutorial on Arrays and Pointers in C might help you. Chapter 5 shows the syntax you’re seeing in the code you mentioned.