I think this logic belongs to ManagedStringFromJavaString, could you please augment the ManagedStringFromJavaString method with your null checking logic instead?