RFR: 8370467: BorderFactory.createBevelBorder and createSoftBevelBorder throws NPE for null highlight and shadow

Harshitha Onkar honkar at openjdk.org
Fri Oct 24 00:23:01 UTC 2025


On Thu, 23 Oct 2025 06:54:27 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> If we pass null as highlight and shadow color to `BorderFactory.createBevelBorder` and `createSoftBevelBorder`
> it throws NPE which is not mentioned in the spec as the expected outcome.
> Fixed the NPE and the spec

src/java.desktop/share/classes/javax/swing/BorderFactory.java line 148:

> 146:      * uses a brighter shade of the shadow color.
> 147:      * If highlight and shadow color are null, then it will
> 148:      * fallback to create beveled border of the specified type.

If the highlight and shadow color are null, are the colors obtained by UIManager defaults?

src/java.desktop/share/classes/javax/swing/BorderFactory.java line 161:

> 159:             return new BevelBorder(type, highlight, shadow);
> 160:         }
> 161:         return new BevelBorder(type);

Do we need to do something similar for other border types such as EtchedBorder ?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27949#discussion_r2458098894
PR Review Comment: https://git.openjdk.org/jdk/pull/27949#discussion_r2458086432


More information about the client-libs-dev mailing list