RFR: 8375561: Class NGGroup is in need of some cleanup

John Hendrikx jhendrikx at openjdk.org
Fri Jan 16 22:12:52 UTC 2026


On Fri, 16 Jan 2026 18:14:35 GMT, Christopher Schnick <duke at openjdk.org> wrote:

> This should improve the code quality of the class while preserving its original workings

modules/javafx.graphics/src/main/java/com/sun/javafx/sg/prism/NGGroup.java line 204:

> 202:      * @param blendMode cannot be null
> 203:      */
> 204:     public void setBlendMode(Blend.Mode blendMode) {

This method looks unused, may as well remove if we're cleaning up stuff.

modules/javafx.graphics/src/main/java/com/sun/javafx/sg/prism/NGGroup.java line 268:

> 266:                 if (child != null) {
> 267:                     child.render(g);
> 268:                 }

That's some pretty poor code to begin with. If there is any worry at all that this can be called from multiple threads, then `synchronized` should be used.

modules/javafx.graphics/src/main/java/com/sun/javafx/sg/prism/NGGroup.java line 287:

> 285:         } while (bot == null || !idValid);
> 286: 
> 287:         bot.unref();

This `null` check could be important if a `Group` is empty.  Please verify.

modules/javafx.graphics/src/main/java/com/sun/javafx/sg/prism/NGGroup.java line 451:

> 449:             NGNode child;
> 450:             List<NGNode> orderedChildren = getOrderedChildren();
> 451:             for (NGNode orderedChild : orderedChildren) {

You may want to stick with the normal `for` loops as they don't require allocating an iterator object.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2043#discussion_r2700114515
PR Review Comment: https://git.openjdk.org/jfx/pull/2043#discussion_r2700119175
PR Review Comment: https://git.openjdk.org/jfx/pull/2043#discussion_r2700124885
PR Review Comment: https://git.openjdk.org/jfx/pull/2043#discussion_r2700126762


More information about the openjfx-dev mailing list