Recent posts:
Recent replies:

Thanks again for the code, it does exactly what I am looking for.  However, I have amended the code to list all of the abstract methods required to be implemented for the subclass in the error message.

Class User.Abstract.AbstractChecker
ClassMethod Check() As %Status [ CodeMode = objectgenerator, ForceGenerate ] {
    k absCheck
    #Dim sc As %Status = $$$OK
    // Get class name from %compiledclass object which is an instance of a currently compiled class
    Set class = %compiledclass.Name
    ; get the abstract methods
    set methodCnt=..FindAbstractMethods(class,.methods)
    ; check whether the abstract methods have been implemented
    set methodCnt=$order(methods(""),-1)
    for i=1:1:methodCnt {
        set method=methods(i)
           set origin = $$$comMemberKeyGet(class, $$$cCLASSmethod, method, $$$cMETHorigin)
           set errtext=$$$FormatText("%1 [abstract] (origin %2)", method,origin)
           ; build array of error messages
           set absCheck("AbsNotImp",$order(absCheck("AbsNotImp",""),-1)+1)=errtext
    ; if there are error messages build the error string
    set str=""
    if $data(absCheck("AbsNotImp")) {
        set ind="",ind=$order(absCheck("AbsNotImp",ind))
        while ind {
            set $piece(str,", ",ind)="("_ind_") "_$get(absCheck("AbsNotImp",ind))
            set ind=$order(absCheck("AbsNotImp",ind))
        set str="In class '"_class_"' the following "_$order(absCheck("AbsNotImp",""),-1)_" abstract classes are to be implemented: "_str
        set sc=$$$ERROR($$$GeneralError,str)
    quit $get(sc)

ClassMethod FindAbstractMethods(class As %String, ByRef methods As %String) As %Integer {
    kill methods
    // Iterate over class methods.
    // You can also use %class object to iterate
    Set method=$$$comMemberNext(class, $$$cCLASSmethod, "")
    While method'="" {
        // Get method abstract state
        Set abstract = $$$comMemberKeyGet(class, $$$cCLASSmethod, method, $$$cMETHabstract)
        if abstract{
            set methods($order(methods(""),-1)+1)=method
        Set method=$$$comMemberNext(class, $$$cCLASSmethod, method)
    quit +$order(methods(""),-1)


Many thanks for the code it does what I am looking for. Do you know if there are plans for the compiler to check for the implementation of abstract methods instead of having to inherit code to do this?

A couple of things I have noticed:

  • If the method is inherited in a Persistent class, it won't compile.
  • It looks as though it checks for the name of the abstract method but not the number of parameters the method requires.

But otherwise that is what I am looking for, I just have to remember to add the AbstractChecker to the inheritance list.

Thanks again.

Hi Jenna,

Thanks for your response.

Fully understand your response but unless I am doing something wrong, Cache does not seem to throw an error/warning if the subclass does not implement the abstract methods defined in the superclass.

My understanding is that inherited abstract methods in subclasses must be implemented (even if the implemented method is empty) to standardise class interfaces but in my code this does not seem to be being enforced.

Thanks again,


Ken has no followers yet.
Ken has not followed anybody yet.
Global Masters badges:
Ken has no Global Masters badges yet.