<div><br></div>   Thanks to every one !<br><br><div class="gmail_quote">On Sat, Mar 31, 2012 at 5:01 PM, Charles Lee <span dir="ltr">&lt;<a href="mailto:littlee@linux.vnet.ibm.com">littlee@linux.vnet.ibm.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>

  
    
  
  <div text="#000000" bgcolor="#ffffff">
    Hi Sean,<br>
    <br>
    The patch has been committed @<br>
    <br>
    <pre>Changeset: 96340349e35b
Author:    zhouyx
Date:      2012-03-31 16:55 +0800
URL:       <a href="http://hg.openjdk.java.net/jdk8/awt/jdk/rev/96340349e35b" target="_blank">http://hg.openjdk.java.net/jdk8/awt/jdk/rev/96340349e35b</a>

7155298: Editable TextArea/TextField are blocking GUI applications from exit
Summary: Stop default caret&#39;s timer by setVisible(false) when dispose
Reviewed-by: anthony, ant
</pre>
    <br>
    Please verify it.<br>
    <br>
    Thank you all for reviewing.<div><div></div><div class="h5"><br>
    <br>
    <br>
    On 03/27/2012 11:22 AM, Sean Chou wrote:
    <blockquote type="cite">
      <div>Hi Anthony,</div>
      <div><br>
      </div>
      <div>    I tried the scenario you suggested, but it doesn&#39;t work.
        And I found the jtreg spec says: </div>
      <div>
        <pre>&#39; A &quot;main&quot; action is
