<Swing Dev> [12] RFR JDK-8211703: JInternalFrame : java.lang.AssertionError: cannot find the internal frame

Prasanta Sadhukhan prasanta.sadhukhan at oracle.com
Mon Oct 22 05:54:06 UTC 2018


Gentle reminder...

Regards
Prasanta
On 05-Oct-18 2:31 PM, Prasanta Sadhukhan wrote:
> Hi Sergey,
>
>
> On 04-Oct-18 11:03 PM, Prasanta Sadhukhan wrote:
>>
>>
>> On 04-Oct-18 10:44 PM, Prasanta Sadhukhan wrote:
>>>
>>>
>>> On 04-Oct-18 10:29 PM, Sergey Bylokhov wrote:
>>>> On 04/10/2018 09:44, Prasanta Sadhukhan wrote:
>>>>> Hi Sergey,
>>>>>
>>>>> Yes, this method should return JInternalFrame but there is no way 
>>>>> to get JinternalFrame object from BasicInternalFrameTitlePane 
>>>>> currently.
>>>>
>>>> But why it is not possible? The BasicInternalFrameTitlePane is a 
>>>> title of the internalFrame and it looks like it should be located 
>>>> somewhere inside the internalFrame, isn't it?
>>>>
>>> BasicInternalTitlePane has a protected variable of JInternalFrame 
>>> object and there is no public method to access that so that's why I 
>>> told it is not currently possible unless we add a public method in 
>>> this Basic* class, if I understand it correctly. Let me know if it 
>>> can be accessed some other way.
>>>
>> JInternalFrame.getUI().getNorthPane() probably might give 
>> BasicInternalTitlePane object but I do not think we can get 
>> viceversa, ie get JInternalFrame object from BasicInternalTitlePane.
> I have improved the code to get JInternalFrame from 
> BasicInternalFrameTitlePane, as you have suggested
> http://cr.openjdk.java.net/~psadhukhan/8211703/webrev.1/
>
> Regards
> Prasanta
>>> Regards
>>> Prasanta
>>>> This Metacity class has the provision of accepting null value from 
>>>> this method
>>>>> and this assertion problem is caused only when we ran with "esa" 
>>>>> [to enable assertion]. The submitter has not mentioned there is 
>>>>> any failure if we run the without esa, so I have only done away 
>>>>> with the wrong assertion for BasicInternalFrameTitlePane.
>>>>>
>>>>> Regards
>>>>> Prasanta
>>>>> On 04-Oct-18 9:43 PM, Sergey Bylokhov wrote:
>>>>>> Hi, Prasanta.
>>>>>> Can you please clarify this code a little bit. As far as I 
>>>>>> understand this method should return the JInternalFrame, which 
>>>>>> should be accessed via the comp passed to this method. This 
>>>>>> method already has this check:
>>>>>>         if (comp.getParent() instanceof 
>>>>>> BasicInternalFrameTitlePane) {
>>>>>>             comp = comp.getParent();
>>>>>>         }
>>>>>>
>>>>>> So maybe we can improve it to fetch the JInternalFrame from the 
>>>>>> BasicInternalFrameTitlePane or from another class passed to this 
>>>>>> method?
>>>>>>
>>>>>> On 04/10/2018 07:35, Prasanta Sadhukhan wrote:
>>>>>>> Hi All,
>>>>>>>
>>>>>>> Please review a cleanup of the code where wrong assertion is 
>>>>>>> used when Component is an instance of BasicInternalFrameTitlePane.
>>>>>>>
>>>>>>> Now, BasicInternalFrameTitlePane is extended from JComponent and 
>>>>>>> not from JInternalFrame
>>>>>>> so it will never satisfy the if-else condition if "Component is 
>>>>>>> instanceof BasicInternalFrameTitlePane",
>>>>>>> so proposed fix is to assert only if the component is not an 
>>>>>>> instance of BasicInternalFrameTitlePane
>>>>>>>
>>>>>>> diff -r d96a607e9594 
>>>>>>> src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java 
>>>>>>>
>>>>>>> --- 
>>>>>>> a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java 
>>>>>>> Tue Sep 18 18:32:03 2018 -0700
>>>>>>> +++ 
>>>>>>> b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java 
>>>>>>> Thu Oct 04 19:53:10 2018 +0530
>>>>>>> @@ -337,7 +337,9 @@
>>>>>>>           } else if (comp instanceof JInternalFrame.JDesktopIcon) {
>>>>>>>               return 
>>>>>>> ((JInternalFrame.JDesktopIcon)comp).getInternalFrame();
>>>>>>>           }
>>>>>>> -        assert false : "cannot find the internal frame";
>>>>>>> +       if (!(comp instanceof BasicInternalFrameTitlePane)) {
>>>>>>> +            assert false : "cannot find the internal frame";
>>>>>>> +       }
>>>>>>>           return null;
>>>>>>>       }
>>>>>>>
>>>>>>> Regards
>>>>>>> Prasanta
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>



More information about the swing-dev mailing list