Skip to content

Fix compiler warning in SSLCertificateTest.parameters()#1213

Merged
chrjohn merged 2 commits intomasterfrom
copilot/fix-ssl-certificate-test-warning
May 6, 2026
Merged

Fix compiler warning in SSLCertificateTest.parameters()#1213
chrjohn merged 2 commits intomasterfrom
copilot/fix-ssl-certificate-test-warning

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

Passing String[][] to Arrays.asList(T... a) is ambiguous — the compiler can't determine whether it's a varargs call (each String[] as a separate element) or a single Object[][] argument, producing a non-varargs warning.

Change

Replace the 2D String[][] literal with explicit Object[] entries:

// Before
return Arrays.asList(new String[][]{{"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLSv1.2"}, {"TLS_AES_256_GCM_SHA384", "TLSv1.3"}});

// After
return Arrays.asList(
    new Object[]{"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLSv1.2"},
    new Object[]{"TLS_AES_256_GCM_SHA384", "TLSv1.3"}
);

This makes the varargs intent unambiguous and aligns the element type with the declared List<Object[]> return type.

Original prompt

Problem

In quickfixj-core/src/test/java/quickfix/mina/ssl/SSLCertificateTest.java at line 100, there is a compiler warning:

non-varargs call of varargs method with inexact argument type for last parameter;
  cast to Object[] for a varargs call
  cast to Object[][] for a non-varargs call and to suppress this warning

The offending code is in the parameters() method:

@Parameters
public static List<Object[]> parameters() {
    return Arrays.asList(new String[][]{{"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLSv1.2"}, {"TLS_AES_256_GCM_SHA384", "TLSv1.3"}});
}

Arrays.asList(T... a) is a varargs method. Passing a String[][] (2D array) is ambiguous — the compiler cannot tell whether it is a varargs call (treating each String[] as a separate element) or a non-varargs call passing the whole String[][] as a single Object[][].

Fix

Replace the String[][] with explicit Object[] entries to remove the ambiguity and match the return type List<Object[]>:

@Parameters
public static List<Object[]> parameters() {
    return Arrays.asList(
        new Object[]{"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLSv1.2"},
        new Object[]{"TLS_AES_256_GCM_SHA384", "TLSv1.3"}
    );
}

This eliminates the compiler warning, clarifies intent, and correctly matches the List<Object[]> return type.

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

User: ```
/home/runner/work/quickfixj/quickfixj/quickfixj-core/src/test/java/quickfix/mina/ssl/SSLCertificateTest.java:[100,29] non-varargs call of varargs method with inexact argument type for last parameter;
2026-05-04T08:49:10.5306689Z cast to Object[] for a varargs call
2026-05-04T08:49:10.5307629Z cast to Object[][] for a non-varargs call and to suppress this warning


User: ```
/home/runner/work/quickfixj/quickfixj/quickfixj-core/src/test/java/quickfix/mina/ssl/SSLCertificateTest.java:[100,29] non-varargs call of varargs method with inexact argument type for last parameter;
2026-05-04T08:49:10.5306689Z   cast to Object[] for a varargs call
2026-05-04T08:49:10.5307629Z   cast to Object[][] for a non-varargs call and to suppress this warning

Assistant: ## The Issue

Line 100 has a compiler warning about an ambiguous varargs call:

@Parameters
public static List<Object[]> parameters() {
    return Arrays.asList(new String[][]{{"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLSv1.2"}, {"TLS_AES_256_GCM_SHA384", "TLSv1.3"}});
}

Root Cause

Arrays.asList(T... a) is a varargs method. Passing a String[][] (a 2D array) as its argument is ambiguous — the compiler can't tell whether you intend:

  • A varargs call treating each String[] element as a separate T argument → List<String[]> ✅ (what's intended)
  • A non-varargs call with String[][] as a single Object[][] argument → List<String[][]>

Fix

Explicitly cast to Object[] to signal a varargs call with each String[] as an element:

@Parameters
public static List<Object[]> parameters() {
    return Arrays.asList((Object[]) new String[][]{{"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLSv1.2"}, {"TLS_AES_256_GCM_SHA384", "TLSv1.3"}});
}

Or, more explicitly and readably, avoid the 2D array entirely:

@Parameters
public static List<Object[]> parameters() {
    return Arrays.asList(
        new Object[]{"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLSv1.2"},
        new Object[]{"TLS_AES_256_GCM_SHA384", "TLSv1.3"}
    );
}

The second form is preferred — it uses Object[] directly (matching the return type List<Object[]>), eliminates the ambiguity warning, and is clearer in intent. Would you like me to open a PR with this fix?

User: Yes, please open a PR.

Assistant: I'm waiting for your response to the confirmation dialog to proceed with creating the pull request.

User: @copilot Dismissed Confirmation: Confirm agent session

Assistant: The PR creation was dismissed. Would you like me to try again?

User: please try again

Assistant: I've submitted the PR creation request. Once confirmed, it will open a pull request against quickfix-j/quickfixj that changes the parameters() method in SSLCertificateTest.java from the ambiguous new String[][]{{...}, {...}} form to the explicit new Object[]{...}, new Object[]{...} form, resolving the compiler warning.

This pull request was created from Copilot chat.

…LCertificateTest.parameters()

Agent-Logs-Url: https://github.com/quickfix-j/quickfixj/sessions/ef1fd840-8efe-4f18-9519-4475685ec24d

Co-authored-by: chrjohn <6644028+chrjohn@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix compiler warning in SSLCertificateTest parameters method Fix compiler warning in SSLCertificateTest.parameters() May 6, 2026
Copilot finished work on behalf of chrjohn May 6, 2026 07:23
Copilot AI requested a review from chrjohn May 6, 2026 07:23
@chrjohn chrjohn changed the title Fix compiler warning in SSLCertificateTest.parameters() Fix compiler warning in SSLCertificateTest.parameters() May 6, 2026
@chrjohn chrjohn added this to the QFJ 3.0.1 milestone May 6, 2026
@chrjohn chrjohn marked this pull request as ready for review May 6, 2026 09:29
@chrjohn chrjohn merged commit 67fd492 into master May 6, 2026
21 checks passed
@chrjohn chrjohn deleted the copilot/fix-ssl-certificate-test-warning branch May 6, 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