changeset 7781:0495f9261e0b

Merge
author asaha
date Thu, 11 Sep 2014 11:03:44 -0700
parents 78a7e3c7165d eda24531237d
children 8b4c3989a112 76d3dbc69959
files .hgtags
diffstat 12 files changed, 533 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Sep 08 12:16:34 2014 -0700
+++ b/.hgtags	Thu Sep 11 11:03:44 2014 -0700
@@ -461,6 +461,10 @@
 ba6cef21c369076be97dd8133fd4a158cd486bd8 jdk7u65-b40
 7b47a34063e94e1ab5636b11231d33fae92754c9 jdk7u65-b31
 4cb63f8ca9ee8c60d6f3d0051b69acc8392bd8de jdk7u65-b33
+5cf343beab2ce73d299d4f1a8f3b95892f9fd818 jdk7u67-b01
+388d34a2e45c2660e7ede2a9d80949b14b5d8df9 jdk7u67-b31
+de2b809bb95904bfd5c2ad47cf0f41c97abd5750 jdk7u67-b32
+193d852a6dce1aaf47f1e6960e1c83936bd0e0a4 jdk7u67-b33
 9ccfe70cee626ac7831cfa7b7a7eb7a88fe1cd42 jdk7u66-b00
 fc87b55d62fc1e81aaf61ff21175129b8ccc302e jdk7u66-b01
 c67e394e49429565540f04c5c2a5544f750658bb jdk7u66-b09
--- a/src/share/classes/java/awt/EventQueue.java	Mon Sep 08 12:16:34 2014 -0700
+++ b/src/share/classes/java/awt/EventQueue.java	Thu Sep 11 11:03:44 2014 -0700
@@ -209,6 +209,11 @@
                 {
                     EventQueue.invokeAndWait(source, r);
                 }
+
+                @Override
+                public long getMostRecentEventTime(EventQueue eventQueue) {
+                    return eventQueue.getMostRecentEventTimeImpl();
+                }
             });
     }
 
--- a/src/share/classes/java/awt/event/InputMethodEvent.java	Mon Sep 08 12:16:34 2014 -0700
+++ b/src/share/classes/java/awt/event/InputMethodEvent.java	Thu Sep 11 11:03:44 2014 -0700
@@ -25,6 +25,10 @@
 
 package java.awt.event;
 
+import sun.awt.AWTAccessor;
+import sun.awt.AppContext;
+import sun.awt.SunToolkit;
+
 import java.awt.AWTEvent;
 import java.awt.Component;
 import java.awt.EventQueue;
@@ -217,8 +221,10 @@
     public InputMethodEvent(Component source, int id,
             AttributedCharacterIterator text, int committedCharacterCount,
             TextHitInfo caret, TextHitInfo visiblePosition) {
-        this(source, id, EventQueue.getMostRecentEventTime(), text,
-             committedCharacterCount, caret, visiblePosition);
+        this(source, id,
+                getMostRecentEventTimeForSource(source),
+                text, committedCharacterCount,
+                caret, visiblePosition);
     }
 
     /**
@@ -258,8 +264,9 @@
      */
     public InputMethodEvent(Component source, int id, TextHitInfo caret,
             TextHitInfo visiblePosition) {
-        this(source, id, EventQueue.getMostRecentEventTime(), null,
-             0, caret, visiblePosition);
+        this(source, id,
+                getMostRecentEventTimeForSource(source),
+                null, 0, caret, visiblePosition);
     }
 
     /**
@@ -410,7 +417,25 @@
     private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
         s.defaultReadObject();
         if (when == 0) {
-            when = EventQueue.getMostRecentEventTime();
+            when = getMostRecentEventTimeForSource(this.source);
         }
     }
+
+    /**
+     * Get the most recent event time in the {@code EventQueue} which the {@code source}
+     * belongs to.
+     *
+     * @param source the source of the event
+     * @exception  IllegalArgumentException  if source is null.
+     * @return most recent event time in the {@code EventQueue}
+     */
+    private static long getMostRecentEventTimeForSource(Object source) {
+        if (source == null) {
+            // throw the IllegalArgumentException to conform to EventObject spec
+            throw new IllegalArgumentException("null source");
+        }
+        AppContext appContext = SunToolkit.targetToAppContext(source);
+        EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext);
+        return AWTAccessor.getEventQueueAccessor().getMostRecentEventTime(eventQueue);
+    }
 }
