We have a following setup:
a managed package pkg_a which provides a global virtual class Cls_A to be extended
a managed package pkg_b which contains a global class Cls_B that extends pkg_a.Cls_A
a static method in pkg_a's class which tries to retrieve a Type given its full name:
public static Type findType(String fullName) { if (String.isBlank(fullName)) { return null; } Type foundType = Type.forName(fullName); if (foundType == null) { // now try to find it locally without package prefix foundType = Type.forName('', fullName); // try with package prefix if (foundType == null && fullName.contains('.')) { List<String> splitStr = fullName.split('\\.', 2); String namespace = splitStr[0]; String className = splitStr[1]; foundType = Type.forName(namespace, className); } } return foundType; }
When this method is called within pkg_a context:
Type t = MyClass.findType('pkg_b.Cls_B');
it returns null for some reason. Does anyone know what are the possible reasons for this? Why wouldn't one managed package see a global class from another managed package, especially if this other class is extending package's own class?
What was checked so far:
pkg_b.Cls_B is set to depend on the latest version of pkg_a
Cls_B methods are public
user running the pkg_a process which calls the findType() method has a System Adminstrator profile with access to all classes and packages, so it's unlikely that it's a permissions problem
the most puzzling bit: this behaviour was noticed on an Enterprise edition org; on dev orgs everything works correctly