considered to be finished when the main method returns; if a test involves
multiple threads, some synchronization may be necessary to ensure that the
other threads finish their work before the thread running the main method
returns. &#39;</pre>
      </div>
      <div>    Then I tried to join TimerQueue in main, but it always
        blocks. So I started a new process </div>
      <div>to wait instead.</div>
      <br>
          I tested and found the &quot;/&quot; separated path works on windows, it
      is not a problem :)<br>
      <br>
      <div class="gmail_quote">On Mon, Mar 26, 2012 at 9:55 PM, Anthony
        Petrov <span dir="ltr">&lt;<a href="mailto:anthony.petrov@oracle.com" target="_blank">anthony.petrov@oracle.com</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          Hi Sean,<br>
          <br>
          <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  92             worker =
            Runtime.getRuntime().exec(System.getProperty(&quot;java.home&quot;)+&quot;/bin/java
            TestDispose workprocess&quot;);<br>
          </blockquote>
          <br>
          This won&#39;t work on MS Windows because the path separator
          character is different there.<br>
          <br>
          Actually, I don&#39;t understand why you need this Runtime stuff
          in the first place. If test JVM doesn&#39;t terminate, the test
          will fail. So why not create a frame and a text field right in
          the main(), then call dispose() and return from main()? Since
          the timer thread will still be running, the test&#39;s JVM won&#39;t
          exit, and the test will fail by timeout eventually. Will this
          testing scenario work?<br>
          <br>
          --<br>
          best regards,<br>
          Anthony
          <div><br>
            <br>
            On 03/23/12 10:49, Sean Chou wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
            <div>
              <br>
              I modified the testcase according to Anthony Petrov&#39;s<br>
              suggestion(<a href="http://mail.openjdk.java.net/pipermail/awt-dev/2012-March/002389.html" target="_blank">http://mail.openjdk.java.net/pipermail/awt-dev/2012-March/002389.html</a>)<br>
              .<br>
              The new webrev: <a href="http://cr.openjdk.java.net/%7Ezhouyx/7155298/webrev.02/" target="_blank">http://cr.openjdk.java.net/~zhouyx/7155298/webrev.02/</a><br>
              <br>
              However, the timeout action in jtreg only checks the main
              method, but<br>
              the timeout is caused by timer thread .<br>
              So, I started an other process to run the testcase and the
              main testcase<br>
              waitFor that process to stop. In order to kill the process
              started by<br>
              the testcase, I added a ShutdownHook to the runtime of
              main testcase.<br>
              And added /othervm action to testcase .<br>
              <br>
              It seems the testcase is a little over complex, is there
              any other<br>
              method to make the testcase simpler ?<br>
              <br>
              On Fri, Mar 23, 2012 at 2:04 AM, Oleg Sukhodolsky &lt;<a href="mailto:son.two@gmail.com" target="_blank">son.two@gmail.com</a><br>
            </div>
            <div>
              &lt;mailto:<a href="mailto:son.two@gmail.com" target="_blank">son.two@gmail.com</a>&gt;&gt;
              wrote:<br>
              <br>
                 On Thu, Mar 22, 2012 at 10:50 PM, Anton V. Tarasov<br>
            </div>
            <div>    &lt;<a href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>
              &lt;mailto:<a href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>&gt;&gt;
              wrote:<br>
                  &gt; On 3/22/12 6:15 PM, Oleg Sukhodolsky wrote:<br>
                  &gt;&gt;<br>
                  &gt;&gt; On Thu, Mar 22, 2012 at 5:55 PM, Anton V.
              Tarasov<br>
            </div>
                &gt;&gt; &lt;<a href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>
            &lt;mailto:<a href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>&gt;&gt;
             wrote:
            <div>
              <br>
                  &gt;&gt;&gt;<br>
                  &gt;&gt;&gt; On 22.03.2012 14:37, Oleg Sukhodolsky
              wrote:<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt; On Thu, Mar 22, 2012 at 2:19 PM,
              Anton V. Tarasov<br>
            </div>
                &gt;&gt;&gt;&gt; &lt;<a href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>
            &lt;mailto:<a href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>&gt;&gt;
            <div>
              <br>
                   wrote:<br>
                  &gt;&gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;&gt; On 22.03.2012 12:47, Oleg
              Sukhodolsky wrote:<br>
                  &gt;&gt;&gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;&gt;&gt; On Thu, Mar 22, 2012 at 12:01
              PM, Sean<br>
            </div>
               Chou&lt;<a href="mailto:zhouyx@linux.vnet.ibm.com" target="_blank">zhouyx@linux.vnet.ibm.com</a>
            &lt;mailto:<a href="mailto:zhouyx@linux.vnet.ibm.com" target="_blank">zhouyx@linux.vnet.ibm.com</a>&gt;&gt;
            <div>
              <div><br>
                    &gt;&gt;&gt;&gt;&gt;&gt;  wrote:<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt; Hi Oleg,<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt;     Seem there are
                misunderstanding .<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt;     DefaultCaret can
                receive FocusLostEvent when another<br>
                   control get<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt; focused. But it<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt; doesn&#39;t receive
                FocusLostEvent when disposing.<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt;     The reason is
                XTextAreaPeer doesn&#39;t receive<br>
                   FocusLostEvent when<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt; disposing. But<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt; I don&#39;t know if it is a
                rule that a FocusLostEvent must be<br>
                   sent to<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt; the<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;&gt; focused&gt;&gt;&gt;  
                 component when the top-level window is disposed ?<br>
                    &gt;&gt;&gt;&gt;&gt;&gt;<br>
                    &gt;&gt;&gt;&gt;&gt;&gt; Well, for regular AWT
                component it is expected.  And I&#39;d<br>
                   expect that<br>
                    &gt;&gt;&gt;&gt;&gt;&gt; this should also be true
                for peer.<br>
                    &gt;&gt;&gt;&gt;&gt;<br>
                    &gt;&gt;&gt;&gt;&gt;<br>
                    &gt;&gt;&gt;&gt;&gt; That&#39;s right, focus_lost should
                be dispatched to a disposed focus<br>
                    &gt;&gt;&gt;&gt;&gt; owner.<br>
                    &gt;&gt;&gt;&gt;<br>
                    &gt;&gt;&gt;&gt; So, now we need to figure out why
                the caret doesn&#39;t get the event.<br>
                    &gt;&gt;&gt;&gt;<br>
                    &gt;&gt;&gt;&gt; Oleg.<br>
                    &gt;&gt;&gt;<br>
                    &gt;&gt;&gt;<br>
                    &gt;&gt;&gt; I ran the testcase provided in the
                webrev and debugged a little.<br>
                    &gt;&gt;&gt; FOCUS_LOST<br>
                    &gt;&gt;&gt; does come to the textarea on its
                disposal, though when the<br>
                   focus event is<br>
                    &gt;&gt;&gt; being dispatched I see the peer is
                null.<br>
                    &gt;&gt;&gt; This is quite expected actually. When
                Component.removeNotify()<br>
                   is called<br>
                    &gt;&gt;&gt; on<br>
                    &gt;&gt;&gt; EDT, it transfers focus further
                (appropriate focus events get<br>
                   queued) and<br>
                    &gt;&gt;&gt; then nullifies the peer. The events
                come later.<br>
                    &gt;&gt;&gt; Hope this helps.<br>
                    &gt;&gt;<br>
                    &gt;&gt; Thank you (I do not have Linux, so I can
                not debug this).<br>
                    &gt;&gt; So, now we know that the cause of the
                problem is that our internal<br>
                    &gt;&gt; AWTText(Field|Area) may be disposed while
                they think<br>
                    &gt;&gt; that they are focused, and, at the same
                time, we can not propogate<br>
                    &gt;&gt; real focus lost to them since peer is
                desposed<br>
                    &gt;&gt; before we receive the event.<br>
                    &gt;&gt; So, the suggested fix works fine for one
                particular problem<br>
                   (unstopped<br>
                    &gt;&gt; timer), but we may get some other<br>
                    &gt;&gt; problems due to the cause.<br>
                    &gt;&gt; For me it looks like better fix would be to
                pass synthetic focus<br>
                   lost<br>
                    &gt;&gt; when we dispose text peer, this way we
                guarantee<br>
                    &gt;&gt; that life-circle of our synthetic
                components will be similar to real<br>
                    &gt;&gt; ones and we will meet Swing&#39;s expectations.<br>
                    &gt;&gt;<br>
                    &gt;&gt; Does this sounds reasonable?<br>
                    &gt;&gt;<br>
                    &gt;&gt; Regards, Oleg.<br>
                    &gt;<br>
                    &gt;<br>
                    &gt; This sounds reasonable, though I personally
                don&#39;t like the idea<br>
                   of yet<br>
                    &gt; another synthetic focus event...<br>
                <br>
                   well, (synthetic) focus events are your area of
                expertise ;)<br>
                <br>
                    &gt; I actually like the fix Sean suggested (after
                we see the whole<br>
                   picture).<br>
                    &gt; Otherwise, we may follow your suggestion<br>
                    &gt; to create AWTTextArea.removeNotify(). And even
                simpler, why not<br>
                   to put<br>
                    &gt; getCaret().setVisible(false) right into<br>
                   JTextComponent.removeNotify()?<br>
                <br>
                   well, the later is a question for Swing team.<br>
                   The former is reasonable fix (not the best one, but
                good enough).<br>
                   So, if everyone agree with this approach then I&#39;m
                fine (hope this is<br>
                   the only problem we<br>
                   will have with invisible focused JTextXXX)<br>
                <br>
                   Oleg.<br>
                <br>
                    &gt;<br>
                    &gt; Either of these looks fine to me.<br>
                    &gt;<br>
                    &gt; Thanks,<br>
                    &gt; Anton.<br>
                    &gt;<br>
                    &gt;<br>
                <br>
                <br>
                <br>
                <br>
                --<br>
                Best Regards,<br>
                Sean Chou<br>
                <br>
              </div>
            </div>
          </blockquote>
        </blockquote>
      </div>
      <br>
      <br clear="all">
      <div><br>
      </div>
      -- <br>
      Best Regards,<br>
      Sean Chou<br>
      <br>
    </blockquote>
    <br>
    <br>
    </div></div><font color="#888888"><pre cols="72">-- 
Yours Charles</pre>
  </font></div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br>Best Regards,<br>Sean Chou<br><br>