Java error: Found interface … but class was expected

后端 未结 5 2065
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 00:55

I am getting a strange runtime error from my code:

\"Found interface [SomeInterface] but class was expected\"

How can this happen? How can an i

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 01:29

    I had the same problem. I use two jar libraries in my application. One library is built upon the other.

    The library A defines top classes and interfaces. Library B requires library A.

    This is pseudocode of some code used in library B:

    TheInterface instance = new TheClass();
    instance.someMethod();
    

    Apparently library A is newer than library B and TheInterface doesn't contain someMethod anymore, but TheClass still does. The only way to fix this is to get the source for either jar and change these things by hand (if at all possible).

提交回复
热议问题