The best fix would be to rename the classes so that they are unique. Typically, a naming convention would be used to ensure uniqueness, such as ‘pkg_name_class_name’.
If this can’t be accomplish, then you won’t be able to use string-based lookups. This normally isn’t an issue as you would typically refer to the class based on it’s type.