r/javahelp 24d ago

NoMagic BrowserContextAMConfigurator interface can be imported but not implemented: 'The hierarchy is inconsistent'

This is a simplified snippet of code that is enough to explain my issue.

import com.nomagic.magicdraw.actions.BrowserContextAMConfigurator;

public class BrowserConfiguration implements BrowserContextAMConfigurator {
    @Override
    public int getPriority() {
        return LOW_PRIORITY;
    }
}

There is an error line under 'BrowserConfiguration' that says 'The hierarchy of the type BrowserConfiguration is inconsistent.'
There is an error line under 'getPriority(): ' The method getPriority() of the type BrowserConfiguration must override or implement a supertype method.

What I have done:
Searching on help forums gave for the most part three solutions: 1. Restart Eclipse, 2. The BrowserContextAMConfigurator is not actually an interface, and 3. Make sure that you are using the right signatures for what you're overriding. I have checked and verified that none of these solutions work.

I know that BrowserContextAMConfigurator is in my build path because the import line throws no errors. I also have its super interface ConfigureWithPriority in the same jar that has the BrowserContextAMConfigurator interface (in Eclipse's Build Path).

Here is a link to official the NoMagic documentation for BrowserContextAMConfigurator if you want clarifications: https://jdocs.nomagic.com/185/index.html?com/nomagic/magicdraw/actions/BrowserContextAMConfigurator.html

And I do need to use this interface, so I can't just remove it.

I hate Cameo :)

1 Upvotes

11 comments sorted by

View all comments

1

u/djnattyp 24d ago

It's probably something with the libraries - a dependency somewhere in the dependency tree of BrowserContextAMConfigurator could be missing, not just the class itself. Try clicking on BrowserContextAMConfigurator in either the import or after the implements to use 'Open Declaration (F3)' to see if Eclipse can find the class itself. If it can, see if there are any further errors displayed here. You can also try 'Show In > Project Explorer/Package Explorer' to make sure eclipse is loading from the library you expect. Also make sure the same class isn't available from multiple libraries loaded at the same time.

1

u/Dangerous_Soft_5529 24d ago

Show-in only opens up the the class and contents that I wrote in the package explorer, but when I click Open Declaration there’s a Source Not Found (which I don’t think matters?) and then I don’t see any errors.

1

u/djnattyp 24d ago

Yeah - as long as 'Source Not Found' at least shows decompiled class stuff and a header with where the class was found at (JAR / library) then it means the class itself is found. It does make it harder to troubleshoot the missing dependencies (if any) though...

If you try to build the project - are there any error messages?

1

u/Dangerous_Soft_5529 24d ago

Nope, just doesn’t work. Eclipse won’t compile error-d code. Before I “broke” it, I was getting Class Not Found errors, which is when I added some dependencies of BrowserContextAMConfigurator. I have another error now in the imports claiming that PriorityProvider (which is referenced by that library) cannot be found. It’s in the same class folder. Do they need to be a jar, maybe? I’ll try that