changeset 11576:ebe88079b88e

Merge
author asaha
date Tue, 15 Dec 2015 14:38:09 -0800
parents f94285e53b66 8581249133fa
children 9e00a43602f8
files .hgtags test/sun/security/provider/certpath/ReverseBuilder/ReverseBuild.java
diffstat 8 files changed, 549 insertions(+), 385 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Dec 15 16:20:09 2015 +0300
+++ b/.hgtags	Tue Dec 15 14:38:09 2015 -0800
@@ -501,6 +501,7 @@
 ea7a705eab9e6495d08a92ff21e0370b68374c54 jdk8u66-b33
 72ab45285f0e8293aa63e889bc75f0287b6e0436 jdk8u66-b34
 e169a214f1f096af6b57169eeb0ba66ee5e9caa3 jdk8u66-b35
+430a8d04d8358206b682323f61405f951f43c773 jdk8u66-b36
 9a2747ef337bdee71bc8225dea77eb403cca1179 jdk8u71-b00
 e8b5e10a19d66a77d04f12d4677e6fec66f79651 jdk8u71-b01
 25d689a73bc037e1710f95f6d4acf0671d22047d jdk8u71-b02
@@ -514,6 +515,7 @@
 e494e93d48f943229223d881a2928064a69cdf23 jdk8u71-b10
 32226f73879f21f7a7bb024f4197c089b53a93c4 jdk8u71-b11
 8181f8b6ef0d861f57547c89e52f258cb5583b77 jdk8u71-b12
+23a6e0931277e7d4278605f55db2c81fcb3907b0 jdk8u71-b13
 be5faa9c77042f202106c18f4e8ea211137b4a3b jdk8u72-b00
 5ad1e9e8e8417f80c91d7e0f1f44cdf89b34ead3 jdk8u72-b01
 ab0c1040414d038ccbcfcc8ceb1ccf2f44ead8e4 jdk8u72-b02
@@ -527,4 +529,5 @@
 dcf7fd07b08b59e1802851d016d913c254221a44 jdk8u72-b10
 d7cc3225f1050de03b236b92e12c547f21697013 jdk8u72-b11
 8afb58c7312b45fe5237afb0292176b734934f60 jdk8u72-b12
+d841d3fdae44f120883dab0a3a809a054cd0274b jdk8u72-b13
 7cfd2c51c501df909833aa0fb6e40c50c61621ed jdk8u75-b00
--- a/src/share/classes/sun/font/TrueTypeFont.java	Tue Dec 15 16:20:09 2015 +0300
+++ b/src/share/classes/sun/font/TrueTypeFont.java	Tue Dec 15 14:38:09 2015 -0800
@@ -171,6 +171,13 @@
     private String localeFamilyName;
     private String localeFullName;
 
