For some reason, I thought I'd see if interfaces support parameterization, as a matter of trying to optimize some code. Amazingly, the following code saved once:

public interface ITriggerHandler<T> {
    void handle();

And after trying to modify it, it would refuse to compile, stating that paramterization isn't supported. I also tried using:

public class AccountTriggerHandler implements ITriggerHandler<Account> {
    public void handle() { /* */ }

This refused to compile, stating that the dependent class was invalid and required re-compilation (parameterization isn't supported).

Perhaps I've found a glitch in the compiler?

  • 1
    Have you seen salesforce.stackexchange.com/questions/1214/…? It seems they've completely backed out of the generics (link to docs is dead, Winter'13 release note mentioned seems to not include the quote...). How about having an Object or SObject as the "generic type" to which you'd be assigning something at runtime? I think in terms of DML only upsert doesn't like generic sObjects...
    – eyescream
    Feb 25, 2014 at 21:28
  • 1
    It gets weirder. See also salesforce.stackexchange.com/questions/5133/… Feb 25, 2014 at 22:00
  • So v25 is supposed to support generics? I've been complaining about of a lack of support for generics since probably around v21 or so.
    – sfdcfox
    Feb 25, 2014 at 23:12

1 Answer 1


One of the reason what i could found is Apex is unable to type cast between sObject to Object or vice-versa.

So it results, unable to support generics because some how it can not find whether passed argument is sObject or Object. They both are isolated. Perhaps apex is unable to handle this scenario.

In addition, Interface taken as example is saved only once. If its parameter is edited to <Object> or some other it won't save and even if we change it again to previous state <T> it will refuse to save.

showing error: Itriggerhandler: line 1, column 18: type parameters not supported at line 1 column 47 interface

In summary we can say it is a some bug that it allow to save generic parameterized class to save but unable to re-save. Not supporting the generic type is hidden in between the isolation between sObject and Object. The way of Apex handle the top-level objects.

Hope it may clear some points.

You must log in to answer this question.

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