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

Prasanta Sadhukhan prasanta.sadhukhan at oracle.com
Mon May 20 09:49:50 UTC 2019


Hi Sergey,

I have unified approach to get InternalFrame from button. Since 
updateFrameGeometry() was called with 
"javax.swing.plaf.basic.BasicInternalFrameTitlePane$NoFocusButton" 
component whose parent does not have internal frame,it was asserting
so as done in paintButtonBackground(), updateFrameGeometry() is modified 
to check if the comp is JButton ,then extract the titlePane and use 
titlePane's parent to find internalFrame.
http://cr.openjdk.java.net/~psadhukhan/8211703/webrev.2/

Regards
Prasanta
On 14-Nov-18 2:01 AM, Sergey Bylokhov wrote:
> On 13/11/2018 01:25, Prasanta Sadhukhan wrote:
>> findInternalFrame() is called from paintButtonBackground(), 
>> paintFrameBorder() and updateFrameGeometry()
>> but in paintButtonBackground() and paintFrameBorder()
>> updateFrameGeometry() is called before findInternalFrame() so 
>> basically it is updateFrameGeometry()#findInternalFrame that is get 
>> called during assertion.
>
> But in these cases it is used in a little bit different ways, take a 
> look to the paintButtonBackground().
>
>  - In first line we will call updateFrameGeometry(), and inside:
>    1. We will call "comp = context.getComponent()"
>    2. Then will try to find titlePane using findChild() -  I guess it 
> will always fail for button.
>    3. Then we pass the comp to the findInternalFrame
>  - After that we return to the paintButtonBackground and:
>    1. We will call "button = context.getComponent()"
>    2. We will take a "titlePane = (JComponent)button.getParent()"; 
> NOTE: It is different that in "updateFrameGeometry"
>    3. Then we will take titlePaneParent from the titlepane
>    4. Then we pass the titlePaneParent to the findInternalFrame
>
> Note that context in both cases is the same, but we pass different 
> components to findInternalFrame.
> I tried to move the call of findInternalFrame in the 
> paintButtonBackground before
> updateFrameGeometry(to compare the second and first approaches) and it 
> is completes successfully. So it
> seems we need to unify approach on how we get a InternalFrame from the 
> button.
>
> Can you please check this.
>
>
>>
>> During assertion,
>> paintButtonBackground() is called which calls updateFrameGeometry() with
>> comp=javax.swing.plaf.basic.BasicInternalFrameTitlePane$NoFocusButton[InternalFrameTitlePane.iconifyButton,240,3,18x18,alignmentX=0.0,alignmentY=0.5,border=,flags=290,maximumSize=,minimumSize=, 
>>
>> preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=false,pressedIcon=, 
>>
>> rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true] 
>>
>>
>> and comp's parent is
>> javax.swing.plaf.synth.SynthInternalFrameTitlePane[InternalFrame.northPane,0,0,300x24,layout=com.sun.java.swing.plaf.gtk.Metacity$TitlePaneLayout, 
>>
>> alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder at 26e3b5d8,flags=8388610,maximumSize=,minimumSize=,preferredSize=] 
>>
>>
>> so "comp.getParent() instanceof BasicInternalFrameTitlePane" check is 
>> satisfied so "comp" becomes SynthInternalFrameTitlePane.
>>
>> Since SynthInternalFrameTitlePane is not an instance of 
>> JInternalFrame nor JInternalFrame.JDesktopIcon, it results in 
>> assertion, so as a fix I extracted the internalframe from 
>> BasicInternalFrameTitlePane.
>>
>> Regards
>> Prasanta
>> On 13-Nov-18 7:56 AM, Sergey Bylokhov wrote:
>>> Hi, Prasanta.
>>>
>>> Can you please provide more details on the hierarchy of components 
>>> which trigger this assertion.
>>>
>>> This method is used in 3 places, in two places we try to find the 
>>> child "InternalFrame.northPane"
>>> and pass it to the findInternalFrame(). But in one place we take a 
>>> "button.getParent()", then pass
>>> it to the findInternalFrame(), and take the parent one more time:
>>> "comp.getParent() instanceof BasicInternalFrameTitlePane"
>>>
>>> Perhaps one call to "getParent()" is superfluous? What is the 
>>> hierarchy of panes/buttons/internal frames?
>>>
>>>
>>> On 12/11/2018 03:21, Prasanta Sadhukhan wrote:
>>>> Thanks Muneer for the confirmation. Gentle reminder to review which 
>>>> is pending for over a month now.
>>>>
>>>> http://cr.openjdk.java.net/~psadhukhan/8211703/webrev.1/
>>>>
>>>> Regards
>>>> Prasanta
>>>> On 24-Oct-18 3:13 PM, Muneer Kolarkunnu wrote:
>>>>> Hi Prasanta,
>>>>>
>>>>> I tested with provided binary and issue is resolved with this fix. 
>>>>> Thanks for fixing this issue.
>>>>>
>>>>> Regards,
>>>>> Muneer
>>>>>
>>>>> -----Original Message-----
>>>>> From: Muneer Kolarkunnu
>>>>> Sent: Wednesday, October 24, 2018 12:00 PM
>>>>> To: Prasanta Sadhukhan <prasanta.sadhukhan at oracle.com>; Sergey 
>>>>> Bylokhov <sergey.bylokhov at oracle.com>; swing-dev at openjdk.java.net
>>>>> Subject: Re: <Swing Dev> [12] RFR JDK-8211703: JInternalFrame : 
>>>>> java.lang.AssertionError: cannot find the internal frame
>>>>>
>>>>> Hi Prasanta,
>>>>>
>>>>> I can verify it if you can share a binary with fix.
>>>>>
>>>>> Regards,
>>>>> Muneer
>>>>>
>>>>> -----Original Message-----
>>>>> From: Prasanta Sadhukhan
>>>>> Sent: Wednesday, October 24, 2018 11:41 AM
>>>>> To: Sergey Bylokhov <sergey.bylokhov at oracle.com>; 
>>>>> swing-dev at openjdk.java.net; ABDUL.KOLARKUNNU 
>>>>> <abdul.kolarkunnu at oracle.com>
>>>>> Subject: Re: <Swing Dev> [12] RFR JDK-8211703: JInternalFrame : 
>>>>> java.lang.AssertionError: cannot find the internal frame
>>>>>
>>>>> Hi Muneer,
>>>>>
>>>>> Could you check (as a submitter) if the proposed fix works in your 
>>>>> jemmy environment? It seems to work for me with the command line 
>>>>> you gave in JBS.
>>>>>
>>>>> Regards
>>>>> Prasanta
>>>>> On 22-Oct-18 11:24 AM, Prasanta Sadhukhan wrote:
>>>>>> 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/Meta 
>>>>>>>>>>>>>
>>>>>>>>>>>>> city.java
>>>>>>>>>>>>>
>>>>>>>>>>>>> ---
>>>>>>>>>>>>> a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Me 
>>>>>>>>>>>>>
>>>>>>>>>>>>> tacity.java
>>>>>>>>>>>>> Tue Sep 18 18:32:03 2018 -0700
>>>>>>>>>>>>> +++
>>>>>>>>>>>>> b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Me 
>>>>>>>>>>>>>
>>>>>>>>>>>>> tacity.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