Restrict Reflective Access to Non-Global Constructors in Packages (Critical Update)

When this critical update is enabled, regardless of API version, you can initiate only Apex classes that have a no-arguments constructor that is visible to the code running Type.newInstance.

Where: This change applies to Lightning Experience and Salesforce Classic in Enterprise, Performance, Unlimited, and Developer editions.

When: This update is automatically enforced on August 18, 2020.

How: This critical update enables strict enforcement of Apex type visibility rules for the Type.newInstance method. It also removes the legacy compatibility behavior supporting these rules in API version 28.0 and earlier. Apex classes contained in second-generation packages can instantiate public classes from other packages in the same namespace only if they are annotated @NamespaceAccessible.

Also, regardless of API version, construction of abstract classes or interfaces is no longer allowed even when the type is visible and can be referenced using Type.forName. Such instantiation fails with this message: "ApexType does not have a no-arg constructor" where ApexType is the type you want to create using the Type.newInstance method.

To enable this feature programmatically with the Metadata API, see ApexSettings in the Metadata API Developer Guide.

Note

Note

Global classes are unchanged and remain available across all namespaces.