changeset 7782:8b4c3989a112

Merge
author asaha
date Fri, 12 Sep 2014 15:35:21 -0700
parents 079bbd366f09 0495f9261e0b
children df2eac635047
files .hgtags src/share/classes/sun/awt/AWTAccessor.java
diffstat 6 files changed, 179 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Sep 08 13:53:15 2014 -0700
+++ b/.hgtags	Fri Sep 12 15:35:21 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 13:53:15 2014 -0700
+++ b/src/share/classes/java/awt/EventQueue.java	Fri Sep 12 15:35:21 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 13:53:15 2014 -0700
+++ b/src/share/classes/java/awt/event/InputMethodEvent.java	Fri Sep 12 15:35:21 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/sun/awt/AWTAccessor.java	Mon Sep 08 13:53:15 2014 -0700
+++ b/src/share/classes/sun/awt/AWTAccessor.java	Fri Sep 12 15:35:21 2014 -0700
@@ -492,6 +492,11 @@
          */
         void invokeAndWait(Object source, Runnable r)
             throws InterruptedException, InvocationTargetException;
+
+        /**
+         * Gets most recent event time in the EventQueue
+         */
+        long getMostRecentEventTime(EventQueue eventQueue);
     }
 
     /*
--- a/src/windows/native/sun/security/krb5/NativeCreds.c	Mon Sep 08 13:53:15 2014 -0700
+++ b/src/windows/native/sun/security/krb5/NativeCreds.c	Fri Sep 12 15:35:21 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	Fri Sep 12 15:35:21 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;
+    }
+}