changeset 6653:f59060c18bb1

Merge
author lana
date Thu, 04 Jul 2013 10:31:31 -0700
parents b1012a7e71ce a5e342a0b9fd
children 419939ecee83 34c9cec19fc5
files
diffstat 8 files changed, 136 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Wed Jul 03 16:36:39 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Thu Jul 04 10:31:31 2013 -0700
@@ -125,6 +125,17 @@
         }
     }
 
+    /**
+     * When the window is activated and had focus before the deactivation
+     * calling this method triggers focus events in the following order:
+     *  1. WINDOW_ACTIVATED for this EmbeddedFrame
+     *  2. WINDOW_GAINED_FOCUS for this EmbeddedFrame
+     *  3. FOCUS_GAINED for the most recent focus owner in this EmbeddedFrame
+     *
+     * The caller must not requestFocus on the EmbeddedFrame together with calling this method.
+     *
+     * @param parentWindowActive true if the window is activated, false otherwise
+     */
     public void handleWindowFocusEvent(boolean parentWindowActive) {
         this.parentWindowActive = parentWindowActive;
         // ignore focus "lost" native request as it may mistakenly
--- a/src/share/classes/sun/misc/VM.java	Wed Jul 03 16:36:39 2013 -0700
+++ b/src/share/classes/sun/misc/VM.java	Thu Jul 04 10:31:31 2013 -0700
@@ -216,6 +216,16 @@
         return allowArraySyntax;
     }
 
