In a managed package I have a global interface and some code that accepts a string as input (which should be a class name).

Will this managed code be able to instantiate an Apex type that is outside of the package's namespace such as, for example, a class that was written by the subscriber?

1 Answer 1


The global keyword works both ways in this situation.

For the interface to be accessible by the subscriber, it should be global (so that the managed code can use it in a context that is managed by the subscriber).

And for your package's code to be able to instantiate it, it should be able to "see" outside its boundaries as well, so the type instantiated should also be declared as global.

  • 3
    One interesting point to note: if your class outside the package is global and implements a package interface's methods or overrides/implements a package virtual or abstract class's methods, those method implementations outside the package do NOT need to be global and can be just public.
    – Phil W
    Commented Nov 19, 2020 at 21:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .