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

Alexander Zvegintsev azvegint at openjdk.java.net
Tue Feb 9 14:02:42 UTC 2021


On Tue, 9 Feb 2021 13:13:51 GMT, Jayathirth D V <jdv at openjdk.org> wrote:

>> Also, if there is no clip set, then the spec statement " If s is null, this method clears the current Clip" does not carry any meaning, so in both regard, setClip() should be there, I presume.
>
> @prsadhuk At first glance i also thought clip() should be called after calling setClip() but that is not the case.
> 
> If we see SunGraphics2D implementation of clip() we dont exit if there is no clip(usrClip object) is set using setClip(). So clip() doesnt depend on whether setClip() is used or not.

> Also, if there is no clip set, then the spec statement " If s is null, this method clears the current Clip" does not carry any meaning, so in both regard, setClip() should be there, I presume.

The old javadoc is definitely does not conform the current behavior. But as of now it clearly says that it will throw NPE if null argument passed.

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

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


More information about the 2d-dev mailing list