On Fri, 31 Oct 2025 20:38:29 GMT, Phil Race <[email protected]> wrote:

>> 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)

Yes, it seems handling the NPE in BevelBorder is more apt..I have updated the 
PR removing from BorderFactory and updated BevelBorder to handle null 
hinghlighter and shadow

> 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.

Yes, if its not a known type, then it will not draw as seen here...so I have 
updated the spec of all methods to highlight this aspect instead...But this 
will also require CSR update, if we remove this spec update or clarification, 
we can do away with CSR...is that clarification needed in the spec?

https://github.com/openjdk/jdk/blob/4cfabd605c42494db4ca4078344d32abc951a9ae/src/java.desktop/share/classes/javax/swing/border/BevelBorder.java#L132-L138

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27949#discussion_r2485306131
PR Review Comment: https://git.openjdk.org/jdk/pull/27949#discussion_r2485308363

Reply via email to