icecreamhead
icecreamhead

Reputation: 121

Why is IntelliJ saying that a class constructor is incorrect despite compiling?

I'm trying to instantiate an object using a class in an external jar. This is a jar that a team-member is developing and recently changed the interface methods.

The problem is that IntelliJ still thinks class constructor should take 4 arguments (the old interface) rather than 3 (new interface).

I can guarantee that the jar in the module dependencies is the new version. This is further confirmed by the fact that the code does successfully compile.

So my question is, why does IntelliJ still think I should have the old interface? Does it have some sort of cache that is not updating properly?

Attached screenshot demonstrates the problem.

Thanks.

Interface Error Screenshot

Upvotes: 1

Views: 1545

Answers (4)

chenyi1976
chenyi1976

Reputation: 1122

try move the cursor in the constructor, then press ctrl + b, it will jump to the declaration of constructor, which will get you a chance to double check if the constructor is correct or not.

also you can try "invalidate cache" under "file" menu, this will clear cache and rebuild index for your project.

enter image description here

Upvotes: 1

Oleg Mihailenko
Oleg Mihailenko

Reputation: 91

You can also remove all files from folders caches and index located for example here c:\Documents and Settings\User.IntelliJIdea\system\ (of course you may have another path) and try to start IDE again.

Upvotes: 1

Bohemian
Bohemian

Reputation: 425083

Right-click on your project and select Refresh. Your project is using the compiled jar, which has changed, but your IDE is still using the old compiled jar as it was when it loaded it (even though the new source may be visible in the relevant project).

Eclipse has the same issue.

Upvotes: 2

Péter Török
Péter Török

Reputation: 116266

Possibly IntelliJ's indexing info is out of date as it didn't notice that you switched a jar dependency.

This may be resolved at least by restarting the IDE, which then rescans and rebuilds indexes.

Upvotes: 1

Related Questions