Illuminated Cloud 2 Offline Debugger not working when using polymorphism/inheritance

Issue #1494 resolved
Dimitar Zahariev created an issue

There is a bug in the offline debugger of Illuminated Cloud 2 when using inheritance/polymorphism.

Polymorphism bug

Steps to reproduce:

  1. Make the following items.

GenericProperty (Apex class)

public abstract class GenericProperty {

  public void genericActionMethod() {
    Integer someSum = 5 + 8;
    Integer someSum2 = 10 + 11;
  }

  public Integer getGenericGetter() {
      Integer someSum = 12 + 14;
      Integer someSum2 = 15 + 17;

      return someSum + someSum2;
  }
}

ConcreteProperty (Apex class)

public class ConcreteProperty extends GenericProperty {
}

AccountExtension (Apex class)

public class AccountExtension {
  public AccountExtension(ApexPages.StandardController stdController) {
    this.ConcreteProperty = new ConcreteProperty();
  }

  public GenericProperty GenericProperty {
      get { return ConcreteProperty; }
  }

  private ConcreteProperty ConcreteProperty;

}

AccountPage (Visualforce page)

<apex:page standardController="Account" extensions="AccountExtension">
  <apex:form>
        <apex:commandButton value="Call genericActionMethod" action="{!GenericProperty.genericActionMethod}"/>

        {!GenericProperty.genericGetter}
  </apex:form>
</apex:page>

  1. Override the standard account page with the one you created
  2. Change all your log levels to FINEST
  3. Put breakpoint on the genericActionMethod and getGenericGetter
  4. Open the account tab (A log will get generated)
  5. Try to debug it using Illuminated Cloud's offline debugger
    The moment when you hit the breakpoint of the method, try to Step over/Step into the method, the logs regarding the method will get dumped in the console tab, and this method will be skipped.
  6. Press the "Call genericActionMethod" button (A log will get generated)
  7. Repeat step 5. (The result is the same)

Inheritance bug

The code is a little bit different but steps are the same.

GenericProperty (Apex class)

public abstract class GenericProperty {

  public void genericActionMethod() {
    Integer someSum = 5 + 8;
    Integer someSum2 = 10 + 11;
  }

  public Integer getGenericGetter() {
      Integer someSum = 12 + 14;
      Integer someSum2 = 15 + 17;

      return someSum + someSum2;
  }
}

ConcreteProperty (Apex class)

public class ConcreteProperty extends GenericProperty {
}

AccountExtension (Apex class)

public class AccountExtension {
  public AccountExtension(ApexPages.StandardController stdController) {
    this.ConcreteProperty = new ConcreteProperty();
  }

  public ConcreteProperty ConcreteProperty { get; private set; }
}

AccountPage (Visualforce page)

<apex:page standardController="Account" extensions="AccountExtension">
  <apex:form>
      <apex:commandButton value="Call genericActionMethod" action="{!ConcreteProperty.genericActionMethod}"/>
      {!ConcreteProperty.genericGetter}
  </apex:form>
</apex:page>

Workaround 1: mark genericActionMethod and getGenericGetter as virtual, override them in the subclasses and call their corresponding methods from their parent classes.

GenericProperty

public abstract class GenericProperty {
    public virtual void genericActionMethod() {
        Integer someSum = 5 + 8;
        Integer someSum2 = 10 + 11;
    }

    public virtual Integer getGenericGetter() {
        Integer someSum = 12 + 14;
        Integer someSum2 = 15 + 17;

        return someSum + someSum2;
    }
}

ConcreteProperty

public class ConcreteProperty extends GenericProperty {
    public override void genericActionMethod() {
        super.genericActionMethod();
    }

    public override Integer getGenericGetter() {
        return super.getGenericGetter();
    }
}

Workaround 2: don't use polymorphism or inheritance

Possible cause: From my research, I guess that what’s happening is that when polymorphism/inheritance is used, Illuminated Cloud’s debugger searches for the method in the subclass, but since it can’t find it there it just dumps the log to the Console.

Further Investigation

I even tried simplifying the POC (thought it could be because of the properties):

GenericProperty

public abstract class GenericProperty {
  public void genericActionMethod() {
    Integer someSum = 5 + 8;
    Integer someSum2 = 10 + 11;
  }

  public Integer getGenericGetter() {
      Integer someSum = 12 + 14;
      Integer someSum2 = 15 + 17;

      return someSum + someSum2;
  }
}

AccountExtension

public class AccountExtension extends GenericProperty {
  public AccountExtension(ApexPages.StandardController stdController) {
  }
}

AccountPage

<apex:page standardController="Account" extensions="AccountExtension">
  <apex:form >
    <apex:commandButton value="Call genericActionMethod" action="{!genericActionMethod}"/>
    {!genericGetter}
  </apex:form>
</apex:page>

I've removed the ConcreteProperty class and the properties in the AccountExtension, despite that we still get the same result.

The software versions are shown in the screenshots.

Comments (8)

  1. Scott Wells repo owner

    Thanks for filing and for all of the details which allowed me to reproduce this successfully. I don't have the answer yet, but the issue seems to be due to a problem with parsing the log into the correct execution tree. There are nested VF_APEX_CALL_* entries:

    09:59:18.0 (47420640)|VF_APEX_CALL_START|[EXTERNAL]|01p2E00000BLD0s|AccountExtension get(GenericProperty)|AccountExtension
    09:59:18.0 (47479742)|VF_APEX_CALL_START|[EXTERNAL]|01p2E00000BLD0s|GenericProperty|AccountExtension
    09:59:18.0 (47633730)|VF_APEX_CALL_END|GenericProperty|AccountExtension
    09:59:18.0 (47655834)|VF_APEX_CALL_END|AccountExtension get(GenericProperty)|AccountExtension
    

    but the tree looks like:

    Issue_1494.png

    Notice that the internal VS_APEX_CALL_START/END pair isn't itself a new tree level though it should be.

    Hopefully once I fix that, all of this will work properly. I've also addressed a few other things encountered while debugging this such as being able to set a breakpoint/checkpoint on a single-line property accessor.

  2. Scott Wells repo owner

    Dimitar, please install the attached build and let me know whether it resolves the issue for you or not. I'm seeing the proper behavior now across the board.

    Download the attached archive then, without extracting it, use Settings/Preferences>Plugins>Install plugin from disk (under the gear drop-down menu) to install it.

    Please let me know how that goes.

  3. Log in to comment