<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Sean,<br>
    <br>
    On 27.03.2012 7:22, Sean Chou wrote:
    <blockquote
cite="mid:CAOo=rxUdr6Cw-QEw=ty+ZfE08BdA+O2OjN8ZH_CWOBZCBkmTtA@mail.gmail.com"
      type="cite">
      <div>Hi Anthony,</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; I tried the scenario you suggested, but it doesn't work.
        And I found the jtreg spec says:&nbsp;</div>
      <div>
        <pre>' A "main" 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. '</pre>
      </div>
      <div>&nbsp; &nbsp; Then I tried to join&nbsp;TimerQueue in main, but it always
        blocks. So I started a new process&nbsp;</div>
      <div>to wait instead.</div>
    </blockquote>
    <br>
    TimerQueue is a package private class which assumes reflection which
    I would avoid using by any means.<br>
    <br>
    I personally don't see any strong reason why you shouldn't use the
    Runtime stuff (taking into account the jtreg behavior). Anthony, do
    you?<br>
    <br>
    <blockquote
cite="mid:CAOo=rxUdr6Cw-QEw=ty+ZfE08BdA+O2OjN8ZH_CWOBZCBkmTtA@mail.gmail.com"
      type="cite"><br>
      &nbsp; &nbsp; I tested and found the "/" separated path works on windows, it
      is not a problem :)<br>
    </blockquote>
    <br>
    I looked at the implementation of Runtime.exec(String) just for
    curiosity. It (in its deep) normalizes the path via File.getPath(),
    so using slash seems ok.<br>
    <br>
    Thanks,<br>
    Anton.<br>
    <br>
    <br>
    <blockquote
