[OpenJDK 2D-Dev] RFR: 6206189: Graphics2D.clip specifies incorrectly that a 'null' is a valid value for this method [v3]

Phil Race prr at openjdk.java.net
Wed Feb 10 18:50:38 UTC 2021


On Wed, 10 Feb 2021 18:30:18 GMT, Phil Race <prr at openjdk.org> wrote:

>> As per code 
>> public void setClip(Shape sh) {
>>         usrClip = transformShape(sh);
>> 
>> usrClip is set to null if "sh" is null so clip is cleared...I will update the setClip doc too..
>
> From what I can tell, if clip is null, then calling clip(null) has no effect.
> And it won't throw an NPE in that case. So the proposed documentation is less accurate than no documentation at all.
> And I would shy away from changing the implementation on this without LOTS of VERY careful testing.  
> Oh the javadoc clause you propose is split by many lines of comments. I see you have the rider "and clip is already set via {@code setClip}".
> Well I am not sure why it has to be set by setClip for this to be true but just having to say this sounds weird.

> usrClip is set to null if "sh" is null so clip is cleared...I will update the setClip doc too..

Huh ? Not understanding you. If the userClip is non-null then we enter this
        if (usrClip != null) {
            s = intersectShapes(usrClip, s, true, true);
        }
which i where you get the NPE from you are proposing to document.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2476


More information about the 2d-dev mailing list