Shadow Variable listeners called alphabetically instead of in order of declaration

Open
#680 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
ai

Research direction

The issue does not name a source file or test. Reproduce the ordering difference from the food-packaging quickstart, then trace how multiple ShadowVariable annotations are discovered and invoked. Done means listeners run in declaration order rather than alphabetical source-variable order, with coverage for the renamed-variable case.

Written by the indexing model from the issue text.

Description

process/needs triage

Describe the bug
When you have more than 1 Shadowvariable listeners on a variable, they are called alphabetically based on the source variable name.

Expected behavior
They are called in the order of declaration

Actual behavior
Describe clearly and concisely what actually happened.

To Reproduce
Taken from the food-packaging quickstart, this is the original

    @InverseRelationShadowVariable(sourceVariableName = "jobList")
    private Line line;
    @PreviousElementShadowVariable(sourceVariableName = "jobList")
    private Job previousJob;
   
    @ShadowVariable(variableListenerClass = StartDateTimeUpdatingVariableListener.class, sourceVariableName = "line")
    @ShadowVariable(variableListenerClass = StartDateTimeUpdatingVariableListener.class, sourceVariableName = "previousJob")
    private LocalDateTime startCleaningDateTime;

When you change it to e.g.

    @InverseRelationShadowVariable(sourceVariableName = "jobList")
    private Line technician;
    @PreviousElementShadowVariable(sourceVariableName = "jobList")
    private Job previousJob;
   
    @ShadowVariable(variableListenerClass = StartDateTimeUpdatingVariableListener.class, sourceVariableName = "technician")
    @ShadowVariable(variableListenerClass = StartDateTimeUpdatingVariableListener.class, sourceVariableName = "previousJob")
    private LocalDateTime startCleaningDateTime;

You will notice that the variable listener is called in another order (because technician comes alphabetically after `previousJob``

@ge0ffrey has an idea why it happens

Environment

Timefold Solver Version or Git ref:

Output of java -version:

Output of uname -a or ver:

Additional information

Related issue in quickstarts: https://github.com/TimefoldAI/timefold-quickstarts/issues/315

Dominant language
Java
Stars
1.8k
Forks
228
Avg merge
1d 13h
Merged PRs (30d)
46

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TimefoldAI/timefold-solver

All issues in TimefoldAI/timefold-solver

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.