+    private static boolean allowGetCallerClass = false;
+
+    // Reflection.getCallerClass(int) is disabled by default.
+    // It can be enabled by setting the system property
+    // "jdk.reflect.allowGetCallerClass" and also used by
+    // logging stack walk of a resource bundle if it is turned on.
+    public static boolean allowGetCallerClass() {
+        return allowGetCallerClass;
+    }
+
     /**
      * Returns the system property of the specified key saved at
      * system initialization time.  This method should only be used
@@ -280,6 +290,16 @@
                                ? defaultAllowArraySyntax
                                : Boolean.parseBoolean(s));
 
+        // Reflection.getCallerClass(int) is disabled by default.
+        // It can be enabled by setting the system property
+        // "jdk.reflect.allowGetCallerClass" and also used by
+        // logging stack walk of a resource bundle if it is turned on.
+        s = props.getProperty("jdk.reflect.allowGetCallerClass");
+        allowGetCallerClass = (s != null
+                                   ? (s.isEmpty() || Boolean.parseBoolean(s))
+                                   : false) ||
+             Boolean.valueOf(props.getProperty("jdk.logging.allowStackWalkSearch"));
+
         // Remove other private system properties
         // used by java.lang.Integer.IntegerCache
         props.remove("java.lang.Integer.IntegerCache.high");
--- a/src/share/classes/sun/reflect/Reflection.java	Wed Jul 03 16:36:39 2013 -0700
+++ b/src/share/classes/sun/reflect/Reflection.java	Thu Jul 04 10:31:31 2013 -0700
@@ -65,7 +65,15 @@
     @Deprecated
     @CallerSensitive
     public static Class getCallerClass(int depth) {
-        return getCallerClass0(depth+1);
+        if (sun.misc.VM.allowGetCallerClass()) {
+            return getCallerClass0(depth+1);
+        }
+        throw new UnsupportedOperationException("This method is in the sun.* " +
+             "namespace so it is not a supported, public interface. " +
+             "The 7u40 release notes describe a temporary mechanism " +
+             "to reenable the historical functionality of this method. " +
+             "Update code to function properly and this method will be " +
+             "removed without further warning in a subsequent 7 update release.");
     }
 
     // If the VM enforces getting caller class with @CallerSensitive,
--- a/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java	Wed Jul 03 16:36:39 2013 -0700
+++ b/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java	Thu Jul 04 10:31:31 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -904,11 +904,12 @@
      */
     public void dispose() {
         setDisposed(true);
-        EventQueue.invokeLater(new Runnable() {
+        InvocationEvent ev = new InvocationEvent(target, new Runnable() {
             public void run() {
                 doDispose();
             }
         });
+        super.postEvent(ev);
     }
 
     /**
@@ -933,11 +934,12 @@
      * so events can not be processed using standart means
      */
     void postEvent(final AWTEvent event) {
-        EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    handleEvent(event);
-                }
-            });
+        InvocationEvent ev = new InvocationEvent(event.getSource(), new Runnable() {
+            public void run() {
+                handleEvent(event);
+            }
+        });
+        super.postEvent(ev);
     }
 
     /**
--- a/src/solaris/classes/sun/awt/X11/XChoicePeer.java	Wed Jul 03 16:36:39 2013 -0700
+++ b/src/solaris/classes/sun/awt/X11/XChoicePeer.java	Thu Jul 04 10:31:31 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -1027,15 +1027,17 @@
             //fix 6252982: PIT: Keyboard FocusTraversal not working when choice's drop-down is visible, on XToolkit
             if (e instanceof KeyEvent){
                 // notify XWindow that this event had been already handled and no need to post it again
-                EventQueue.invokeLater(new Runnable() {
-                        public void run() {
-                            if(target.isFocusable() &&
-                               getParentTopLevel().isFocusableWindow() )
-                            {
-                                handleJavaKeyEvent((KeyEvent)e);
-                            }
+                InvocationEvent ev = new InvocationEvent(target, new Runnable() {
+                    public void run() {
+                        if(target.isFocusable() &&
+                                getParentTopLevel().isFocusableWindow() )
+                        {
+                            handleJavaKeyEvent((KeyEvent)e);
                         }
-                    });
+                    }
+                });
+                postEvent(ev);
+
                 return true;
             } else {
                 if (e instanceof MouseEvent){
@@ -1077,11 +1079,13 @@
     //convenient method
     //do not generate this kind of Events
     public boolean handleMouseEventByChoice(final MouseEvent me){
-        EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    handleJavaMouseEvent(me);
-                }
-            });
+        InvocationEvent ev = new InvocationEvent(target, new Runnable() {
+            public void run() {
+                handleJavaMouseEvent(me);
+            }
+        });
+        postEvent(ev);
+
         return true;
     }
 
--- a/src/solaris/classes/sun/awt/X11/XListPeer.java	Wed Jul 03 16:36:39 2013 -0700
+++ b/src/solaris/classes/sun/awt/X11/XListPeer.java	Thu Jul 04 10:31:31 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -1646,11 +1646,12 @@
      * Do handleJavaMouseEvent on EDT
      */
     void handleJavaMouseEventOnEDT(final MouseEvent me){
-        EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    handleJavaMouseEvent(me);
-                }
-            });
+        InvocationEvent ev = new InvocationEvent(target, new Runnable() {
+            public void run() {
+                handleJavaMouseEvent(me);
+            }
+        });
+        postEvent(ev);
     }
 
     /*
--- a/test/ProblemList.txt	Wed Jul 03 16:36:39 2013 -0700
+++ b/test/ProblemList.txt	Thu Jul 04 10:31:31 2013 -0700
@@ -393,9 +393,6 @@
 
 # jdk_tools
 
-# 8012474
-sun/tools/jmap/Basic.sh                                         generic-all
-
 # 6461635
 com/sun/tools/attach/BasicTests.sh                              generic-all
 
--- a/test/sun/reflect/GetCallerClass.java	Wed Jul 03 16:36:39 2013 -0700
+++ b/test/sun/reflect/GetCallerClass.java	Thu Jul 04 10:31:31 2013 -0700
@@ -23,29 +23,83 @@
 
 /*
  * @test
- * @bug 8016814
- * @summary Test sun.reflect.Reflection.getCallerClass(int)
+ * @bug 8016814 8014925
+ * @summary Test sun.reflect.Reflection.getCallerClass(int) disabled by default
  * @compile -XDignore.symbol.file GetCallerClass.java
- * @run main GetCallerClass
+ * @run main/othervm GetCallerClass
+ * @run main/othervm -Djdk.reflect.allowGetCallerClass GetCallerClass
+ * @run main/othervm -Djdk.reflect.allowGetCallerClass=true GetCallerClass
+ * @run main/othervm -Djdk.reflect.allowGetCallerClass=false GetCallerClass
  */
 
 public class GetCallerClass {
     public static void main(String[] args) throws Exception {
-        Class<?> c = Temp.test();
-        if (c != GetCallerClass.class) {
-            throw new RuntimeException("Incorrect caller: " + c);
+        String s = System.getProperty("jdk.reflect.allowGetCallerClass");
+        boolean allowed;
+        if (s == null || s.equals("false")) {
+            allowed = false;
+        } else if (s.equals("") || s.equals("true")) {
+            allowed = true;
+        } else {
+            throw new RuntimeException("Unsupported test setting");
+        }
+
+        try {
+            Class<?> c = Test.test();
+            if (!allowed) {
+                throw new RuntimeException("Reflection.getCallerClass should not be allowed");
+            }
+            Class<?> caller = Test.caller();
+            if (c != GetCallerClass.class || caller != c) {
+                throw new RuntimeException("Incorrect caller: " + c);
+            }
+            Test.selfTest();
+        } catch (UnsupportedOperationException e) {
+            if (allowed) throw e;
         }
     }
 
     @sun.reflect.CallerSensitive
     public Class<?> getCallerClass() {
-        // 0: Reflection 1: getCallerClass 2: Temp.test 3: main
+        // 0: Reflection 1: getCallerClass 2: Test.test 3: main
         return sun.reflect.Reflection.getCallerClass(3);
     }
 
-    static class Temp {
+    static class Test {
+        // Returns the caller of this method
         public static Class<?> test() {
             return new GetCallerClass().getCallerClass();
         }
+        @sun.reflect.CallerSensitive
+        public static Class<?> caller() {
+            return sun.reflect.Reflection.getCallerClass();
+        }
+        @sun.reflect.CallerSensitive
+        public static void selfTest() {
+            // 0: Reflection 1: Test.selfTest
+            Class<?> c = sun.reflect.Reflection.getCallerClass(1);
+            if (c != Test.class || caller() != c) {
+                throw new RuntimeException("Incorrect caller: " + c);
+            }
+            Inner1.deep();
+        }
+
+        static class Inner1 {
+            static void deep() {
+                 deeper();
+            }
+            static void deeper() {
+                 Inner2.deepest();
+            }
+            static class Inner2 {
+                static void deepest() {
+                    // 0: Reflection 1: deepest 2: deeper 3: deep 4: Test.selfTest
+                    Class<?> c = sun.reflect.Reflection.getCallerClass(4);
+                    if (c != Test.class) {
+                        throw new RuntimeException("Incorrect caller: " + c);
+                    }
+                }
+            }
+        }
     }
 }