Skip to content

Fix Windows compile break in executor example by aligning LastShares quantity type (FIX 4.0/4.1/4.2)#1237

Merged
chrjohn merged 2 commits into
masterfrom
copilot/fix-windows-compile-failure
May 22, 2026
Merged

Fix Windows compile break in executor example by aligning LastShares quantity type (FIX 4.0/4.1/4.2)#1237
chrjohn merged 2 commits into
masterfrom
copilot/fix-windows-compile-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

Windows Java CI fails to compile quickfixj-examples-executor due to double values being passed to LastShares call sites that require int in the affected generated message APIs.
This change makes quantity handling type-correct at the three failing locations while preserving existing behavior in surrounding execution-report construction.

Error from the build job: (this happened only intermittently on Windows builds)

Application.java:[154,86] incompatible types: possible lossy conversion from double to int
Application.java:[252,37] incompatible types: possible lossy conversion from double to int
Application.java:[287,64] incompatible types: possible lossy conversion from double to int
  • Type correction in execution report fill paths

    • FIX 4.0: convert orderQty.getValue() once to int and pass to LastShares.
    • FIX 4.1: same adjustment in the fill ExecutionReport constructor path.
    • FIX 4.2: same adjustment for executionReport.set(new LastShares(...)).
  • Behavior preserved

    • CumQty, LastPx, and AvgPx paths remain unchanged.
    • Scope is limited to the compile-failing quantity usages only.
int lastShares = (int) orderQty.getValue();
executionReport.set(new LastShares(lastShares));
Original prompt

Fix the Windows compile failure in the quickfix-j/quickfixj repository caused by incompatible quantity types in quickfixj-examples/executor/src/main/java/quickfix/examples/executor/Application.java.

Context:

Compiler errors:

  • Application.java:[154,86] incompatible types: possible lossy conversion from double to int
  • Application.java:[252,37] incompatible types: possible lossy conversion from double to int
  • Application.java:[287,64] incompatible types: possible lossy conversion from double to int

Relevant file:

  • quickfixj-examples/executor/src/main/java/quickfix/examples/executor/Application.java

What to do:

  1. Update the code in Application.java to fix the compile errors by using the correct types for the affected FIX field constructors/setters.
  2. Inspect the generated field/class APIs used at those call sites so the fix matches the actual constructor/setter signatures in this codebase, instead of applying a blind cast if a better type-correct fix exists.
  3. Preserve existing behavior as much as possible. If explicit conversion is required, keep the change minimal and consistent across the affected FIX 4.0, 4.1, and 4.2 execution report code paths.
  4. Run or reason through the impacted build/test scope enough to ensure the module compiles.
  5. Create a pull request with a concise title and summary of the fix.

Goal:
Make the repository build pass again by correcting the quantity type usage in the executor example code.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failing job is a compile failure in quickfixj-examples/executor/src/main/java/quickfix/examples/executor/Application.java on Windows/JDK 8–21, in the workflow job defined by .github/workflows/maven.yml (test-windows, Maven install step). The actual failure is here:

  • Application.java:154
  • Application.java:252
  • Application.java:287

Source:

Root cause

The code passes double values into FIX field constructors that expect int-typed quantity values.

The errors line up with these calls:

new LastShares(orderQty.getValue())
new CumQty(orderQty.getValue())
new LastShares(orderQty.getValue())

orderQty.getValue() is a double, but in these FIX versions the corresponding field constructors expect an int, so Java reports:

incompatible types: possible lossy conversion from double to int

Fix

Use an explicit conversion before constructing LastShares/CumQty, or use the constructor/setter overload that matches the field type expected by the generated QuickFIX/J classes.

A minimal safe patch is to convert the quantity once and reuse it.

Suggested patch

// FIX 4.0
if (isOrderExecutable(order, price)) {
    int filledQty = (int) orderQty.getValue();

    quickfix.fix40.ExecutionReport fill = new quickfix.fix40.ExecutionReport(
            genOrderID(), genExecID(),
            new ExecTransType(ExecTransType.NEW),
            new OrdStatus(OrdStatus.FILLED),
            order.getSymbol(), order.getSide(),
            orderQty,
            new LastShares(filledQty),
            new LastPx(price.getValue()),
            new CumQty(filledQty),
            new AvgPx(price.getValue()));

    fill.set(order.getClOrdID());
    sendMessage(sessionID, fill);
}
// FIX 4.1
if (isOrderExecutable(order, price)) {
    int filledQty = (int) orderQty.getValue();

    quickfix.fix41.ExecutionReport executionReport = new quickfix.fix41.ExecutionReport(
            genOrderID(), genExecID(),
            new ExecTransType(ExecTransType.NEW),
            new ExecType(ExecType.FILL),
            new OrdStatus(OrdStatus.FILLED),
            order.getSymbol(), order.getSide(),
            orderQty,
            new LastShares(filledQty),
            new LastPx(price.getValue()),
            new LeavesQty(0),
            new CumQty(filledQty),
            new AvgPx(price.getValue()));

    executionReport.set(order.getClOrdID());
    sendMessage(sessionID, executionReport);
}
// FIX 4.2
if (isOrderExecut...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

Copilot AI changed the title [WIP] Fix Windows compile failure due to incompatible quantity types Fix Windows compile break in executor example by aligning LastShares quantity type (FIX 4.0/4.1/4.2) May 22, 2026
Copilot AI requested a review from chrjohn May 22, 2026 03:05
@chrjohn chrjohn changed the title Fix Windows compile break in executor example by aligning LastShares quantity type (FIX 4.0/4.1/4.2) Fix Windows compile break in executor example by aligning LastShares quantity type (FIX 4.0/4.1/4.2) May 22, 2026
@chrjohn chrjohn added this to the QFJ 3.0.2 milestone May 22, 2026
@chrjohn chrjohn marked this pull request as ready for review May 22, 2026 09:30
@chrjohn chrjohn merged commit 4f61818 into master May 22, 2026
39 checks passed
@chrjohn chrjohn deleted the copilot/fix-windows-compile-failure branch May 22, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants