<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>looks good to me. Please add @key headful to test before pushing.<br>
    </p>
    Regards<br>
    Prasanta<br>
    <div class="moz-cite-prefix">On 8/23/2018 9:49 PM, Anton Litvinov
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:19806eb4-8b2a-b542-c633-26ab45c65fe3@oracle.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      I am sorry for an additional e-mail. In the previous e-mail I
      forgot to specify, that during the experiment not only JDK 11+28
      was used, but also JDK 8u181 b13 was used. The correction in the
      first sentence below is marked with the bold font style.<br>
      <br>
      <div class="moz-cite-prefix">On 23/08/2018 16:32, Anton Litvinov
        wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:790ef595-31d1-f0eb-5c05-ed1a12244d6b@oracle.com">Hello
        Prasanta, <br>
        <br>
        By your explicit request today I have verified and confirm that
        the bug is not reproducible on MS Windows 10 OS, Linux Ubuntu
        16.04.2 x86_64 OS with JDK 11+28<b>, JDK 8u181 b13</b>,
        therefore I confirm again that this bug is macOS specific. <br>
        <br>
        The root cause of the issue is described in my review request, I
        do not see a big reason to accomplish and provide here detailed
        comparisons of how printing area code related to this issue is
        implemented on all supported platforms; code for Windows, Linux,
        macOS platforms has differences. This fix is for this specific
        bug in macOS implementation of JDK. The bug is not reproducible
        on Windows and Linux, simply because JDK code for Windows, Linux
        does not involve calling the method
        "RasterPrinterJob.getPageFormatFromAttributes()". <br>
        <br>
        I do not want to alter any generic code under this bug record to
        address macOS specific issue, it will be certainly more error
        prone. <br>
        <br>
        Thank you, <br>
        Anton <br>
        <br>
        On 23/08/2018 06:40, Prasanta Sadhukhan wrote: <br>
        <blockquote type="cite">Hi Anton, <br>
          <br>
          One thing I would like to know..since you told this fix will
          only affects macOS platform, did you check if this is not
          reproducible in windows or linux, if not why? If yes, then
          maybe we should put the fix in more generic place!! <br>
          <br>
          Regards <br>
          Prasanta <br>
          On 8/23/2018 12:29 AM, Anton Litvinov wrote: <br>
          <blockquote type="cite">Hello Phil, <br>
            <br>
            Thank you for review of this fix. It is correct, this code
            area was already touched by 3 fixes which you specified, but
            they are just 2 attempts to fix the same issue and 1
            rollback of the 1st fix, which was dictated by the fact that
            at that time JDK 9 passed RDP 1. Answers to your questions
            are following: <br>
            <br>
            1.  No, absolutely, this bug is not a regression from the
            fix for 8181659. This bug exists in JDK for a long time,
            this is proved by the fact that I was able to reproduce it
            with JDK 8u112 b16, while the fix for 8167102 was never
            released in GA JDK 8 update, except for 1 released build JDK
            8u131 b32. I consider this bug as an independent issue from
            8167102, because of a difference in a test scenario (in
            8167102 "java.awt.print.Printable" interface is involved, in
            this bug "java.awt.print.Pageable" interface is involved),
            but at the same time they both have the same root cause. The
            end user, which reported 8167102 changed conditions by
            moving its application from setting "Printable" object to a
            printer job to setting "Pageable" object
            ("java.awt.print.Book") and encountered this issue. <br>
            <br>
            2.  Yes, sure, I verified that the bug 8167102 is still not
            reproducible with this fix by using the existing "jtreg"
            regression test
            "test/jdk/java/awt/print/PageFormat/WrongPaperPrintingTest.java".
            <br>
            <br>
            3.  Today I have run all available "jtreg" manual and
            automatic regression tests in the directories specified
            below and in our closed directories (total 189 tests) using
            both JDK 12 compiled without and with the fix, and verified
            that no new test failed on JDK 12 with the fix. <br>
            <br>
            Directories with the executed regression tests: <br>
            - "test/jdk/java/awt/print" <br>
            - "test/jdk/javax/print" <br>
            <br>
            4. Yes, I verified that the fix works as expected for
            specified by you 3 cases: <br>
            a)  no print dialog - attached to the bug record test case
            "PrintingAttributeBreaksBookPageSize.java" <br>
            b)  native print dialog - the created regression test
            "test/jdk/java/awt/print/PageFormat/WrongPaperForBookPrintingTest.java"
            <br>
            c)  swing print dialog - the regression test in point #b
            with modification in 1 line. <br>
            <br>
            Thank you, <br>
            Anton <br>
            <br>
            On 21/08/2018 00:37, Philip Race wrote: <br>
            <blockquote type="cite">Hi, <br>
              <br>
              The fix looks reasonable. <br>
              But we've touched the code being touched here quite
              recently and the history <br>
              there shows that this can be tricky to get right : <br>
              8167102: [macosx] PrintRequestAttributeSet breaks page
              size set using PageFormat <br>
              caused <br>
              8181192: [macos] javafx.print.PrinterJob.showPrintDialog()
              hangs on macOS <br>
              so then we had <br>
              8181659: Create an alternative fix for JDK-8167102, whose
              fix was backed out <br>
              <br>
              Is this new bug a regression caused by the previous fix ?
              <br>
              Have you verified the previous fix is still functional ? <br>
              What tests have been run ? <br>
              Can you make sure this works in the cases of <br>
              a) no dialog <br>
              b) swing dialog <br>
              c) native dialog. <br>
              <br>
              -phil. <br>
              <br>
              On 8/17/18, 12:42 PM, Anton Litvinov wrote: <br>
              <blockquote type="cite">Hello, <br>
                <br>
                Could you please review the following fix for the bug. <br>
                <br>
                Bug: <a class="moz-txt-link-freetext"
                  href="https://bugs.openjdk.java.net/browse/JDK-8201818"
                  moz-do-not-send="true">https://bugs.openjdk.java.net/browse/JDK-8201818</a>
                <br>
                Webrev: <a class="moz-txt-link-freetext"
                  href="http://cr.openjdk.java.net/%7Ealitvinov/8201818/jdk12/webrev.00"
                  moz-do-not-send="true">http://cr.openjdk.java.net/~alitvinov/8201818/jdk12/webrev.00</a>
                <br>
                <br>
                The bug consists in the fact that, if any one printing
                attribute is contained in "PrintRequestAttributeSet"
                during the call to
                "java.awt.print.PrinterJob.print(PrintRequestAttributeSet)"
                method, a page size from "java.awt.print.PageFormat"
                object provided by "java.awt.print.Book" set to a
                printer job through "PrinterJob.setPageable(Pageable)"
                method is not respected and the printer job prints the
                document on a page of a size equal to a default page
                size of a selected printer. <br>
                <br>
                CAUSE OF THE BUG: <br>
                The root cause of the bug is
                "sun.print.RasterPrinterJob.getPageFormatFromAttributes()"
                method which returns "PageFormat" object constructed
                from default settings of the selected printer, if the
                attribute set in the printer job is not empty. For the
                case in this bug, when the user explicitly sets "Book"
                object for the printer job, this method should not
                return anything except for "null", because: <br>
                <br>
                1. According to the documentation for the method
                "PrinterJob.print(PrintRequestAttributeSet)" from Java
                Platform SE 8 API Specification, if a user sets
                "java.awt.print.Pageable" object for "PrinterJob", then
                printing attributes related to media size, imageable
                area, page orientation will not influence anyhow the
                "PageFormat" object used for printing, and only
                "PageFormat" provided by the "Pageable" object will be
                used. <br>
                Statement: "For clients of the Pageable interface, the
                PageFormat will always be as supplied by that interface,
                on a per page basis." <br>
                Specification URL #1:
                <a class="moz-txt-link-freetext"