cite="mid:CAOo=rxUdr6Cw-QEw=ty+ZfE08BdA+O2OjN8ZH_CWOBZCBkmTtA@mail.gmail.com"
      type="cite">
      <br>
      <div class="gmail_quote">On Mon, Mar 26, 2012 at 9:55 PM, Anthony
        Petrov <span dir="ltr">&lt;<a moz-do-not-send="true"
            href="mailto:anthony.petrov@oracle.com">anthony.petrov@oracle.com</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          Hi Sean,<br>
          <br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex"> &nbsp;92 &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; worker = Runtime.getRuntime().exec(System.getProperty("java.home")+"/bin/java
            TestDispose workprocess");<br>
          </blockquote>
          <br>
          This won't work on MS Windows because the path separator
          character is different there.<br>
          <br>
          Actually, I don't understand why you need this Runtime stuff
          in the first place. If test JVM doesn'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's JVM won't
          exit, and the test will fail by timeout eventually. Will this
          testing scenario work?<br>
          <br>
          --<br>
          best regards,<br>
          Anthony
          <div class="im"><br>
            <br>
            On 03/23/12 10:49, Sean Chou wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div class="im">
              <br>
              I modified the testcase according to Anthony Petrov's<br>
              suggestion(<a moz-do-not-send="true"
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 moz-do-not-send="true"
                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
                moz-do-not-send="true" href="mailto:son.two@gmail.com"
                target="_blank">son.two@gmail.com</a><br>
            </div>
            <div class="im">
              &lt;mailto:<a moz-do-not-send="true"
                href="mailto:son.two@gmail.com" target="_blank">son.two@gmail.com</a>&gt;&gt;
              wrote:<br>
              <br>
              &nbsp; &nbsp;On Thu, Mar 22, 2012 at 10:50 PM, Anton V. Tarasov<br>
            </div>
            <div class="im"> &nbsp; &nbsp;&lt;<a moz-do-not-send="true"
                href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>
              &lt;mailto:<a moz-do-not-send="true"
                href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>&gt;&gt;
              wrote:<br>
              &nbsp; &nbsp; &gt; On 3/22/12 6:15 PM, Oleg Sukhodolsky wrote:<br>
              &nbsp; &nbsp; &gt;&gt;<br>
              &nbsp; &nbsp; &gt;&gt; On Thu, Mar 22, 2012 at 5:55 PM, Anton V.
              Tarasov<br>
            </div>
            &nbsp; &nbsp; &gt;&gt; &lt;<a moz-do-not-send="true"
              href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>
            &lt;mailto:<a moz-do-not-send="true"
              href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>&gt;&gt;
            &nbsp;wrote:
            <div class="im">
              <br>
              &nbsp; &nbsp; &gt;&gt;&gt;<br>
              &nbsp; &nbsp; &gt;&gt;&gt; On 22.03.2012 14:37, Oleg Sukhodolsky
              wrote:<br>
              &nbsp; &nbsp; &gt;&gt;&gt;&gt;<br>
              &nbsp; &nbsp; &gt;&gt;&gt;&gt; On Thu, Mar 22, 2012 at 2:19 PM,
              Anton V. Tarasov<br>
            </div>
            &nbsp; &nbsp; &gt;&gt;&gt;&gt; &lt;<a moz-do-not-send="true"
              href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>
            &lt;mailto:<a moz-do-not-send="true"
              href="mailto:anton.tarasov@oracle.com" target="_blank">anton.tarasov@oracle.com</a>&gt;&gt;
            <div class="im">
              <br>
              &nbsp; &nbsp; &nbsp;wrote:<br>
              &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;<br>
              &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt; On 22.03.2012 12:47, Oleg
              Sukhodolsky wrote:<br>
              &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;<br>
              &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt; On Thu, Mar 22, 2012 at 12:01
              PM, Sean<br>
            </div>
            &nbsp; &nbsp;Chou&lt;<a moz-do-not-send="true"
              href="mailto:zhouyx@linux.vnet.ibm.com" target="_blank">zhouyx@linux.vnet.ibm.com</a>
            &lt;mailto:<a moz-do-not-send="true"
              href="mailto:zhouyx@linux.vnet.ibm.com" target="_blank">zhouyx@linux.vnet.ibm.com</a>&gt;&gt;
            <div>
              <div class="h5"><br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt; &nbsp;wrote:<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Hi Oleg,<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; &nbsp; &nbsp; Seem there are
                misunderstanding .<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; &nbsp; &nbsp; DefaultCaret can
                receive FocusLostEvent when another<br>
                &nbsp; &nbsp;control get<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; focused. But it<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; doesn't receive
                FocusLostEvent when disposing.<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; &nbsp; &nbsp; The reason is
                XTextAreaPeer doesn't receive<br>
                &nbsp; &nbsp;FocusLostEvent when<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; disposing. But<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; I don't know if it is a
                rule that a FocusLostEvent must be<br>
                &nbsp; &nbsp;sent to<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; the<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;&gt; focused&gt;&gt;&gt; &nbsp;
                &nbsp;component when the top-level window is disposed ?<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt; Well, for regular AWT
                component it is expected. &nbsp;And I'd<br>
                &nbsp; &nbsp;expect that<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;&gt; this should also be true
                for peer.<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt; That's right, focus_lost should
                be dispatched to a disposed focus<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;&gt; owner.<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt; So, now we need to figure out why
                the caret doesn't get the event.<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt;&gt; Oleg.<br>
                &nbsp; &nbsp; &gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt;&gt; I ran the testcase provided in the
                webrev and debugged a little.<br>
                &nbsp; &nbsp; &gt;&gt;&gt; FOCUS_LOST<br>
                &nbsp; &nbsp; &gt;&gt;&gt; does come to the textarea on its
                disposal, though when the<br>
                &nbsp; &nbsp;focus event is<br>
                &nbsp; &nbsp; &gt;&gt;&gt; being dispatched I see the peer is
                null.<br>
                &nbsp; &nbsp; &gt;&gt;&gt; This is quite expected actually. When
                Component.removeNotify()<br>
                &nbsp; &nbsp;is called<br>
                &nbsp; &nbsp; &gt;&gt;&gt; on<br>
                &nbsp; &nbsp; &gt;&gt;&gt; EDT, it transfers focus further
                (appropriate focus events get<br>
                &nbsp; &nbsp;queued) and<br>
                &nbsp; &nbsp; &gt;&gt;&gt; then nullifies the peer. The events
                come later.<br>
                &nbsp; &nbsp; &gt;&gt;&gt; Hope this helps.<br>
                &nbsp; &nbsp; &gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt; Thank you (I do not have Linux, so I can
                not debug this).<br>
                &nbsp; &nbsp; &gt;&gt; So, now we know that the cause of the
                problem is that our internal<br>
                &nbsp; &nbsp; &gt;&gt; AWTText(Field|Area) may be disposed while
                they think<br>
                &nbsp; &nbsp; &gt;&gt; that they are focused, and, at the same
                time, we can not propogate<br>
                &nbsp; &nbsp; &gt;&gt; real focus lost to them since peer is
                desposed<br>
                &nbsp; &nbsp; &gt;&gt; before we receive the event.<br>
                &nbsp; &nbsp; &gt;&gt; So, the suggested fix works fine for one
                particular problem<br>
                &nbsp; &nbsp;(unstopped<br>
                &nbsp; &nbsp; &gt;&gt; timer), but we may get some other<br>
                &nbsp; &nbsp; &gt;&gt; problems due to the cause.<br>
                &nbsp; &nbsp; &gt;&gt; For me it looks like better fix would be to
                pass synthetic focus<br>
                &nbsp; &nbsp;lost<br>
                &nbsp; &nbsp; &gt;&gt; when we dispose text peer, this way we
                guarantee<br>
                &nbsp; &nbsp; &gt;&gt; that life-circle of our synthetic
                components will be similar to real<br>
                &nbsp; &nbsp; &gt;&gt; ones and we will meet Swing's expectations.<br>
                &nbsp; &nbsp; &gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt; Does this sounds reasonable?<br>
                &nbsp; &nbsp; &gt;&gt;<br>
                &nbsp; &nbsp; &gt;&gt; Regards, Oleg.<br>
                &nbsp; &nbsp; &gt;<br>
                &nbsp; &nbsp; &gt;<br>
                &nbsp; &nbsp; &gt; This sounds reasonable, though I personally
                don't like the idea<br>
                &nbsp; &nbsp;of yet<br>
                &nbsp; &nbsp; &gt; another synthetic focus event...<br>
                <br>
                &nbsp; &nbsp;well, (synthetic) focus events are your area of
                expertise ;)<br>
                <br>
                &nbsp; &nbsp; &gt; I actually like the fix Sean suggested (after
                we see the whole<br>
                &nbsp; &nbsp;picture).<br>
                &nbsp; &nbsp; &gt; Otherwise, we may follow your suggestion<br>
                &nbsp; &nbsp; &gt; to create AWTTextArea.removeNotify(). And even
                simpler, why not<br>
                &nbsp; &nbsp;to put<br>
                &nbsp; &nbsp; &gt; getCaret().setVisible(false) right into<br>
                &nbsp; &nbsp;JTextComponent.removeNotify()?<br>
                <br>
                &nbsp; &nbsp;well, the later is a question for Swing team.<br>
                &nbsp; &nbsp;The former is reasonable fix (not the best one, but
                good enough).<br>
                &nbsp; &nbsp;So, if everyone agree with this approach then I'm
                fine (hope this is<br>
                &nbsp; &nbsp;the only problem we<br>
                &nbsp; &nbsp;will have with invisible focused JTextXXX)<br>
                <br>
                &nbsp; &nbsp;Oleg.<br>
                <br>
                &nbsp; &nbsp; &gt;<br>
                &nbsp; &nbsp; &gt; Either of these looks fine to me.<br>
                &nbsp; &nbsp; &gt;<br>
                &nbsp; &nbsp; &gt; Thanks,<br>
                &nbsp; &nbsp; &gt; Anton.<br>
                &nbsp; &nbsp; &gt;<br>
                &nbsp; &nbsp; &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>
  </body>
</html>