On Thu, 30 Oct 2025 03:30:45 GMT, Prasanta Sadhukhan <[email protected]>
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
>
> Prasanta Sadhukhan has updated the pull request incrementally with one
> additional commit since the last revision:
>
> Test update
src/java.desktop/share/classes/javax/swing/BorderFactory.java line 147:
> 145: * the highlight color. The inner edge of the shadow area
> 146: * uses a brighter shade of the shadow color.
> 147: * If highlight and shadow color are null, then it will
The text above says that if both are null it will fall back. You don't mean
that.
You mean if either is null it will fall back.
This results in the colors all being null.
And I think you need to look further.
The NPE happens because BevelBorder does this
this(bevelType, highlight.brighter(), highlight, shadow,
shadow.brighter());
But the constructor it is calling is also public and will happily allow nulls
for any specific case.
So perhaps the above constructor should be doing something like
((highlight != null) ? highlight.brighter : null)
src/java.desktop/share/classes/javax/swing/BorderFactory.java line 158:
> 156: */
> 157: public static Border createBevelBorder(int type, Color highlight,
> Color shadow) {
> 158: if (highlight != null && shadow != null) {
What happens if type isn't a known type ?
Looks to me like no errors but no painting but I've not looked very closely.
Whatever we want should be specified everywhere.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27949#discussion_r2482611678
PR Review Comment: https://git.openjdk.org/jdk/pull/27949#discussion_r2482622608