IncompatibleClassChangeError thrown by my extensions

gnuite's Avatar

gnuite

17 Nov, 2023 05:29 AM

After upgrading to Moneydance Version 5052, at least one of my own (home-grown) extensions is now throwing IncompatibleClassChangeError exceptions, in one case because com.infinitekind.moneydance.model.AcctFilter is not an interface. In the version of the developer's kit linked at https://infinitekind.com/developer (version 5.1), AcctFilter is indeed an interface. So it sounds like that has changed.

Is there a newer version of the developer's kit, so that I can recompile my extensions? If so, how do I acquire that newer version?

  1. 1 Posted by dtd on 17 Nov, 2023 05:35 AM

    dtd's Avatar

    I don't know the answer, but yes, I think AcctFilter changed for some reason.

    Someone like Stuart could help you, as I saw he changed a lot of his extensions to cover this (and changed a couple of abandoned extensions as well...)

  2. 2 Posted by dtd on 17 Nov, 2023 05:46 AM

    dtd's Avatar

    yogi1967 is Stuart:

    extension_development
    APP Aug 30th at 6:00 AM
    5 new commits pushed to main by yogi1967
    d42bde05 - Updating build file for ratios...
    45ba5058 - Updating ratios extension to fix the recent AcctFilter fix for MD2023.2(5008+)...
    f1c83a9d - Updating debtinsights extension to fix the recent AcctFilter fix for MD2023.2(5008+)...
    b6fa909f - Updating findandreplace extension to fix the recent AcctFilter fix for MD2023.2(5008+)...

  3. 3 Posted by Stuart Beesley ... on 17 Nov, 2023 07:23 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    To make it work pre/post 5007 you will need to do something like this and override all the methods. Instead of using AcctFilter() use:

    new DefaultAcctSearch() {
    
        @Override
        public boolean matches(Account account) { return x; }
    
        @Override
        public String format(Account account) { return z; }
    }
    

    Basically, because DefaultAcctSearch implements AcctFilter, it can be passed to things that require AcctFilter

  4. 4 Posted by gnuite on 17 Nov, 2023 10:18 PM

    gnuite's Avatar

    Thanks, Stuart. Sounds easy enough. But what is DefaultAcctSearch? I don't see it in the API of the developer's kit v5.1.

  5. 5 Posted by Stuart Beesley ... on 17 Nov, 2023 10:35 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Fair point. But this is a trick to give you some forward/backwards compatible code..

    Just import it from:
    com.moneydance.apps.md.view.gui

    It basically extends/implements AcctFilter and adds some convenience methods. But these are irrelevant as the code I gave you completely overrides the methods you need.

    Try it.

  6. 6 Posted by Stuart Beesley ... on 17 Nov, 2023 10:37 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Ps. I don’t know if this class is in the devkit (model) jar… if not, you might have to supply a full Moneydance.jar to compile.

  7. 7 Posted by gnuite on 18 Nov, 2023 12:29 AM

    gnuite's Avatar

    Ah, I see. That's why I couldn't find it. Compiling against moneydance.jar seems a bit of a hack (and will require me to upgrade my toolchain to JDK 17). But maybe it's better than nothing.

    Surely there must be a more "ordained" solution. Maybe they're waiting for 5007+ to go public (non-preview) before releasing the new dev kit? I wonder if there's a way to gain early access?

    Or, I guess I could just downgrade to non-preview and just be patient.

  8. 8 Posted by Stuart Beesley ... on 18 Nov, 2023 07:17 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    There’s lots of ways to fix it. How are you actually using AcctFilter?

  9. 9 Posted by gnuite on 18 Nov, 2023 07:28 AM

    gnuite's Avatar

    Anonymously in a call to Account.getSubAccounts:

        List<Account> accounts = rootAcct.getSubAccounts(new AcctFilter() {
          @Override public boolean matches(Account acct) {
            ...
          }
          @Override public String format(Account acct) {
            ...
          }
        });
    

    Is there a sanctioned way to do this in v5007+ ?

  10. 10 Posted by Stuart Beesley ... on 18 Nov, 2023 07:35 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    For example, if you were using allMatchesForSearch() on oldFilter, then something like this..

    newList = []
    acctList = AccountUtil.allMatchesForSearch(book, AcctFilter.ALL_ACCOUNTS_FILTER)
    for acct in acctList:
     if oldFilter.matches(acct):
        newList.append(acct)
    

    (Sorry, you’ll have to Java-ise the syntax)

    Then newList matches your previous result. This will compile with model api and work forwards/backwards.

    I wouldn’t wait for a new model api….

  11. 11 Posted by gnuite on 18 Nov, 2023 07:45 AM

    gnuite's Avatar

    Ah, so you're suggesting that I just stop using AcctFilter (and getSubAccounts) completely, and just do the filtering myself manually?

    If there's no hope for a new dev kit, and if the old API is going away, then yeah, I guess that's probably my best option.

    Thanks for all your help. :)

  12. 12 Posted by Stuart Beesley ... on 18 Nov, 2023 07:47 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Ah ok. Here is that code:

        public final List<Account> getSubAccounts(@NotNull AcctFilter search) {
            List accounts = new ArrayList();
            Iterator<Account> it = AccountUtil.Companion.getAccountIterator(this);
            while (it.hasNext()) {
                Account subacct;
                if (!search.matches(subacct)) continue;
                accounts.add(subacct);
            }
            return accounts;
        }
    

    So perhaps make your own version…

    Or:

    accounts = new ArrayList()
    for acct in acctRef.getSubAccounts():    // no parameters
      if acct rules match what I want then:
        accounts.append(acct)
    
  13. 13 Posted by Stuart Beesley ... on 18 Nov, 2023 07:48 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Correct. AcctFilter cannot be made backwards/forwards compatible. The developer tried. So you either pick a version and compile against that, or change the usage completely.

  14. 14 Posted by Stuart Beesley ... on 18 Nov, 2023 08:42 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    To clarify…

    You can still use

    Account.getSubAccounts()

    With no parameters for all sub accounts. Then iterate that list..

  15. 15 Posted by Stuart Beesley ... on 21 Nov, 2023 12:12 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    I just spotted:
    com.infinitekind.moneydance.model.BaseAcctFilter
    which also extends AcctFilter. It appears to be in the model code.
    I haven’t tested it but perhaps it’s a better solution to using DefaultAcctSearch?

  16. 16 Posted by gnuite on 21 Nov, 2023 05:47 PM

    gnuite's Avatar

    Sounds perfect - but I don't see it in the v5.1 dev kit. Is it in a newer version of the dev kit, or in the larger moneydance.jar ?

  17. 17 Posted by Stuart Beesley ... on 21 Nov, 2023 07:36 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    No. Sorry. I’ve checked.
    a) it’s private
    b) it’s new

    So of no help.

  18. 18 Posted by gnuite on 29 Nov, 2023 09:30 PM

    gnuite's Avatar

    The new Build 5061 includes "Various tweaks to maintain compatibility with pre-2023.2 extensions." I wonder if that addressed the AcctFilter change.

    I already worked around it by reimplementing getSubAccounts (per Stuart's suggestion), but I'm curious.

  19. 19 Posted by Stuart Beesley ... on 29 Nov, 2023 09:42 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Nope. It just stops old extensions that were using AcctFilter from crashing MD. It doesn’t fix your issue and no it’s still not forwards / backwards compatible.

  20. System closed this discussion on 28 Feb, 2024 09:50 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac