This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] fix to BufferedImage


Tom Tromey <tromey@redhat.com> writes:

> graydon> +        // slower path
> graydon> +        int samples[] = null;
> graydon> +        samples = src.getPixels (x, y, w, h, samples);
> 
> The `null' here is redundant; there are a couple of these.
> I'd either do the assignment and declaration at once, or just not
> initialize samples.  (In java this is always safe due to the definite
> assignment rules.)

yeah, I'm aware that the null initialization is redundant in java;
that's probably just a C++ habit leaking through. I'll remove that.

the assignment however cannot coincide with the declaration, because
this is one of those "efficiency oriented" java APIs (pass in null if
you want the callee to allocate the array), and writing a literal
"null" in position of the "samples" argument degrades the type of the
argument to Object, which ambiguates the call: there's an overload for
each of int[], double[] and float[].

-graydon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]