Recently, Salesforce came out with a critical update to Restrict Reflective Access to Non-Global Constructors in Packages. The update is active in my org. My code uses Type.newInstance
. I'm a bit confused as to why my code is not throwing the error as per the description provided by the critical update.
This is the code structure I have :
public abstract class AbstractClass {
//some methods + abstract methods
}
public class IWillExtendAbstractClass extends AbstractClass {
//all abstract methods implemented etc
}
Now I execute the following in anonymous window in dev console (expecting an error to show up for instantiating an abstract class)
AbstractClass obj = (AbstractClass) Type.forName('IWillExtendAbstractClass').newInstance();
I thought this line instantiated an abstract class but since it ran, I sense a gap in my understanding. Can someone explain what this line is doing and give an example for when the error message ApexType does not have a no-arg constructor
will show up as per the details of this critical update? Where will this critical update impact the most?