function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Phil WPhil W 

Cannot deploy public sharing class extending public sharing virtual class

I have a Visualforce controller extension class that is working fine. However, I now need a second controller extension that shares some of the behaviour of the first. As such I have been trying to refactor the original controller extension, but have hit a problem.

The new base class provides some nested classes, public properties and some virtual (overridable) methods, something like:
​public with sharing virtual class MyExtensionBase {
    public class A {
        public String something { get; set; }
        public String somethingElse { get; set; }
    }

    public A myA { get; set; }

    public MyExtensionBase(Apex.StandardController ctrl) {
        myA = getA(ctrl);
    }

    protected virtual A getA(Apex.StandardController ctrl) {
        A anA = new A();
        ...
        return anA;
    }
}
I have then refactored the original controller extension to remove the nested class, the property and the initialization of the property, and to make it now extend the new base class, something like:
public with sharing class MyExtension extends MyExtensionBase {
    ...
    public MyExtension(ApexPages.StandardController ctrl) {
        // Allow the base class to perform its initialization
        super(ctrl);
        ...
    }
}
I can successfully deploy the base class. However, the refactored original controller extension will not deploy, with the following error:

ERROR deploying ApexClass classes/MyExtension.cls: An unexpected error occurred. Please include this ErrorId if you contact support: 515167826-28209 (-2057717022)

I cannot see what I've done wrong and cannot believe that this sort of code structure (and refactoring exercise) isn't common.

Has anyone else seen this sort of GACK raised in this sort of scenario?
Best Answer chosen by Phil W
Phil WPhil W

As an update, I did the following:

  1. Deploy new base class (success!)
  2. Empty out everything in the refactored original class and remove the inheritance from the base
  3. Deploy the (now empty) refactored original class (success!)
  4. Put everything back into the refactored original class
  5. Deploy the (now complete) refactored original class (success!!!)
Doing this allowed me to continue with my work and removed the GACK.