href="https://docs.oracle.com/javase/8/docs/api/java/awt/print/PrinterJob.html#print-javax.print.attribute.PrintRequestAttributeSet"
                  moz-do-not-send="true">https://docs.oracle.com/javase/8/docs/api/java/awt/print/PrinterJob.html#print-javax.print.attribute.PrintRequestAttributeSet</a>-<br>
                <br>
                2. Documentation on the method
                "PrinterJob.printDialog(PrintRequestAttributeSet)"
                acknowledges the point #1 by the statement "If using the
                Pageable interface, clients which intend to use media
                selected by the user must create a PageFormat derived
                from the user's selections.". <br>
                Specification URL #2:
                <a class="moz-txt-link-freetext"
href="https://docs.oracle.com/javase/8/docs/api/java/awt/print/PrinterJob.html#printDialog-javax.print.attribute.PrintRequestAttributeSet"
                  moz-do-not-send="true">https://docs.oracle.com/javase/8/docs/api/java/awt/print/PrinterJob.html#printDialog-javax.print.attribute.PrintRequestAttributeSet</a>-<br>
                <br>
                THE SOLUTION: <br>
                The solution consists in changing the method
                "RasterPrinterJob.getPageFormatFromAttributes()" to
                return "null" for cases, when the "Pageable" object set
                in the printer job is not an instance of
                "sun.print.OpenBook" class, which is exclusively used by
                the printer job to wrap "Printable" object set by the
                user through "PrinterJob.setPrintable(Printable)". <br>
                <br>
                The fix affects only macOS platform, because
                "RasterPrinterJob.getPageFormatFromAttributes()" method
                is called only from the macOS specific native code in
                the file
                "src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m".
                <br>
                <br>
                Thank you, <br>
                Anton <br>
              </blockquote>
            </blockquote>
            <br>
          </blockquote>
          <br>
        </blockquote>
        <br>
      </blockquote>
      <br>
    </blockquote>
    <br>
  </body>
</html>