Avoid passing class pointers to some marshal icalls since its not aot compatible. Fixes #12595.