--- a/src/share/classes/java/beans/XMLEncoder.java	Mon Sep 08 12:16:34 2014 -0700
+++ b/src/share/classes/java/beans/XMLEncoder.java	Thu Sep 11 11:03:44 2014 -0700
@@ -377,7 +377,7 @@
             Object arg = args[i];
             mark(arg, true);
         }
-        mark(stm.getTarget(), false);
+        mark(stm.getTarget(), stm instanceof Expression);
     }
 
 
--- a/src/share/classes/sun/awt/AWTAccessor.java	Mon Sep 08 12:16:34 2014 -0700
+++ b/src/share/classes/sun/awt/AWTAccessor.java	Thu Sep 11 11:03:44 2014 -0700
@@ -491,6 +491,11 @@
          */
         void invokeAndWait(Object source, Runnable r)
             throws InterruptedException, InvocationTargetException;
+
+        /**
+         * Gets most recent event time in the EventQueue
+         */
+        long getMostRecentEventTime(EventQueue eventQueue);
     }
 
     /*
--- a/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java	Mon Sep 08 12:16:34 2014 -0700
+++ b/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java	Thu Sep 11 11:03:44 2014 -0700
@@ -65,7 +65,11 @@
                                            int w, int h)
     {
         if (cachedData == null) {
-            cachedData = oglgc.createManagedSurface(w, h, transparency);
+            try {
+                cachedData = oglgc.createManagedSurface(w, h, transparency);
+            } catch (OutOfMemoryError er) {
+                return null;
+            }
         }
         return cachedData;
     }
--- a/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Mon Sep 08 12:16:34 2014 -0700
+++ b/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Thu Sep 11 11:03:44 2014 -0700
@@ -234,10 +234,6 @@
         // check trusted certificate's subject
         issuerSelector.setSubject(firstCert.getIssuerX500Principal());
 
-        // check the validity period
-        issuerSelector.setValidityPeriod(firstCert.getNotBefore(),
-                                                firstCert.getNotAfter());
-
         /*
          * Facilitate certification path construction with authority
          * key identifier and subject key identifier.
--- a/src/windows/native/sun/security/krb5/NativeCreds.c	Mon Sep 08 12:16:34 2014 -0700
+++ b/src/windows/native/sun/security/krb5/NativeCreds.c	Thu Sep 11 11:03:44 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, 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
@@ -397,7 +397,7 @@
     jobject ticketFlags, startTime, endTime, krbCreds = NULL;
     jobject authTime, renewTillTime, hostAddresses = NULL;
     KERB_EXTERNAL_TICKET *msticket;
-    int found_in_cache = 0;
+    int found = 0;
     FILETIME Now, EndTime, LocalEndTime;
 
     int i, netypes;
@@ -485,7 +485,7 @@
             if (CompareFileTime(&Now, &LocalEndTime) < 0) {
                 for (i=0; i<netypes; i++) {
                     if (etypes[i] == msticket->SessionKey.KeyType) {
-                        found_in_cache = 1;
+                        found = 1;
                         if (native_debug) {
                             printf("LSA: Valid etype found: %d\n", etypes[i]);
                         }
@@ -495,7 +495,7 @@
             }
         }
 
-        if (!found_in_cache) {
+        if (!found) {
             if (native_debug) {
                 printf("LSA: MS TGT in cache is invalid/not supported; request new ticket\n");
             }
@@ -538,6 +538,13 @@
 
                 // got the native MS Kerberos TGT
                 msticket = &(pTicketResponse->Ticket);
+                if (msticket->SessionKey.KeyType != etypes[i]) {
+                    if (native_debug) {
+                        printf("LSA: Response etype is %d for %d. Retry.\n", msticket->SessionKey.KeyType, etypes[i]);
+                    }
+                    continue;
+                }
+                found = 1;
                 break;
             }
         }
@@ -590,6 +597,10 @@
             PUCHAR Value;
         } KERB_CRYPTO_KEY, *PKERB_CRYPTO_KEY;
 
+        if (!found) {
+            break;
+        }
+
         */
         // Build a com.sun.security.krb5.Ticket
         ticket = BuildTicket(env, msticket->EncodedTicket,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/im/8041990/bug8041990.java	Thu Sep 11 11:03:44 2014 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2014, 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 8041990
+  @summary Language specific keys does not work in applets when opened outside the browser
+  @author Petr Pchelko
+*/
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputMethodEvent;
+import java.awt.font.TextHitInfo;
+import java.text.AttributedString;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class bug8041990 {
+    private static JFrame frame;
+    private static JComponent component;
+
+    public static void main(String[] args) throws Exception {
+        ThreadGroup stubTG = new ThreadGroup(getRootThreadGroup(), "Stub Thread Group");
+        ThreadGroup swingTG = new ThreadGroup(getRootThreadGroup(), "SwingTG");
+        try {
+            Thread stubThread = new Thread(stubTG, new Runnable() {
+                public void run() {
+                    SunToolkit.createNewAppContext();
+                }
+            });
+            stubThread.start();
+            stubThread.join();
+
+            final CountDownLatch startSwingLatch = new CountDownLatch(1);
+            new Thread(swingTG, new Runnable() {
+                public void run() {
+                    SunToolkit.createNewAppContext();
+                    SwingUtilities.invokeLater(new Runnable() {
+                        public void run() {
+                            frame = new JFrame();
+                            component = new JLabel("Test Text");
+                            frame.add(component);
+                            frame.setBounds(100, 100, 100, 100);
+                            frame.setVisible(true);
+                            startSwingLatch.countDown();
+                        }
+                    });
+                }
+            }).start();
+            startSwingLatch.await();
+
+            final AtomicReference<Exception> caughtException = new AtomicReference<>();
+            Thread checkThread = new Thread(getRootThreadGroup(), new Runnable() {
+                public void run() {
+                    try {
+                        // If the bug is present this will throw exception
+                        new InputMethodEvent(component,
+                                InputMethodEvent.CARET_POSITION_CHANGED,
+                                TextHitInfo.leading(0),
+                                TextHitInfo.trailing(0));
+                    } catch (Exception e) {
+                        caughtException.set(e);
+                    }
+                }
+            });
+            checkThread.start();
+            checkThread.join();
+
+            if (caughtException.get() != null) {
+                throw new RuntimeException("Failed. Caught exception!", caughtException.get());
+            }
+        } finally {
+            new Thread(swingTG, new Runnable() {
+                public void run() {
+                    SwingUtilities.invokeLater(new Runnable() {
+                        public void run() {
+                            if (frame != null) {
+                                frame.dispose();
+                            }
+                        }
+                    });
+                }
+            }).start();
+        }
+    }
+
+    private static ThreadGroup getRootThreadGroup() {
+        ThreadGroup currentTG = Thread.currentThread().getThreadGroup();
+        ThreadGroup parentTG = currentTG.getParent();
+        while (parentTG != null) {
+            currentTG = parentTG;
+            parentTG = currentTG.getParent();
+        }
+        return currentTG;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/XMLEncoder/Test8016545.java	Thu Sep 11 11:03:44 2014 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013, 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 8016545
+ * @summary Tests beans with predefined fields
+ * @author Sergey Malenkov
+ */
+
+public class Test8016545 extends AbstractTest {
+    public static void main(String[] args) {
+        new Test8016545().test(true);
+    }
+
+    @Override
+    protected Object getObject() {
+        Bean bean = new Bean();
+        bean.setUndefined(Boolean.FALSE);
+        Info info = new Info();
+        info.setEnabled(Boolean.TRUE);
+        info.setID(1);
+        bean.setInfo(info);
+        return bean;
+    }
+
+    @Override
+    protected Object getAnotherObject() {
+        Bean bean = new Bean();
+        bean.setUndefined(Boolean.TRUE);
+        bean.getInfo().setEnabled(Boolean.FALSE);
+        bean.getInfo().setID(2);
+        return bean;
+    }
+
+    public static class Bean {
+        private Info info = new Info(); // predefined
+        private Boolean defined = Boolean.TRUE;
+        private Boolean undefined;
+
+        public Info getInfo() {
+            return this.info;
+        }
+
+        public void setInfo(Info info) {
+            this.info = info;
+        }
+
+        public Boolean getDefined() {
+            return this.defined;
+        }
+
+        public void setDefined(Boolean defined) {
+            this.defined = defined;
+        }
+
+        public Boolean getUndefined() {
+            return this.undefined;
+        }
+
+        public void setUndefined(Boolean undefined) {
+            this.undefined = undefined;
+        }
+    }
+
+    public static class Info {
+        private Integer id;
+        private Boolean enabled;
+
+        public Integer getID() {
+            return this.id;
+        }
+
+        public void setID(Integer id) {
+            this.id = id;
+        }
+
+        public Boolean getEnabled() {
+            return this.enabled;
+        }
+
+        public void setEnabled(Boolean enabled) {
+            this.enabled = enabled;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/java2d/OpenGL/DrawHugeImageTest.java	Thu Sep 11 11:03:44 2014 -0700
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014, 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     8040617
+ * @summary Test verifies that an attempt to get an accelerated copy of
+ *          a huge buffered image does not result in an OOME.
+ *
+ * @run     main DrawHugeImageTest
+ */
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.image.BufferedImage;
+import java.awt.image.VolatileImage;
+
+public class DrawHugeImageTest {
+    // we have to render the BI source several times in order
+    // to get an accelerated copy to be used.
+    static {
+        System.setProperty("sun.java2d.accthreshold", "1");
+    }
+    private static final int max_rendering_count = 5;
+
+    private static final Color srcColor = Color.red;
+    private static final Color dstColor = Color.blue;
+
+    public static void main(String[] args) {
+        BufferedImage src = createSrc();
+
+        VolatileImage dst = createDst();
+        System.out.println("Dst: " + dst);
+        boolean status;
+        int count = max_rendering_count;
+
+        do {
+            System.out.println("render image: " + (max_rendering_count - count));
+            status = render(src, dst);
+
+        } while (status && count-- > 0);
+
+        if (!status || count > 0) {
+            throw new RuntimeException("Test failed: " + count);
+        }
+    }
+
+    private static boolean render(BufferedImage src, VolatileImage dst) {
+        int cnt = 5;
+        do {
+            Graphics2D g = dst.createGraphics();
+            g.setColor(dstColor);
+            g.fillRect(0, 0, dst.getWidth(), dst.getHeight());
+            g.drawImage(src, 0, 0, null);
+            g.dispose();
+        } while (dst.contentsLost() && (--cnt > 0));
+
+        if (cnt == 0) {
+            System.err.println("Test failed: unable to render to volatile destination");
+            return false;
+        }
+
+        BufferedImage s = dst.getSnapshot();
+
+        return s.getRGB(1,1) == srcColor.getRGB();
+    }
+
+    private static BufferedImage createSrc() {
+        final int w = 20000;
+        final int h = 5;
+
+        BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);
+        Graphics2D g = img.createGraphics();
+        g.setColor(srcColor);
+        g.fillRect(0, 0, w, h);
+        g.dispose();
+
+        return img;
+    }
+
+    private static VolatileImage createDst() {
+        GraphicsConfiguration gc =
+                GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
+
+        return gc.createCompatibleVolatileImage(200, 200);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/provider/certpath/PKIXCertPathValidator/Validity.java	Thu Sep 11 11:03:44 2014 -0700
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2014, 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 8021804
+ * @summary CertPath should validate even if the validity period of the
+ *          root cert does not include the validity period of a subordinate
+ *          cert.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.security.cert.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+public class Validity {
+
+    /*
+     * Subject: OU=TestOrg, CN=TestCA
+     * Issuer: OU=TestOrg, CN=TestCA
+     * Validity
+     *     Not Before: Feb 26 21:33:55 2014 GMT
+           Not After : Feb 26 21:33:55 2024 GMT
+     * Version 1
+     */
+    static String CACertStr =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIBvTCCASYCCQCQRiTo4lBCFjANBgkqhkiG9w0BAQUFADAjMRAwDgYDVQQLDAdU\n" +
+        "ZXN0T3JnMQ8wDQYDVQQDDAZUZXN0Q0EwHhcNMTQwMjI2MjEzMzU1WhcNMjQwMjI2\n" +
+        "MjEzMzU1WjAjMRAwDgYDVQQLDAdUZXN0T3JnMQ8wDQYDVQQDDAZUZXN0Q0EwgZ8w\n" +
+        "DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOtKS4ZrsM3ansd61ZxitcrN0w184I+A\n" +
+        "z0kyrSP1eMtlam+cC2U91NpTz11FYV4XUfBhqqxaXW043AWTUer8pS90Pt4sCrUX\n" +
+        "COx1+QA1M3ZhbZ4sTM7XQ90JbGaBJ/sEza9mlQP7hQ2yQO/hATKbP6J5qvgG2sT2\n" +
+        "S2WYjEgwNwmFAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAQ/CXEpnx2WY4LJtv4jwE\n" +
+        "4jIVirur3pdzV5oBhPyqqHMsyhQBkukCfX7uD7L5wN1+xuM81DfANpIxlnUfybp5\n" +
+        "CpjcmktLpmyK4kJ6XnSd2blbLOIpsr9x6FqxPxpVDlyw/ySHYrIG/GZdsLHgmzGn\n" +
+        "B06jeYzH8OLf879VxAxSsPc=\n" +
+        "-----END CERTIFICATE-----";
+
+    /*
+     * Subject: OU=TestOrg, CN=TestEE0
+     * Issuer: OU=TestOrg, CN=TestCA
+     * Validity
+     *     Not Before: Feb 26 22:55:12 2014 GMT
+     *     Not After : Feb 25 22:55:12 2025 GMT
+     * Version 1
+     */
+    static String EECertStr =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIBtjCCAR8CAQQwDQYJKoZIhvcNAQEFBQAwIzEQMA4GA1UECwwHVGVzdE9yZzEP\n" +
+        "MA0GA1UEAwwGVGVzdENBMB4XDTE0MDIyNjIyNTUxMloXDTI1MDIyNTIyNTUxMlow\n" +
+        "JDEQMA4GA1UECwwHVGVzdE9yZzEQMA4GA1UEAwwHVGVzdEVFMDCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAt8xz9W3ruCTHjSOtTX6cxsUZ0nRP6EavEfzgcOYh\n" +
+        "CXGA0gr+viSHq3c2vQBxiRny2hm5rLcqpPo+2OxZtw/ajxfyrV6d/r8YyQLBvyl3\n" +
+        "xdCZdOkG1DCM1oFAQDaSRt9wN5Zm5kyg7uMig5Y4L45fP9Yee4x6Xyh36qYbsR89\n" +
+        "rFMCAwEAATANBgkqhkiG9w0BAQUFAAOBgQDZrPqSo08va1m9TOWOztTuWilGdjK/\n" +
+        "2Ed2WXg8utIpy6uAV+NaOYtHQ7ULQBVRNmwg9nKghbVbh+E/xpoihjl1x7OXass4\n" +
+        "TbwXA5GKFIFpNtDvATQ/QQZoCuCzw1FW/mH0Q7UEQ/9/iJdDad6ebkapeMwtj/8B\n" +
+        "s2IZV7s85CEOXw==\n" +
+        "-----END CERTIFICATE-----";
+
+    public static void main(String[] args) throws Exception {
+
+        String[] certStrs = {EECertStr};
+        String[] trustedCertStrs = {CACertStr};
+        runTest(certStrs, trustedCertStrs);
+
+        System.out.println("Test passed.");
+    }
+
+    private static void runTest(String[] certStrs,
+                                String[] trustedCertStrs)
+            throws Exception {
+
+        CertificateFactory cf = CertificateFactory.getInstance("X509");
+
+        // Generate the CertPath from the certs named in certStrs
+        ArrayList<X509Certificate> certs = new ArrayList<>();
+        for (String certStr : certStrs) {
+            certs.add(generateCert(certStr, cf));
+        }
+        CertPath cp = cf.generateCertPath(certs);
+
+        // Generate the set of Trust Anchors from the certs named in
+        // trustedCertStrs
+        Set<TrustAnchor> trustAnchors = new HashSet<>();
+        for (String trustedCertStr : trustedCertStrs) {
+            TrustAnchor ta = new TrustAnchor(generateCert(trustedCertStr, cf),
+                                             null);
+            trustAnchors.add(ta);
+        }
+        PKIXParameters params = new PKIXParameters(trustAnchors);
+        params.setDate(new Date(114, 3, 1));   // 2014-03-01
+        params.setRevocationEnabled(false);
+
+        // Attempt to validate the CertPath. If no exception thrown, successful.
+        CertPathValidator cpv = CertPathValidator.getInstance("PKIX");
+        cpv.validate(cp, params);
+        System.out.println("CertPath validation successful.");
+    }
+
+    private static X509Certificate generateCert(String certStr,
+                                                CertificateFactory cf)
+            throws Exception {
+        ByteArrayInputStream stream
+                = new ByteArrayInputStream(certStr.getBytes());
+        return (X509Certificate) cf.generateCertificate(stream);
+
+    }
+}