Re: Warning in Netbeans: what does it mean?

Michael Bien <[email protected]> Mon, 1 Dec 2025 11:35:36 +0100
Newsgroups gmane.comp.java.ide.netbeans.user
Message-ID <[email protected]>
On 12/1/25 01:10, Owen Thomas wrote:
>
>
> On Mon, 1 Dec 2025 at 10:38, Owen Thomas <[email protected]> wrote:
>
>     Thank you Alonso and Pete for your responses.
>
>     This warning's short message was "Confusing primitive array passed to vararg method", and it was suppressed with the following:
>
>     @SuppressWarnings({"ConfusingArrayVararg", "PrimitiveArrayArgumentToVariableArgMethod"})
>
>     Thanks again.
>
>       Owen.
>
>
> A single argument to a method with this signature would be a single byte array - not a single byte. Providing a byte array could be a manifestation of the mistaken apprehension by the developer that a single byte is indeed a single argument - and this probably would lead to a problem that might not be picked up until runtime.
>
> Hence, upon reflection, I think the warning is a legitimate reason for alerting the developer to the possibility of a mistake; and so I think all is good with issuing the warning.

Btw: if anyone wants to update the hint description text for this or other hints its fairly easy to do

E.g adding

        int size = Arrays.asList(new byte[3]).size();
        System.out.println(size); // returns 1

to the description might help to visualize the problem.

https://github.com/apache/netbeans/blob/f914d7fecd5bb0a4537b706cf6a22d93bc33b6d1/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Bundle.properties#L228-L229

in case anyone wants to contribute it ;)

best regards,
michael

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists