19

My understanding from the docs is that apex class and method names are case-insensitive.

I've run across an edge-case with interfaces and abstract classes which appears to be undocumented behavior where it is case-sensitive. The following 3 stub classes reproduce the issue which I believe is a compiler bug.

Base Interface

public interface overrideInterface {
    void camelCase();
}

Abstract Class

public abstract class SL_override implements overrideInterface{
    public virtual void camelCase() {
        system.debug('should never run.');
    }
}

Class to Run

public class SL_newOverride extends SL_Override {
    //capital A
    public override void camelCAse(){
        system.debug('will never run.');
    }
}

Anonymous Apex

SL_newOverride foo = new SL_newOverride();
foo.camelCase();

If you run this anonymous apex it appears to never enter the methods and errors out:

Error on line -1, column -1: System.LimitException: Maximum stack depth reached: 1001
External entry point
External entry point
External entry point
External entry point
External entry point
External entry point
External entry point
External entry point
...
  • 4
    You haven't opened a case for this by chance, have you? – ca_peterson Jun 12 '18 at 1:42
  • @ca_peterson, not yet. Wanted to make sure I wasn't missing something obvious before going through the exercise. – Greg Grinberg Jun 12 '18 at 3:08
  • I'm not able to reproduce this myself - my attempt debugs the expected value from the concrete implementation class - not anything like a infinite recursion issue. Are you sure there's not more to this issue? – ca_peterson Jun 12 '18 at 21:26
  • @GregGrinberg can you capture the Apex debug log when the problem occurs. Set the Apex Code log level to FINE, FINER, or FINEST. Can you also check the API versions on all three classes and that the ApexClass Id's are lining up with the Id's showing in the log. – Daniel Ballinger Jun 12 '18 at 21:44
  • 1
    BTW it's only reproducible if you have the extension SL_newOverride as a top-level class. I tried extending a top-level by a nested, extend nested by nested and nested by top-level. And it only behaves that way when you extending whatever by a top-level class – blank Aug 19 '18 at 16:09
0

This is an unique case. I tried your code and got the same stack depth error. But I play around with the method name and what I observed that not all the combinations of Upper-case and Lower-case letters in the method name are behaving in the same way. For example, I changed the Interface class method name as follows

    public interface overrideInterface {
    void camelcaSE();
    void METHOD2();
}

Then I change the Abstract Class method name as follows

public abstract class SL_override implements overrideInterface{

     public virtual void camelCase() {
        system.debug('should never run.');
    }
      public virtual void Method2() {
        system.debug('Abstract class Method2() display- Interface method name - METHOD2()');
    }
}

Then I changed the method name in the child class as follows

public class SL_newOverride extends SL_Override {

    public override void camelcASE(){
        super.camelcase();
        system.debug('will never run.');
    }

    public override void metHod2(){
        super.method2();
        system.debug('method2 display.');
    }
}

Then I invoke and execute the child class through anonymous apex as follows

SL_newOverride foo = new SL_newOverride();
foo.camelCasE();

And it works fine. The only situation the case-sensitivity is becoming the issue is camelCAse(). Otherwise, I don't think the Apex naming convention is case-sensitive. The proof is with the second method name Method2 which I declared in the interface class and overridden in the abstract and child classes.

SL_newOverride foo = new SL_newOverride();
foo.camelCasE();
foo.Method2();

So we can't conclude that Salesforce Apex class methods are case sensitive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.