0

After adding a new inner class to a controller I get the following error when trying to save.

Compile Error: The configuration of your org has changed, please reload the page. Missing dependent object: Type: PackageNamespace.OuterClass: InnerClass at line -1 column -1

The controller in question already contains 4 other inner classes and an enum definition. Why would adding one more inner class cause a compile error?

The inner class is nothing special. It will be expanded on to include methods for working with a collection of custom objects:

public class InnerClass {

    public List<CustomObject__c> toUpsert { get; set; }

    public InnerClass() {
        toUpsert = new List<CustomObject__c>();
    }

    public integer size() {
        return toUpsert.size();
    }

    public void add(CustomObject__c pcd) {
        toUpsert.add(pcd);
    }       
}

I've done a Compile all Classes but the save/compile error still persists.

1 Answer 1

1

The Apex compiler is not always very smart at resolving cross references. When you add an inner class and then -- before saving -- write code that references it or its methods/properties elsewhere within the outer class code, then you are very likely to see this compilation error. It's not your fault, but to workaround it you should remove the inner class references (comment them out) and save a version of your outer class with just the inner class's shell defined (also leave its methods defined when possible): public class InnerClass { }. That will get the inner class's definition "up into the cloud"; now you can uncomment your code and should be able to save successfully on a subsequent attempt.

Also, the Force.com IDE's "Deploy to Server" seems more robust than single-file Apex class saves, though I can't say off of memory whether it would handle this particular kind of scenario.

1
  • In the end I gave up on the inner class and created an entirely separate class. I took it as a warning that the class was getting too complicated. Commented Aug 9, 2013 at 1:52

You must log in to answer this question.

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