I have a class MyClass that has a method getId() with return type Long. I am using it with optaplanner. I create a solver factory from a resource file and build a solver.
SolverFactory solverFactory = SolverFactory.createFromXmlResource("/path/to/config");
Solver solve = solverFactory.buildSolver();
When buildSolver() is executed, I see the warning
Getter overloading detected in class mypackage.MyClass : getId (class java.lang.Object) vs getId (class java.lang.Long)
I am wondering where optaplanner finds the method getId() with return type Object. It is nowhere in the source code!
EDIT
As pointed out in the comments, the warning could also mean, that drools has found two methods: getId(Object) and getId(Long). This is even more suspicious, since I did not define a getId method that takes any parameters.
UPDATE
I have investigated the class https://github.com/kiegroup/drools/blob/master/drools-core/src/main/java/org/drools/core/util/asm/ClassFieldInspector.java in the version that I have on my machine using the maven dependency
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-benchmark</artifactId>
<version>6.4.0.Final</version>
</dependency>
When the ClassFieldInspector is instanciated with classUnderInspection equals "mypackage.MyClass", then the list of methods
final List<Method> methods = Arrays.asList( clazz.getMethods() );
does indeed contain two methods called getId():
- "public java.lang.Long mypackage.myClass.getId()"
- "public java.lang.Object mypackage.myClass.getId()"