[patch] fix to BufferedImage

graydon hoare graydon@redhat.com
Wed Sep 17 16:27:00 GMT 2003


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



More information about the Java-patches mailing list