[OpenJDK 2D-Dev] RFR: JDK-8263362: Avoid division by 0 in java/awt/font/TextJustifier.java justify

Matthias Baesken mbaesken at openjdk.java.net
Thu Mar 11 06:48:10 UTC 2021

On Thu, 11 Mar 2021 04:24:26 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Nothing throws an exception or otherwise prevent this being negative but that would be a weird usage. Typically the weight is either zero or based on the font size .. which ought not to be negative but I don't think anything prevents it and I think we would treat it essentially as a transform. So If you really want to be careful here, then yes assume weight could be negative.
> By that same logic, then shouldn't absorbweight also be checked as != 0 instead of > 0 as that also uses += gi.weight

Hi, I am not sure about the absorbweight  check; but  currently the calculated value weightedAbsorb is only used when absorbing is true. And  there the > 0 check is present too

boolean absorbing = hitLimit && absorbweight > 0;


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

More information about the 2d-dev mailing list