[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:34:40 UTC 2021
On Wed, 10 Feb 2021 04:51:33 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> If "*setClip*(null)" has to clear the clip then it should be specified, currently, that method said nothing about the null parameter.
>
> 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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2476
More information about the 2d-dev
mailing list