+    public TrueTypeFont(String platname, Object nativeNames, int fIndex,
+                 boolean javaRasterizer)
+        throws FontFormatException
+    {
+        this(platname, nativeNames, fIndex, javaRasterizer, true);
+    }
+
     /**
      * - does basic verification of the file
      * - reads the header table for this font (within a collection)
@@ -181,14 +188,17 @@
      * or fails verification,  or there's no usable cmap
      */
     public TrueTypeFont(String platname, Object nativeNames, int fIndex,
-                 boolean javaRasterizer)
+                 boolean javaRasterizer, boolean useFilePool)
         throws FontFormatException {
         super(platname, nativeNames);
         useJavaRasterizer = javaRasterizer;
         fontRank = Font2D.TTF_RANK;
         try {
-            verify();
+            verify(useFilePool);
             init(fIndex);
+            if (!useFilePool) {
+               close();
+            }
         } catch (Throwable t) {
             close();
             if (t instanceof FontFormatException) {
@@ -275,6 +285,10 @@
     }
 
 
+    private synchronized FileChannel open() throws FontFormatException {
+        return open(true);
+     }
+
     /* This is intended to be called, and the returned value used,
      * from within a block synchronized on this font object.
      * ie the channel returned may be nulled out at any time by "close()"
@@ -282,7 +296,8 @@
      * Deadlock warning: FontManager.addToPool(..) acquires a global lock,
      * which means nested locks may be in effect.
      */
-    private synchronized FileChannel open() throws FontFormatException {
+    private synchronized FileChannel open(boolean usePool)
+                                     throws FontFormatException {
         if (disposerRecord.channel == null) {
             if (FontUtilities.isLogging()) {
                 FontUtilities.getLogger().info("open TTF: " + platName);
@@ -301,9 +316,11 @@
                 });
                 disposerRecord.channel = raf.getChannel();
                 fileSize = (int)disposerRecord.channel.size();
-                FontManager fm = FontManagerFactory.getInstance();
-                if (fm instanceof SunFontManager) {
-                    ((SunFontManager) fm).addToPool(this);
+                if (usePool) {
+                    FontManager fm = FontManagerFactory.getInstance();
+                    if (fm instanceof SunFontManager) {
+                        ((SunFontManager) fm).addToPool(this);
+                    }
                 }
             } catch (NullPointerException e) {
                 close();
@@ -487,8 +504,8 @@
         }
     }
 
-    private void verify() throws FontFormatException {
-        open();
+    private void verify(boolean usePool) throws FontFormatException {
+        open(usePool);
     }
 
     /* sizes, in bytes, of TT/TTC header records */
--- a/src/windows/classes/sun/awt/Win32FontManager.java	Tue Dec 15 16:20:09 2015 +0300
+++ b/src/windows/classes/sun/awt/Win32FontManager.java	Tue Dec 15 14:38:09 2015 -0800
@@ -63,7 +63,7 @@
                              * enumerate (allow direct use) of EUDC fonts.
                              */
                             eudcFont = new TrueTypeFont(eudcFile, null, 0,
-                                                        true);
+                                                        true, false);
                         } catch (FontFormatException e) {
                         }
                     }
--- a/src/windows/classes/sun/awt/windows/WPathGraphics.java	Tue Dec 15 16:20:09 2015 +0300
+++ b/src/windows/classes/sun/awt/windows/WPathGraphics.java	Tue Dec 15 14:38:09 2015 -0800
@@ -494,24 +494,48 @@
          */
         float fontSize = font.getSize2D();
 
+        double devResX = wPrinterJob.getXRes();
+        double devResY = wPrinterJob.getYRes();
+
+        double fontDevScaleY = devResY / DEFAULT_USER_RES;
+
+        int orient = getPageFormat().getOrientation();
+        if (orient == PageFormat.LANDSCAPE ||
+            orient == PageFormat.REVERSE_LANDSCAPE)
+        {
+            double tmp = devResX;
+            devResX = devResY;
+            devResY = tmp;
+        }
+
+        double devScaleX = devResX / DEFAULT_USER_RES;
+        double devScaleY = devResY / DEFAULT_USER_RES;
+        fontTransform.scale(1.0/devScaleX, 1.0/devScaleY);
+
         Point2D.Double pty = new Point2D.Double(0.0, 1.0);
         fontTransform.deltaTransform(pty, pty);
         double scaleFactorY = Math.sqrt(pty.x*pty.x+pty.y*pty.y);
-        float scaledFontSizeY = (float)(fontSize * scaleFactorY);
+        float scaledFontSizeY = (float)(fontSize * scaleFactorY * fontDevScaleY);
 
         Point2D.Double ptx = new Point2D.Double(1.0, 0.0);
         fontTransform.deltaTransform(ptx, ptx);
         double scaleFactorX = Math.sqrt(ptx.x*ptx.x+ptx.y*ptx.y);
-        float scaledFontSizeX = (float)(fontSize * scaleFactorX);
 
         float awScale = getAwScale(scaleFactorX, scaleFactorY);
         int iangle = getAngle(ptx);
 
+        ptx = new Point2D.Double(1.0, 0.0);
+        deviceTransform.deltaTransform(ptx, ptx);
+        double advanceScaleX = Math.sqrt(ptx.x*ptx.x+ptx.y*ptx.y);
+        pty = new Point2D.Double(0.0, 1.0);
+        deviceTransform.deltaTransform(pty, pty);
+        double advanceScaleY = Math.sqrt(pty.x*pty.x+pty.y*pty.y);
+
         Font2D font2D = FontUtilities.getFont2D(font);
         if (font2D instanceof TrueTypeFont) {
             textOut(str, font, (TrueTypeFont)font2D, frc,
                     scaledFontSizeY, iangle, awScale,
-                    deviceTransform, scaleFactorX,
+                    advanceScaleX, advanceScaleY,
                     x, y, devpos.x, devpos.y, targetW);
         } else if (font2D instanceof CompositeFont) {
             /* Composite fonts are made up of multiple fonts and each
@@ -542,7 +566,7 @@
                 PhysicalFont slotFont = compFont.getSlotFont(slot);
                 textOut(substr, font, slotFont, frc,
                         scaledFontSizeY, iangle, awScale,
-                        deviceTransform, scaleFactorX,
+                        advanceScaleX, advanceScaleY,
                         userx, usery, devx, devy, 0f);
                 Rectangle2D bds = font.getStringBounds(substr, frc);
                 float xAdvance = (float)bds.getWidth();
@@ -635,18 +659,42 @@
          */
         float fontSize = font.getSize2D();
 
+        double devResX = wPrinterJob.getXRes();
+        double devResY = wPrinterJob.getYRes();
+
+        double fontDevScaleY = devResY / DEFAULT_USER_RES;
+
+        int orient = getPageFormat().getOrientation();
+        if (orient == PageFormat.LANDSCAPE ||
+            orient == PageFormat.REVERSE_LANDSCAPE)
+        {
+            double tmp = devResX;
+            devResX = devResY;
+            devResY = tmp;
+        }
+
+        double devScaleX = devResX / DEFAULT_USER_RES;
+        double devScaleY = devResY / DEFAULT_USER_RES;
+        fontTransform.scale(1.0/devScaleX, 1.0/devScaleY);
+
         Point2D.Double pty = new Point2D.Double(0.0, 1.0);
         fontTransform.deltaTransform(pty, pty);
         double scaleFactorY = Math.sqrt(pty.x*pty.x+pty.y*pty.y);
-        float scaledFontSizeY = (float)(fontSize * scaleFactorY);
+        float scaledFontSizeY = (float)(fontSize * scaleFactorY * fontDevScaleY);
 
-        Point2D.Double pt = new Point2D.Double(1.0, 0.0);
-        fontTransform.deltaTransform(pt, pt);
-        double scaleFactorX = Math.sqrt(pt.x*pt.x+pt.y*pt.y);
-        float scaledFontSizeX = (float)(fontSize * scaleFactorX);
+        Point2D.Double ptx = new Point2D.Double(1.0, 0.0);
+        fontTransform.deltaTransform(ptx, ptx);
+        double scaleFactorX = Math.sqrt(ptx.x*ptx.x+ptx.y*ptx.y);
 
         float awScale = getAwScale(scaleFactorX, scaleFactorY);
-        int iangle = getAngle(pt);
+        int iangle = getAngle(ptx);
+
+        ptx = new Point2D.Double(1.0, 0.0);
+        deviceTransform.deltaTransform(ptx, ptx);
+        double advanceScaleX = Math.sqrt(ptx.x*ptx.x+ptx.y*ptx.y);
+        pty = new Point2D.Double(0.0, 1.0);
+        deviceTransform.deltaTransform(pty, pty);
+        double advanceScaleY = Math.sqrt(pty.x*pty.x+pty.y*pty.y);
 
         int numGlyphs = gv.getNumGlyphs();
         int[] glyphCodes = gv.getGlyphCodes(0, numGlyphs, null);
@@ -705,8 +753,7 @@
          * rotation element of the deviceTransform.
          */
         AffineTransform advanceTransform =
-            new AffineTransform(deviceTransform);
-        advanceTransform.rotate(iangle*Math.PI/1800.0);
+           AffineTransform.getScaleInstance(advanceScaleX, advanceScaleY);
         float[] glyphAdvPos = new float[glyphPos.length];
 
         advanceTransform.transform(glyphPos, 0,         //source
@@ -784,8 +831,7 @@
                           Font font, PhysicalFont font2D,
                           FontRenderContext frc,
                           float deviceSize, int rotation, float awScale,
-                          AffineTransform deviceTransform,
-                          double scaleFactorX,
+                          double scaleFactorX, double scaleFactorY,
                           float userx, float usery,
                           float devx, float devy, float targetW) {
 
@@ -826,8 +872,7 @@
               * See earlier comment in printGlyphVector() for details.
               */
              AffineTransform advanceTransform =
-               new AffineTransform(deviceTransform);
-             advanceTransform.rotate(rotation*Math.PI/1800.0);
+                AffineTransform.getScaleInstance(scaleFactorX, scaleFactorY);
              float[] glyphAdvPos = new float[glyphPos.length];
 
              advanceTransform.transform(glyphPos, 0,         //source
@@ -841,11 +886,11 @@
      /* If 2D and GDI agree on the advance of the string we do not
       * need to explicitly assign glyph positions.
       * If we are to use the GDI advance, require it to agree with
-      * JDK to a precision of <= 0.2% - ie 1 pixel in 500
+      * JDK to a precision of <= 1.0% - ie 1 pixel in 100
       * discrepancy after rounding the 2D advance to the
       * nearest pixel and is greater than one pixel in total.
-      * ie strings < 500 pixels in length will be OK so long
-      * as they differ by only 1 pixel even though that is > 0.02%
+      * ie strings < 100 pixels in length will be OK so long
+      * as they differ by only 1 pixel even though that is > 1%
       * The bounds from 2D are in user space so need to
       * be scaled to device space for comparison with GDI.
       * scaleX is the scale from user space to device space needed for this.
@@ -863,7 +908,7 @@
              if (ratio < 1) {
                  ratio = 1/ratio;
              }
-             return diff <= 1 || ratio < 1.002;
+             return diff <= 1 || ratio < 1.01;
          }
          return true;
      }
--- a/src/windows/native/java/net/Inet4AddressImpl.c	Tue Dec 15 16:20:09 2015 +0300
+++ b/src/windows/native/java/net/Inet4AddressImpl.c	Tue Dec 15 14:38:09 2015 -0800
@@ -480,6 +480,7 @@
     char SendData[32] = {0};
     LPVOID ReplyBuffer = NULL;
     DWORD ReplySize = 0;
+    jboolean ret = JNI_FALSE;
 
     hIcmpFile = IcmpCreateFile();
     if (hIcmpFile == INVALID_HANDLE_VALUE) {
@@ -503,7 +504,11 @@
                                 NULL,       // PIP_OPTION_INFORMATION RequestOptions,
                                 ReplyBuffer,// LPVOID ReplyBuffer,
                                 ReplySize,  // DWORD ReplySize,
-                                timeout);   // DWORD Timeout
+                                // Note: IcmpSendEcho and its derivatives
+                                // seem to have an undocumented minimum
+                                // timeout of 1000ms below which the
+                                // api behaves inconsistently.
+                                (timeout < 1000) ? 1000 : timeout);   // DWORD Timeout
     } else {
         dwRetVal = IcmpSendEcho2Ex(hIcmpFile,  // HANDLE IcmpHandle,
                                    NULL,       // HANDLE Event
@@ -516,17 +521,19 @@
                                    NULL,       // PIP_OPTION_INFORMATION RequestOptions,
                                    ReplyBuffer,// LPVOID ReplyBuffer,
                                    ReplySize,  // DWORD ReplySize,
-                                   timeout);   // DWORD Timeout
+                                   (timeout < 1000) ? 1000 : timeout);   // DWORD Timeout
+    }
+
+    if (dwRetVal != 0) {
+        PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
+        if ((int)pEchoReply->RoundTripTime <= timeout)
+            ret = JNI_TRUE;
     }
 
     free(ReplyBuffer);
     IcmpCloseHandle(hIcmpFile);
 
-    if (dwRetVal != 0) {
-        return JNI_TRUE;
-    } else {
-        return JNI_FALSE;
-    }
+    return ret;
 }
 
 /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintTextTest.html	Tue Dec 15 14:38:09 2015 -0800
@@ -0,0 +1,46 @@
+<!--
+ Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<body>
+<applet  code="PrintTextTest.class" width=400 height=100></applet>
+This tests that printed text renders similarly to on-screen,
+under a variety of APIs and graphics and font transforms
+Print to your preferred printer. Collect the output.
+Refer to the onscreen buttons to cycle through the on-screen
+content
+For each page, confirm that the printed content corresponds to
+the on-screen rendering for that *same* page.
+Some cases may look odd but its intentional. Verify
+it looks the same on screen and on the printer.
+Note that text does not scale linearly from screen to printer
+so some differences are normal and not a bug.
+The easiest way to spot real problems is to check that
+any underlines are the same length as the underlined text
+and that any rotations are the same in each case.
+Note that each on-screen page is printed in both portrait
+and landscape mode
+So for example, Page 1/Portrait, and Page 1/Landscape when
+rotated to view properly, should both match Page 1 on screen.;
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintTextTest.java	Tue Dec 15 14:38:09 2015 -0800
@@ -0,0 +1,395 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/**
+ * @test
+ * @bug 6425068 7157659 8132890
+ * @summary Confirm that text prints where we expect to the length we expect.
+ * @run applet/manual=yesno PrintTextTest.html
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.text.*;
+import java.util.*;
+import java.awt.font.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import javax.swing.*;
+
+public class PrintTextTest extends JApplet {
+    public void start() {
+        StandalonePrintTextTest.main(null);
+    }
+}
+
+class StandalonePrintTextTest extends Component implements Printable {
+
+    static int preferredSize;
+    Font textFont;
+    AffineTransform gxTx;
+    String page;
+    boolean useFM;
+
+    public static void main(String args[]) {
+
+        PrinterJob pjob = PrinterJob.getPrinterJob();
+        PageFormat portrait = pjob.defaultPage();
+        portrait.setOrientation(PageFormat.PORTRAIT);
+        preferredSize = (int)portrait.getImageableWidth();
+
+        PageFormat landscape = pjob.defaultPage();
+        landscape.setOrientation(PageFormat.LANDSCAPE);
+
+        Book book = new Book();
+
+        JTabbedPane p = new JTabbedPane();
+
+        int page = 1;
+        Font font = new Font("Dialog", Font.PLAIN, 18);
+        String name = "Page " + new Integer(page++);
+        StandalonePrintTextTest ptt = new StandalonePrintTextTest(name, font, null, false);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Dialog", Font.PLAIN, 18);
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, font, null, true);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Lucida Sans", Font.PLAIN, 18);
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, font, null, false);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Lucida Sans", Font.PLAIN, 18);
+        AffineTransform rotTx = AffineTransform.getRotateInstance(0.15);
+        rotTx.translate(60,0);
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, font, rotTx, false);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Dialog", Font.PLAIN, 18);
+        AffineTransform scaleTx = AffineTransform.getScaleInstance(1.25, 1.25);
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, font, scaleTx, false);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Dialog", Font.PLAIN, 18);
+        scaleTx = AffineTransform.getScaleInstance(-1.25, 1.25);
+        scaleTx.translate(-preferredSize/1.25, 0);
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, font, scaleTx, false);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Dialog", Font.PLAIN, 18);
+        scaleTx = AffineTransform.getScaleInstance(1.25, -1.25);
+        scaleTx.translate(0, -preferredSize/1.25);
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, font, scaleTx, false);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = font.deriveFont(rotTx);
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, font, null, false);
+        p.add(ptt, BorderLayout.CENTER);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Monospaced", Font.PLAIN, 12);
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, font, null, false);
+        p.add(ptt, BorderLayout.CENTER);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        Font xfont = font.deriveFont(AffineTransform.getScaleInstance(1.5, 1));
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, xfont, null, false);
+        p.add(ptt, BorderLayout.CENTER);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        Font yfont = font.deriveFont(AffineTransform.getScaleInstance(1, 1.5));
+        name = "Page " + new Integer(page++);
+        ptt = new StandalonePrintTextTest(name, yfont, null, false);
+        p.add(ptt, BorderLayout.CENTER);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        if (System.getProperty("os.name").startsWith("Windows")) {
+            font = new Font("MS Gothic", Font.PLAIN, 12);
+            name = "Page " + new Integer(page++);
+            ptt = new PrintJAText(name, font, null, true);
+            p.add(ptt, BorderLayout.CENTER);
+            p.add(name, ptt);
+            book.append(ptt, portrait);
+            book.append(ptt, landscape);
+
+            font = new Font("MS Gothic", Font.PLAIN, 12);
+            name = "Page " + new Integer(page++);
+            rotTx = AffineTransform.getRotateInstance(0.15);
+            ptt = new PrintJAText(name, font, rotTx, true);
+            p.add(ptt, BorderLayout.CENTER);
+            p.add(name, ptt);
+            book.append(ptt, portrait);
+            book.append(ptt, landscape);
+        }
+
+        pjob.setPageable(book);
+
+        JFrame f = new JFrame();
+        f.add(BorderLayout.CENTER, p);
+        f.addWindowListener(new WindowAdapter() {
+            public void windowClosing(WindowEvent e) {System.exit(0);}
+        });
+        f.pack();
+        f.show();
+
+        try {
+            if (pjob.printDialog()) {
+                pjob.print();
+            }
+        } catch (PrinterException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    public StandalonePrintTextTest(String page, Font font, AffineTransform gxTx,
+                         boolean fm) {
+        this.page = page;
+        textFont = font;
+        this.gxTx = gxTx;
+        this.useFM = fm;
+        setBackground(Color.white);
+    }
+
+    public static AttributedCharacterIterator getIterator(String s) {
+        return new AttributedString(s).getIterator();
+    }
+
+    static String orient(PageFormat pf) {
+        if (pf.getOrientation() == PageFormat.PORTRAIT) {
+            return "Portrait";
+        } else {
+            return "Landscape";
+        }
+    }
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.translate(pf.getImageableX(),  pf.getImageableY());
+        g.drawString(page+" "+orient(pf),50,20);
+        g.translate(0, 25);
+        paint(g);
+        return PAGE_EXISTS;
+    }
+
+    public Dimension getMinimumSize() {
+        return getPreferredSize();
+    }
+
+    public Dimension getPreferredSize() {
+        return new Dimension(preferredSize, preferredSize);
+    }
+
+    public void paint(Graphics g) {
+
+        /* fill with white before any transformation is applied */
+        g.setColor(Color.white);
+        g.fillRect(0, 0, getSize().width, getSize().height);
+
+
+        Graphics2D g2d = (Graphics2D) g;
+        if (gxTx != null) {
+            g2d.transform(gxTx);
+        }
+        if (useFM) {
+            g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        }
+
+        g.setFont(textFont);
+        FontMetrics fm = g.getFontMetrics();
+
+        String s;
+        int LS = 30;
+        int ix=10, iy=LS+10;
+        g.setColor(Color.black);
+
+        s = "drawString(String str, int x, int y)";
+        g.drawString(s, ix, iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+        }
+
+        iy += LS;
+        s = "drawString(AttributedCharacterIterator iterator, int x, int y)";
+        g.drawString(getIterator(s), ix, iy);
+
+        iy += LS;
+        s = "\tdrawChars(\t\r\nchar[], int off, int len, int x, int y\t)";
+        g.drawChars(s.toCharArray(), 0, s.length(), ix, iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+        }
+
+        iy += LS;
+        s = "drawBytes(byte[], int off, int len, int x, int y)";
+        byte data[] = new byte[s.length()];
+        for (int i = 0; i < data.length; i++) {
+            data[i] = (byte) s.charAt(i);
+        }
+        g.drawBytes(data, 0, data.length, ix, iy);
+
+        Font f = g2d.getFont();
+        FontRenderContext frc = g2d.getFontRenderContext();
+
+        iy += LS;
+        s = "drawString(String s, float x, float y)";
+        g2d.drawString(s, (float) ix, (float) iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+        }
+
+        iy += LS;
+        s = "drawString(AttributedCharacterIterator iterator, "+
+            "float x, float y)";
+        g2d.drawString(getIterator(s), (float) ix, (float) iy);
+
+        iy += LS;
+        s = "drawGlyphVector(GlyphVector g, float x, float y)";
+        GlyphVector gv = f.createGlyphVector(frc, s);
+        g2d.drawGlyphVector(gv, ix, iy);
+        Point2D adv = gv.getGlyphPosition(gv.getNumGlyphs());
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+(int)adv.getX(), iy+1);
+        }
+
+        iy += LS;
+        s = "GlyphVector with position adjustments";
+
+        gv = f.createGlyphVector(frc, s);
+        int ng = gv.getNumGlyphs();
+        adv = gv.getGlyphPosition(ng);
+        for (int i=0; i<ng; i++) {
+            Point2D gp = gv.getGlyphPosition(i);
+            double gx = gp.getX();
+            double gy = gp.getY();
+            if (i % 2 == 0) {
+                gy+=5;
+            } else {
+                gy-=5;
+            }
+            gp.setLocation(gx, gy);
+            gv.setGlyphPosition(i, gp);
+        }
+        g2d.drawGlyphVector(gv, ix, iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+(int)adv.getX(), iy+1);
+        }
+
+        iy +=LS;
+        s = "drawString: \u0924\u094d\u0930 \u0915\u0948\u0930\u0947 End.";
+        g.drawString(s, ix, iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+        }
+
+        iy += LS;
+        s = "TextLayout 1: \u0924\u094d\u0930 \u0915\u0948\u0930\u0947 End.";
+        TextLayout tl = new TextLayout(s, new HashMap(), frc);
+        tl.draw(g2d,  ix, iy);
+
+        iy += LS;
+        s = "TextLayout 2: \u0924\u094d\u0930 \u0915\u0948\u0930\u0947 End.";
+        tl = new TextLayout(s, f, frc);
+        tl.draw(g2d,  ix, iy);
+    }
+}
+
+class PrintJAText extends StandalonePrintTextTest {
+
+
+    public PrintJAText(String page, Font font, AffineTransform gxTx,
+                         boolean fm) {
+        super(page, font, gxTx, fm);
+    }
+
+    private static final String TEXT =
+        "\u3042\u3044\u3046\u3048\u304a\u30a4\u30ed\u30cf" +
+        "\u30cb\u30db\u30d8\u30c8\u4e00\u4e01\u4e02\u4e05\uff08";
+
+
+    public void paint(Graphics g) {
+
+        /* fill with white before any transformation is applied */
+        g.setColor(Color.white);
+        g.fillRect(0, 0, getSize().width, getSize().height);
+
+
+        Graphics2D g2d = (Graphics2D) g;
+        if (gxTx != null) {
+            g2d.transform(gxTx);
+        }
+        if (useFM) {
+            g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        }
+
+        String text = TEXT + TEXT + TEXT;
+        g.setColor(Color.black);
+        int y = 20;
+        float origSize = 7f;
+        for (int i=0;i<11;i++) {
+            float size = origSize+(i*0.1f);
+            g2d.translate(0, size+6);
+            Font f = textFont.deriveFont(size);
+            g2d.setFont(f);
+            FontMetrics fontMetrics = g2d.getFontMetrics();
+            int stringWidth = fontMetrics.stringWidth(text);
+            g.drawLine(0, y+1, stringWidth, y+1);
+            g.drawString(text, 0, y);
+            y +=10;
+        }
+    }
+}
--- a/test/sun/security/provider/certpath/ReverseBuilder/ReverseBuild.java	Tue Dec 15 16:20:09 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,349 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 7167988
- * @summary PKIX CertPathBuilder in reverse mode doesn't work if more than
- *          one trust anchor is specified
- * @run main/othervm ReverseBuild
- */
-import java.io.*;
-import java.util.*;
-import java.security.cert.*;
-
-import sun.security.provider.certpath.SunCertPathBuilderParameters;
-
-public class ReverseBuild {
-    // Certificate information:
-    // Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org
-    // Validity
-    //     Not Before: Dec  8 02:43:36 2008 GMT
-    //     Not After : Aug 25 02:43:36 2028 GMT
-    // Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org
-    // X509v3 Subject Key Identifier:
-    //     FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14
-    // X509v3 Authority Key Identifier:
-    //     keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14
-    //     DirName:/C=US/ST=Some-State/L=Some-City/O=Some-Org
-    //     serial:00
-    static String NoiceTrusedCertStr =
-        "-----BEGIN CERTIFICATE-----\n" +
-        "MIICrDCCAhWgAwIBAgIBADANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" +
-        "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" +
-        "EwhTb21lLU9yZzAeFw0wODEyMDgwMjQzMzZaFw0yODA4MjUwMjQzMzZaMEkxCzAJ\n" +
-        "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" +
-        "dHkxETAPBgNVBAoTCFNvbWUtT3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n" +
-        "gQDLxDggB76Ip5OwoUNRLdeOha9U3a2ieyNbz5kTU5lFfe5tui2/461uPZ8a+QOX\n" +
-        "4BdVrhEmV94BKY4FPyH35zboLjfXSKxT1mAOx1Bt9sWF94umxZE1cjyU7vEX8HHj\n" +
-        "7BvOyk5AQrBt7moO1uWtPA/JuoJPePiJl4kqlRJM2Akq6QIDAQABo4GjMIGgMB0G\n" +
-        "A1UdDgQWBBT6uVG/TOfZhpgz+efLHvEzSfeoFDBxBgNVHSMEajBogBT6uVG/TOfZ\n" +
-        "hpgz+efLHvEzSfeoFKFNpEswSTELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUt\n" +
-        "U3RhdGUxEjAQBgNVBAcTCVNvbWUtQ2l0eTERMA8GA1UEChMIU29tZS1PcmeCAQAw\n" +
-        "DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQBcIm534U123Hz+rtyYO5uA\n" +
-        "ofd81G6FnTfEAV8Kw9fGyyEbQZclBv34A9JsFKeMvU4OFIaixD7nLZ/NZ+IWbhmZ\n" +
-        "LovmJXyCkOufea73pNiZ+f/4/ScZaIlM/PRycQSqbFNd4j9Wott+08qxHPLpsf3P\n" +
-        "6Mvf0r1PNTY2hwTJLJmKtg==\n" +
-        "-----END CERTIFICATE-----";
-
-    // Certificate information:
-    // Issuer: C=US, O=Java, OU=SunJSSE Test Serivce
-    // Validity
-    //     Not Before: Aug 19 01:52:19 2011 GMT
-    //     Not After : Jul 29 01:52:19 2032 GMT
-    // Subject: C=US, O=Java, OU=SunJSSE Test Serivce
-
-    // X509v3 Subject Key Identifier:
-    //     B9:7C:D5:D9:DF:A7:4C:03:AE:FD:0E:27:5B:31:95:6C:C7:F3:75:E1
-    // X509v3 Authority Key Identifier:
-    //     keyid:B9:7C:D5:D9:DF:A7:4C:03:AE:FD:0E:27:5B:31:95:6C:C7:F3:75:E1
-    //     DirName:/C=US/O=Java/OU=SunJSSE Test Serivce
-    //     serial:00
-    static String NoiceTrusedCertStr_2nd =
-        "-----BEGIN CERTIFICATE-----\n" +
-        "MIICkjCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" +
-        "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" +
-        "MTEwODE5MDE1MjE5WhcNMzIwNzI5MDE1MjE5WjA7MQswCQYDVQQGEwJVUzENMAsG\n" +
-        "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwgZ8wDQYJ\n" +
-        "KoZIhvcNAQEBBQADgY0AMIGJAoGBAM8orG08DtF98TMSscjGsidd1ZoN4jiDpi8U\n" +
-        "ICz+9dMm1qM1d7O2T+KH3/mxyox7Rc2ZVSCaUD0a3CkhPMnlAx8V4u0H+E9sqso6\n" +
-        "iDW3JpOyzMExvZiRgRG/3nvp55RMIUV4vEHOZ1QbhuqG4ebN0Vz2DkRft7+flthf\n" +
-        "vDld6f5JAgMBAAGjgaUwgaIwHQYDVR0OBBYEFLl81dnfp0wDrv0OJ1sxlWzH83Xh\n" +
-        "MGMGA1UdIwRcMFqAFLl81dnfp0wDrv0OJ1sxlWzH83XhoT+kPTA7MQswCQYDVQQG\n" +
-        "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" +
-        "Y2WCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAQYwDQYJKoZIhvcNAQEE\n" +
-        "BQADgYEALlgaH1gWtoBZ84EW8Hu6YtGLQ/L9zIFmHonUPZwn3Pr//icR9Sqhc3/l\n" +
-        "pVTxOINuFHLRz4BBtEylzRIOPzK3tg8XwuLb1zd0db90x3KBCiAL6E6cklGEPwLe\n" +
-        "XYMHDn9eDsaq861Tzn6ZwzMgw04zotPMoZN0mVd/3Qca8UJFucE=\n" +
-        "-----END CERTIFICATE-----";
-
-
-    // Certificate information:
-    // Issuer: C=US, O=Java, OU=SunJSSE Test Serivce
-    // Validity
-    //     Not Before: May  5 02:40:50 2012 GMT
-    //     Not After : Apr 15 02:40:50 2033 GMT
-    // Subject: C=US, O=Java, OU=SunJSSE Test Serivce
-    // X509v3 Subject Key Identifier:
-    //     DD:4E:8D:2A:11:C0:83:03:F0:AC:EB:A2:BF:F9:F2:7D:C8:69:1F:9B
-    // X509v3 Authority Key Identifier:
-    //     keyid:DD:4E:8D:2A:11:C0:83:03:F0:AC:EB:A2:BF:F9:F2:7D:C8:69:1F:9B
-    //     DirName:/C=US/O=Java/OU=SunJSSE Test Serivce
-    //     serial:00
-    static String trustedCertStr =
-        "-----BEGIN CERTIFICATE-----\n" +
-        "MIICkjCCAfugAwIBAgIBADANBgkqhkiG9w0BAQIFADA7MQswCQYDVQQGEwJVUzEN\n" +
-        "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" +
-        "MTIwNTA1MDI0MDUwWhcNMzMwNDE1MDI0MDUwWjA7MQswCQYDVQQGEwJVUzENMAsG\n" +
-        "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwgZ8wDQYJ\n" +
-        "KoZIhvcNAQEBBQADgY0AMIGJAoGBANtiq0AIJK+iVRwFrqcD7fYXTCbMYC5Qz/k6\n" +
-        "AXBy7/1rI8wDhEJLE3m/+NSqiJwZcmdq2dNh/1fJFrwvzuURbc9+paOBWeHbN+Sc\n" +
-        "x3huw91oPZme385VpoK3G13rSE114S/rF4DM9mz4EStFhSHXATjtdbskNOAYGLTV\n" +
-        "x8uEy9GbAgMBAAGjgaUwgaIwHQYDVR0OBBYEFN1OjSoRwIMD8Kzror/58n3IaR+b\n" +
-        "MGMGA1UdIwRcMFqAFN1OjSoRwIMD8Kzror/58n3IaR+boT+kPTA7MQswCQYDVQQG\n" +
-        "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" +
-        "Y2WCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAQYwDQYJKoZIhvcNAQEC\n" +
-        "BQADgYEAjjkJesQrkbr36N40egybaIxw7RcqT6iy5fkAGS1JYlBDk8uSCK1o6bCH\n" +
-        "ls5EpYcGeEoabSS73WRdkO1lgeyWDduO4ef8cCCSpmpT6/YdZG0QS1PtcREeVig+\n" +
-        "Zr25jNemS4ADHX0aaXP4kiV/G80cR7nX5t5XCUm4bYdbwM07NgI=\n" +
-        "-----END CERTIFICATE-----";
-    static String trustedPrivateKey = // Private key in the format of PKCS#8
-        "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBANtiq0AIJK+iVRwF\n" +
-        "rqcD7fYXTCbMYC5Qz/k6AXBy7/1rI8wDhEJLE3m/+NSqiJwZcmdq2dNh/1fJFrwv\n" +
-        "zuURbc9+paOBWeHbN+Scx3huw91oPZme385VpoK3G13rSE114S/rF4DM9mz4EStF\n" +
-        "hSHXATjtdbskNOAYGLTVx8uEy9GbAgMBAAECgYEA2VjHkIiA0ABjkX+PqKeb+VLb\n" +
-        "fxS7tSca5C8zfdRhLxAWRui0/3ihst0eCJNrBDuxvAOACovsDWyLuaUjtI2v2ysz\n" +
-        "vz6SPyGy82PhQOFzyKQuQ814N6EpothpiZzF0yFchfKIGhUsdY89UrGs9nM7m6NT\n" +
-        "rztYvgIu4avg2VPR2AECQQD+pFAqipR2BplQRIuuRSZfHRxvoEyDjT1xnHJsC6WP\n" +
-        "I5hCLghL91MhQGWbP4EJMKYQOTRVukWlcp2Kycpf+P5hAkEA3I43gmVUAPEdyZdY\n" +
-        "fatW7OaLlbbYJb6qEtpCZ1Rwe/BIvm6H6E3qSi/lpz7Ia7WDulpbF6BawHH3pRFq\n" +
-        "CUY5ewJBAP3pUDqrRpBN0jB0uSeDslhjSciQ+dqvSpZv3rSYBHUvlBJhnkpJiy37\n" +
-        "7ZUZhIxqYxyIPgRBolLwb+FFh7OdL+ECQCtldDic9WVmC+VheRDpCKZ+SlK/8lGi\n" +
-        "7VXeShiIvcU1JysJFoa35fSI7hf1O3wt7+hX5PqGG7Un94EsJwACKEcCQQC1TWt6\n" +
-        "ArKH6tRxKjOxFtqfs8fgEVYUaOr3j1jF4KBUuX2mtQtddZe3VfJ2wPsuKMMxmhkB\n" +
-        "e7xWWZnJsErt2e+E";
-
-    // Certificate information:
-    // Issuer: C=US, O=Java, OU=SunJSSE Test Serivce
-    // Validity
-    //     Not Before: May  5 02:40:53 2012 GMT
-    //     Not After : Jan 21 02:40:53 2032 GMT
-    // Subject: C=US, O=Java, OU=SunJSSE Test Serivce, CN=casigner
-    // X509v3 Subject Key Identifier:
-    //     13:07:E0:11:07:DB:EB:33:23:87:31:D0:DB:7E:16:56:BE:11:90:0A
-    // X509v3 Authority Key Identifier:
-    //     keyid:DD:4E:8D:2A:11:C0:83:03:F0:AC:EB:A2:BF:F9:F2:7D:C8:69:1F:9B
-    //     DirName:/C=US/O=Java/OU=SunJSSE Test Serivce
-    //     serial:00
-    static String caSignerStr =
-        "-----BEGIN CERTIFICATE-----\n" +
-        "MIICqDCCAhGgAwIBAgIBAjANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" +
-        "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" +
-        "MTIwNTA1MDI0MDUzWhcNMzIwMTIxMDI0MDUzWjBOMQswCQYDVQQGEwJVUzENMAsG\n" +
-        "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UxETAPBgNV\n" +
-        "BAMTCGNhc2lnbmVyMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+x8+o7oM0\n" +
-        "ct/LZmZLXBL4CQ8jrULD5P7NtEW0hg/zxBFZfBHf+44Oo2eMPYZj+7xaREOH5BmV\n" +
-        "KRYlzRtONAaC5Ng4Mrm5UKNPcMIIUjUOvm7vWM4oSTMSfoEcSX+vp99uUAkw3w7Z\n" +
-        "+frYDm1M4At/j0b+lLij71GFN2L8drpgPQIDAQABo4GoMIGlMB0GA1UdDgQWBBQT\n" +
-        "B+ARB9vrMyOHMdDbfhZWvhGQCjBjBgNVHSMEXDBagBTdTo0qEcCDA/Cs66K/+fJ9\n" +
-        "yGkfm6E/pD0wOzELMAkGA1UEBhMCVVMxDTALBgNVBAoTBEphdmExHTAbBgNVBAsT\n" +
-        "FFN1bkpTU0UgVGVzdCBTZXJpdmNlggEAMBIGA1UdEwEB/wQIMAYBAf8CAQEwCwYD\n" +
-        "VR0PBAQDAgEGMA0GCSqGSIb3DQEBBAUAA4GBAI+LXA/UCPkTANablUkt80JNPWsl\n" +
-        "pS4XLNgPxWaN0bkRDs5oI4ooWAz1rwpeJ/nfetOvWlpmrVjSeovBFja5Hl+dUHTf\n" +
-        "VfuyzkxXbhuNiJIpo1mVBpNsjwu9YRxuwX6UA2LTUQpgvtVJEE012x3zRvxBCbu2\n" +
-        "Y/v1R5fZ4c+hXDfC\n" +
-        "-----END CERTIFICATE-----";
-    static String caSignerPrivateKey = // Private key in the format of PKCS#8
-        "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAL7Hz6jugzRy38tm\n" +
-        "ZktcEvgJDyOtQsPk/s20RbSGD/PEEVl8Ed/7jg6jZ4w9hmP7vFpEQ4fkGZUpFiXN\n" +
-        "G040BoLk2DgyublQo09wwghSNQ6+bu9YzihJMxJ+gRxJf6+n325QCTDfDtn5+tgO\n" +
-        "bUzgC3+PRv6UuKPvUYU3Yvx2umA9AgMBAAECgYBYvu30cW8LONyt62Zua9hPFTe7\n" +
-        "qt9B7QYyfkdmoG5PQMepTrOp84SzfoOukvgvDm0huFuJnSvhXQl2cCDhkgXskvFj\n" +
-        "Hh7KBCFViVXokGdq5YoS0/KYMyQV0TZfJUvILBl51uc4/siQ2tClC/N4sa+1JhgW\n" +
-        "a6dFGfRjiUKSSlmMwQJBAPWpIz3Q/c+DYMvoQr5OD8EaYwYIevlTdXb97RnJJh2b\n" +
-        "UnhB9jrqesJiHYVzPmP0ukyPOXOwlp2T5Am4Kw0LFOkCQQDGz150NoHOp28Mvyc4\n" +
-        "CTqz/zYzUhy2eCJESl196uyP4N65Y01VYQ3JDww4DlsXiU17tVSbgA9TCcfTYOzy\n" +
-        "vyw1AkARUky+1hafZCcWGZljK8PmnMKwsTZikCTvL/Zg5BMA8Wu+OQBwpQnk3OAy\n" +
-        "Aa87gw0DyvGFG8Vy9POWT9sRP1/JAkBqP0hrMvYMSs6+MSn0eHo2151PsAJIQcuO\n" +
-        "U2/Da1khSzu8N6WMi2GiobgV/RYRbf9KrY2ZzMZjykZQYOxAjopBAkEAghCu38cN\n" +
-        "aOsW6ueo24uzsWI1FTdE+qWNVEi3RSP120xXBCyhaBjIq4WVSlJK9K2aBaJpit3j\n" +
-        "iQ5tl6zrLlxQhg==";
-
-    // Certificate information:
-    // Issuer: C=US, O=Java, OU=SunJSSE Test Serivce, CN=casigner
-    // Validity
-    //     Not Before: May  5 02:40:57 2012 GMT
-    //     Not After : Jan 21 02:40:57 2032 GMT
-    // Subject: C=US, O=Java, OU=SunJSSE Test Serivce, CN=certissuer
-    // X509v3 Subject Key Identifier:
-    //     39:0E:C6:33:B1:50:BC:73:07:31:E5:D8:04:F7:BB:97:55:CF:9B:C8
-    // X509v3 Authority Key Identifier:
-    //     keyid:13:07:E0:11:07:DB:EB:33:23:87:31:D0:DB:7E:16:56:BE:11:90:0A
-    //     DirName:/C=US/O=Java/OU=SunJSSE Test Serivce
-    //     serial:02
-    static String certIssuerStr =
-        "-----BEGIN CERTIFICATE-----\n" +
-        "MIICvjCCAiegAwIBAgIBAzANBgkqhkiG9w0BAQQFADBOMQswCQYDVQQGEwJVUzEN\n" +
-        "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UxETAP\n" +
-        "BgNVBAMTCGNhc2lnbmVyMB4XDTEyMDUwNTAyNDA1N1oXDTMyMDEyMTAyNDA1N1ow\n" +
-        "UDELMAkGA1UEBhMCVVMxDTALBgNVBAoTBEphdmExHTAbBgNVBAsTFFN1bkpTU0Ug\n" +
-        "VGVzdCBTZXJpdmNlMRMwEQYDVQQDEwpjZXJ0aXNzdWVyMIGfMA0GCSqGSIb3DQEB\n" +
-        "AQUAA4GNADCBiQKBgQCyz55zinU6kNL/LeiTNiBI0QWYmDG0YTotuC4D75liBNqs\n" +
-        "7Mmladsh2mTtQUAwmuGaGzaZV25a+cUax0DXZoyBwdbTI09u1bUYsZcaUUKbPoCC\n" +
-        "HH26e4jLFL4olW13Sv4ZAd57tIYevMw+Fp5f4fLPFGegCJTFlv2Qjpmic/cuvQID\n" +
-        "AQABo4GpMIGmMB0GA1UdDgQWBBQ5DsYzsVC8cwcx5dgE97uXVc+byDBjBgNVHSME\n" +
-        "XDBagBQTB+ARB9vrMyOHMdDbfhZWvhGQCqE/pD0wOzELMAkGA1UEBhMCVVMxDTAL\n" +
-        "BgNVBAoTBEphdmExHTAbBgNVBAsTFFN1bkpTU0UgVGVzdCBTZXJpdmNlggECMBMG\n" +
-        "A1UdEwEB/wQJMAcBAf8CAgQAMAsGA1UdDwQEAwIBBjANBgkqhkiG9w0BAQQFAAOB\n" +
-        "gQCQTagenCdClT98C+oTJGJrw/dUBD9K3tE6ZJKPMc/2bUia8G5ei1C0eXj4mWG2\n" +
-        "lu9umR6C90/A6qB050QB2h50qtqxSrkpu+ym1yypauZpg7U3nUY9wZWJNI1vqrQZ\n" +
-        "pqUMRcXY3iQIVKx+Qj+4/Za1wwFQzpEoGmqRW31V1SdMEw==\n" +
-        "-----END CERTIFICATE-----";
-    static String certIssuerPrivateKey = // Private key in the format of PKCS#8
-        "MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBALLPnnOKdTqQ0v8t\n" +
-        "6JM2IEjRBZiYMbRhOi24LgPvmWIE2qzsyaVp2yHaZO1BQDCa4ZobNplXblr5xRrH\n" +
-        "QNdmjIHB1tMjT27VtRixlxpRQps+gIIcfbp7iMsUviiVbXdK/hkB3nu0hh68zD4W\n" +
-        "nl/h8s8UZ6AIlMWW/ZCOmaJz9y69AgMBAAECgYEAjtew2tgm4gxDojqIauF4VPM1\n" +
-        "pzsdqd1p3pAdomNLgrQiBLZ8N7oiph6TNb1EjA+OXc+ThFgF/oM9ZDD8qZZwcvjN\n" +
-        "qDZlpTkFs2TaGcyEZfUaMB45NHVs6Nn+pSkagSNwwy3xeyAct7sQEzGNTDlEwVv5\n" +
-        "7V9LQutQtBd6xT48KzkCQQDpNRfv2OFNG/6GtzJoO68oJhpnpl2MsYNi4ntRkre/\n" +
-        "6uXpiCYaDskcrPMRwOOs0m7mxG+Ev+uKnLnSoEMm1GCbAkEAxEmDtiD0Psb8Z9BL\n" +
-        "ZRb83Jqho3xe2MCAh3xUfz9b/Mhae9dZ44o4OCgQZuwvW1mczF0NtpgZl93BmYa2\n" +
-        "hTwHhwJBAKHrEj6ep/fA6x0gD2idoATRR94VfbiU+7NpqtO9ecVP0+gsdr/66hn1\n" +
-        "3yLBeZLh3MxvMTrLgkAQh1i9m0JXjOcCQQClLXAHHegrw+u3uNMZeKTFR+Lp3sk6\n" +
-        "AZSnbvr0Me9I45kxSeG81x3ENALJecvIRbrrRws5MvmmkNhQR8rkh8WVAkEAk6b+\n" +
-        "aVtmBgUaTS5+FFlHGHJY9HFrfT1a1C/dwyMuqlmbC3YsBmZaMOlKli5TXNybLff8\n" +
-        "5KMeGEpXMzgC7AscGA==";
-
-    // Certificate information:
-    // Issuer: C=US, O=Java, OU=SunJSSE Test Serivce, CN=certissuer
-    // Validity
-    //     Not Before: May  5 02:41:01 2012 GMT
-    //     Not After : Jan 21 02:41:01 2032 GMT
-    // Subject: C=US, O=Java, OU=SunJSSE Test Serivce, CN=localhost
-    // X509v3 Subject Key Identifier:
-    //     AD:C0:2C:4C:E4:C2:2E:A1:BB:5D:92:BE:66:E0:4E:E0:0D:2F:11:EF
-    // X509v3 Authority Key Identifier:
-    //     keyid:39:0E:C6:33:B1:50:BC:73:07:31:E5:D8:04:F7:BB:97:55:CF:9B:C8
-    static String targetCertStr =
-        "-----BEGIN CERTIFICATE-----\n" +
-        "MIICjTCCAfagAwIBAgIBBDANBgkqhkiG9w0BAQQFADBQMQswCQYDVQQGEwJVUzEN\n" +
-        "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UxEzAR\n" +
-        "BgNVBAMTCmNlcnRpc3N1ZXIwHhcNMTIwNTA1MDI0MTAxWhcNMzIwMTIxMDI0MTAx\n" +
-        "WjBPMQswCQYDVQQGEwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNT\n" +
-        "RSBUZXN0IFNlcml2Y2UxEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0B\n" +
-        "AQEFAAOBjQAwgYkCgYEAvwaUd7wmBSKqycEstYLWD26vkU08DM39EtaT8wL9HnQ0\n" +
-        "fgPblwBFI4zdLa2cuYXRZcFUb04N8nrkcpR0D6kkE+AlFAoRWrrZF80B7JTbtEK4\n" +
-        "1PIeurihXvUT+4MpzGLOojIihMfvM4ufelblD56SInso4WFHm7t4qCln88J1gjkC\n" +
-        "AwEAAaN4MHYwCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBStwCxM5MIuobtdkr5m4E7g\n" +
-        "DS8R7zAfBgNVHSMEGDAWgBQ5DsYzsVC8cwcx5dgE97uXVc+byDAnBgNVHSUEIDAe\n" +
-        "BggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMDMA0GCSqGSIb3DQEBBAUAA4GB\n" +
-        "AGfwcfdvEG/nSCiAn2MGbYHp34mgF3OA1SJLWUW0LvWJhwm2cn4AXlSoyvbwrkaB\n" +
-        "IDDCwhJvvc0vUyL2kTx7sqVaFTq3mDs+ktlB/FfH0Pb+i8FE+g+7T42Iw/j0qxHL\n" +
-        "YmgbrjBQf5WYN1AvBE/rrPt9aOtS3UsqtVGW574b0shW\n" +
-        "-----END CERTIFICATE-----";
-    static String targetPrivateKey = // Private key in the format of PKCS#8
-        "MIICdAIBADANBgkqhkiG9w0BAQEFAASCAl4wggJaAgEAAoGBAL8GlHe8JgUiqsnB\n" +
-        "LLWC1g9ur5FNPAzN/RLWk/MC/R50NH4D25cARSOM3S2tnLmF0WXBVG9ODfJ65HKU\n" +
-        "dA+pJBPgJRQKEVq62RfNAeyU27RCuNTyHrq4oV71E/uDKcxizqIyIoTH7zOLn3pW\n" +
-        "5Q+ekiJ7KOFhR5u7eKgpZ/PCdYI5AgMBAAECf3CscOYvFD3zNMnMJ5LomVqA7w3F\n" +
-        "gKYM2jlCWAH+wU41PMEXhW6Lujw92jgXL1o+lERwxFzirVdZJWZwKgUSvzP1G0h3\n" +
-        "fkucq1/UWnToK+8NSXNM/yS8hXbBgSEoJo5f7LKcIi1Ev6doBVofMxs+njzyWKbM\n" +
-        "Nb7rOLHadghoon0CQQDgQzbzzSN8Dc1YmmylhI5v+0sQRHH0DL7D24k4Weh4vInG\n" +
-        "EAbt4x8M7ZKEo8/dv0s4hbmNmAnJl93/RRxIyEqLAkEA2g87DiswSQam2pZ8GlrO\n" +
-        "+w4Qg9mH8uxx8ou2rl0XlHzH1XiTNbkjfY0EZoL7L31BHFk9n11Fb2P85g6ws+Hy\n" +
-        "ywJAM/xgyLNM/nzUlS128geAXUULaYH0SHaL4isJ7B4rXZGW/mrIsGxtzjlkNYsj\n" +
-        "rGujrD6TfNc5rZmexIXowJZtcQJBAIww+pCzZ4mrgx5JXWQ8OZHiiu+ZrPOa2+9J\n" +
-        "r5sOMpi+WGN/73S8oHqZbNjTINZ5OqEVJq8MchWZPQBTNXuQql0CQHEjUzzkCQa3\n" +
-        "j6JTa2KAdqyvLOx0XF9zcc1gA069uNQI2gPUHS8V215z57f/gMGnDNhVfLs/vMKz\n" +
-        "sFkVZ3zg7As=";
-
-
-    public static void main(String args[]) throws Exception {
-        // MD5 is used in this test case, don't disable MD5 algorithm.
-        java.security.Security.setProperty(
-                "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");
-
-        // generate certificate from cert string
-        CertificateFactory cf = CertificateFactory.getInstance("X.509");
-
-        // create a set of trust anchors
-        LinkedHashSet<TrustAnchor> trustAnchors = new LinkedHashSet<>();
-
-        ByteArrayInputStream is =
-            new ByteArrayInputStream(NoiceTrusedCertStr.getBytes());
-        Certificate trustedCert = cf.generateCertificate(is);
-        is.close();
-        TrustAnchor anchor =
-            new TrustAnchor((X509Certificate)trustedCert, null);
-        trustAnchors.add(anchor);
-
-        is = new ByteArrayInputStream(trustedCertStr.getBytes());
-        trustedCert = cf.generateCertificate(is);
-        is.close();
-        anchor = new TrustAnchor((X509Certificate)trustedCert, null);
-        trustAnchors.add(anchor);
-
-        is = new ByteArrayInputStream(NoiceTrusedCertStr_2nd.getBytes());
-        trustedCert = cf.generateCertificate(is);
-        is.close();
-        anchor = new TrustAnchor((X509Certificate)trustedCert, null);
-        trustAnchors.add(anchor);
-
-        // create a list of certificates
-        List<Certificate> chainList = new ArrayList<>();
-
-        is = new ByteArrayInputStream(targetCertStr.getBytes());
-        Certificate cert = cf.generateCertificate(is);
-        is.close();
-        chainList.add(cert);
-
-        is = new ByteArrayInputStream(certIssuerStr.getBytes());
-        cert = cf.generateCertificate(is);
-        is.close();
-        chainList.add(cert);
-
-        is = new ByteArrayInputStream(caSignerStr.getBytes());
-        cert = cf.generateCertificate(is);
-        is.close();
-        chainList.add(cert);
-
-        // create a certificate selector
-        X509CertSelector xcs = new X509CertSelector();
-        X509Certificate eeCert = (X509Certificate)chainList.get(0);
-        xcs.setSubject(eeCert.getSubjectX500Principal());
-
-        // reverse build
-        SunCertPathBuilderParameters params =
-            new SunCertPathBuilderParameters(trustAnchors, xcs);
-        params.setBuildForward(false);
-        params.setRevocationEnabled(false);
-
-        CollectionCertStoreParameters ccsp =
-            new CollectionCertStoreParameters(chainList);
-        params.addCertStore(CertStore.getInstance("Collection", ccsp));
-
-        CertPathBuilder cpb = CertPathBuilder.getInstance("PKIX");
-        CertPathBuilderResult res = cpb.build(params);
-    }
-}