<Swing Dev> [12] RFR JDK-6828982: UIDefaults.getUI swallows original exception

Phil Race philip.race at oracle.com
Mon Oct 8 17:00:17 UTC 2018


That fixes one call site of getUIError, but like the submitter at least 
implied,
the problem is arguably down to the design of getUIError.
It will always print a stack trace that starts in getUIError itself.

///////////////////////////
    /**
      * If <code>getUI()</code> fails for any reason,
      * it calls this method before returning <code>null</code>.
      * Subclasses may choose to do more or less here.
      *
      * @param msg message string to print
      * @see #getUI
      */

     protected void getUIError(String msg) {
         try {
             throw new Error(msg);
         }
         catch (Throwable e) {
             e.printStackTrace();
         }
     }
///////////////////////////

So I agree it would have been better if it could have taken a possibly null
second exception parameter.
But I am not sure what we can do about it since as you can read,
the spec. actually says this exact method will be called by getUI()
Obviously the designers wanted to ensure a developer would see
the message but the exception would be handled, so as not to
possibly hang the UI.  I don't think this is worth the trouble to
add new API + respecify so somewhat reluctantly I will give it a +1,
although I'd be open to ideas.

-phil.

On 10/08/2018 12:40 AM, Prasanta Sadhukhan wrote:
> Can I get a 2nd (R)eviewer for this?
>
> Regards
> Prasanta
> On 29-Sep-18 3:55 PM, Krishna Addepalli wrote:
>> Looks fine.
>>
>> Krishna
>>
>>> On 29-Sep-2018, at 10:28 AM, Prasanta Sadhukhan 
>>> <prasanta.sadhukhan at oracle.com> wrote:
>>>
>>> Hi All,
>>>
>>> Please review a fix for an issue where it is seen that 
>>> UIDefaults.getUI() swallows the original exception and only emits 
>>> InvocationTargetException without the original stacktrace/message.
>>> Proposed fix is to make sure the original exception/stackTrace is 
>>> embedded in getUIError() message.
>>>
>>> Bug: https://bugs.openjdk.java.net/browse/JDK-6828982
>>> webrev: http://cr.openjdk.java.net/~psadhukhan/6828982/webrev.0/
>>>
>>> Regards
>>> Prasanta
>



More information about the swing-dev mailing list