Skip to content
Advertisement

Intellij cannot resolve method even though it is public (Java)

I have googled this a lot, invalidated the cache, and I can’t seem to find an answer. For background, this is a timetabling system using constraint solving. I have a custom class called Period with public methods getStart() and getEnd(). I also have an abstract class Constraint<V, D> and a subclass DemAvailConstratint<Demonstrator, Period>. It is in this subclass (and similarly in another one) where the methods in Period and Demonstrator cannot be resolved.

In DemAvailConstraint the methods showing the error are getStart() and getEnd() when called on this.period but not when called on other Period objects. Similarly, it happens with isAvailable() when called on this.getDemonstrator() in the satisfied() method. This is a public method in Demonstrator. Any idea why this would happen?

Here are the classes (with some methods removed for clarity):

JavaScript
JavaScript
JavaScript

Advertisement

Answer

After all sorts of attempts at invalidating the cache, changing the JDK etc., I have deleted the <Demonstrator, Period> part in the DemAvailConstraint class declaration. I think I know why this worked. Adding that piece of code made Demonstrator and Period into placeholder types rather than referring to my custom classes. This is why the class couldn’t access my methods. I have kept the placeholder code <V, D> (variable and domain) in the abstract class Constraint, and I’m now wondering if I actually need to specify those types in the subclass.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement