Fix error when serialize native code