Unless the managed package class implements Salesforce's nasty** Callable interface you cannot do anything dynamic with the managed package class other than use the Type methods, including Type.newInstance (and that assumes there's a default constructor available for use).
Everything else must be static as mentioned by @metasync.
You could isolate the static invocations within some form of "adapter" class you provide if entirely essential. This would isolate the specific static uses from most of your own code.
If you are doing this to remove an installation/deployment dependency on that managed package for your code, you're out of luck. However, if you are developing a package yourself, you could ensure that your "adapter" API is an interface or abstract class and have the implementation of this that calls through to this other managed package class outside your package and thus installed on/deployed to the org separately compared with your package. Your package would need to instantiate this implementation from a string of the implementation's class name via Type.forName(...).newInstance()
. This approach is called Dependency Injection, where the dependency is separated out to configuration.
**: This Callable interface is a "quick hack" in Salesforce to introduce a common API that can be used for arbitrary method invocations, rather than providing effective Reflection capabilities in the language similar to those available in Java.
It is nasty because:
- There is no method discovery. You cannot discover which methods are supported, what parameters they take and what types they return.
- There is no type safety.
As an ISV product architect I would not want to touch this API if I can avoid it.