Search code examples
javaoptaplanner

OptaPlanner, why break point is not hit when debugging example


New to OptaPlanner and want to debug the example Task Assigning in Eclipse to learn. Found that the breakpoints are hit only when the code are called by the UI related code, such as

org.optaplanner.examples.taskassigning.domain.Affinity(int durationMultiplier)
org.optaplanner.examples.taskassigning.domain.TaskAssigningSolution.getEmployeeList()

when set breakpoint at:

org.optaplanner.examples.taskassigning.domain.TaskAssigningSolution.setEmployeeList(List<Employee> employeeList)

it won't be hit. My questions are, why the breakpoints are not hit? how can the breakpoints be hit?


Solution

  • A solution like TaskAssigningSolution is planning cloned (see docs for what this is) through reflection on the fields. See FieldAccessingSolutionCloner. You can write your own solution cloner to avoid that behavior (but that's very error prone to write correctly).

    We have a RFE running to support something like accessFieldsThroughGetterSetters=true to be more JDK 17 friendly, which will force OptaPlanner never to use field access for non-public fields.