changeset 2457:1585db3ed50d

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/MASTER/jfx/rt
author kcr
date Sat, 26 Jan 2013 08:41:03 -0800
parents 61ccba4d6c12 00328d63df9e
children 56dee48d8e94 46c38b139bc9
files javafx-fxml/src/com/sun/javafx/fxml/BeanAdapter.java javafx-ui-common/src/com/sun/javafx/application/PlatformImpl.java javafx-ui-common/src/javafx/scene/Scene.java javafx-ui-common/src/javafx/stage/Stage.java javafx-ui-controls/src/javafx/scene/control/Control.java javafx-ui-controls/src/javafx/scene/control/PopupControl.java
diffstat 15 files changed, 176 insertions(+), 130 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-fxml/project.properties	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-fxml/project.properties	Sat Jan 26 08:41:03 2013 -0800
@@ -11,6 +11,8 @@
     ${runtime.dist.root.dir}/../artifacts/sdk/rt/lib/jfxrt.jar:\
     ${build.test.classes.dir}
 
+javac.compilerargs=-XDignore.symbol.file
+
 #test-sys-prop.javafx.toolkit=com.sun.javafx.pgstub.StubToolkit
 build.generated.dir=${build.dir}/gensrc
 disable-lombok=true
--- a/javafx-fxml/src/com/sun/javafx/fxml/BeanAdapter.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-fxml/src/com/sun/javafx/fxml/BeanAdapter.java	Sat Jan 26 08:41:03 2013 -0800
@@ -44,6 +44,8 @@
 import java.lang.reflect.*;
 
 import javafx.beans.value.ObservableValue;
+import sun.reflect.misc.FieldUtil;
+import sun.reflect.misc.MethodUtil;
 import sun.reflect.misc.ReflectUtil;
 
 /**
@@ -95,6 +97,7 @@
     private static HashMap<String, LinkedList<Method>> getClassMethodCache(Class<?> type) {
         HashMap<String, LinkedList<Method>> classMethodCache = new HashMap<String, LinkedList<Method>>();
 
+        ReflectUtil.checkPackageAccess(type);
         Method[] declaredMethods = type.getDeclaredMethods();
         for (int i = 0; i < declaredMethods.length; i++) {
             Method method = declaredMethods[i];
@@ -203,7 +206,7 @@
         Object value;
         if (getterMethod != null) {
             try {
-                value = getterMethod.invoke(bean);
+                value = MethodUtil.invoke(getterMethod, bean, (Object[]) null);
             } catch (IllegalAccessException exception) {
                 throw new RuntimeException(exception);
             } catch (InvocationTargetException exception) {
@@ -249,7 +252,7 @@
         }
 
         try {
-            setterMethod.invoke(bean, new Object[] {coerce(value, getType(key))});
+            MethodUtil.invoke(setterMethod, bean, new Object[] { coerce(value, getType(key)) });
         } catch (IllegalAccessException exception) {
             throw new RuntimeException(exception);
         } catch (InvocationTargetException exception) {
@@ -381,7 +384,7 @@
             throw new NullPointerException();
         }
 
-        Object coercedValue;
+        Object coercedValue = null;
 
         if (value == null) {
             // Null values can only be coerced to null
@@ -473,6 +476,7 @@
             while (valueOfMethod == null
                 && valueType != null) {
                 try {
+                    ReflectUtil.checkPackageAccess(type); 
                     valueOfMethod = type.getDeclaredMethod(VALUE_OF_METHOD_NAME, valueType);
                 } catch (NoSuchMethodException exception) {
                     // No-op
@@ -494,7 +498,7 @@
             }
 
             try {
-                coercedValue = valueOfMethod.invoke(null, value);
+                coercedValue = MethodUtil.invoke(valueOfMethod, null, new Object[] { value });
             } catch (IllegalAccessException exception) {
                 throw new RuntimeException(exception);
             } catch (InvocationTargetException exception) {
@@ -532,7 +536,7 @@
 
         if (getterMethod != null) {
             try {
-                value = (T)getterMethod.invoke(null, target);
+                value = (T) MethodUtil.invoke(getterMethod, null, new Object[] { target } );
             } catch (InvocationTargetException exception) {
                 throw new RuntimeException(exception);
             } catch (IllegalAccessException exception) {
@@ -590,7 +594,7 @@
 
         // Invoke the setter
         try {
-            setterMethod.invoke(null, target, value);
+            MethodUtil.invoke(setterMethod, null, new Object[] { target, value });
         } catch (InvocationTargetException exception) {
             throw new RuntimeException(exception);
         } catch (IllegalAccessException exception) {
@@ -805,7 +809,7 @@
 
         Field field;
         try {
-            field = type.getField(name);
+            field = FieldUtil.getField(type, name);
         } catch (NoSuchFieldException exception) {
             throw new IllegalArgumentException(exception);
         }
@@ -845,14 +849,14 @@
             String isMethodName = IS_PREFIX + key;
 
             try {
-                method = sourceType.getMethod(getMethodName, targetType);
+                method = MethodUtil.getMethod(sourceType, getMethodName, new Class[] { targetType });
             } catch (NoSuchMethodException exception) {
                 // No-op
             }
 
             if (method == null) {
                 try {
-                    method = sourceType.getMethod(isMethodName, targetType);
+                    method = MethodUtil.getMethod(sourceType, isMethodName, new Class[] { targetType });
                 } catch (NoSuchMethodException exception) {
                     // No-op
                 }
@@ -863,14 +867,14 @@
                 Class<?>[] interfaces = targetType.getInterfaces();
                 for (int i = 0; i < interfaces.length; i++) {
                     try {
-                        method = sourceType.getMethod(getMethodName, interfaces[i]);
+                        method = MethodUtil.getMethod(sourceType, getMethodName, new Class[] { interfaces[i] });
                     } catch (NoSuchMethodException exception) {
                         // No-op
                     }
 
                     if (method == null) {
                         try {
-                            method = sourceType.getMethod(isMethodName, interfaces[i]);
+                            method = MethodUtil.getMethod(sourceType, isMethodName, new Class[] { interfaces[i] });
                         } catch (NoSuchMethodException exception) {
                             // No-op
                         }
@@ -911,7 +915,7 @@
 
             String setMethodName = SET_PREFIX + key;
             try {
-                method = sourceType.getMethod(setMethodName, targetType, valueType);
+                method = MethodUtil.getMethod(sourceType, setMethodName, new Class[] { targetType, valueType });
             } catch (NoSuchMethodException exception) {
                 // No-op
             }
@@ -921,7 +925,7 @@
                 Class<?>[] interfaces = targetType.getInterfaces();
                 for (int i = 0; i < interfaces.length; i++) {
                     try {
-                        method = sourceType.getMethod(setMethodName, interfaces[i], valueType);
+                        method = MethodUtil.getMethod(sourceType, setMethodName, new Class[] { interfaces[i], valueType });
                     } catch (NoSuchMethodException exception) {
                         // No-op
                     }
--- a/javafx-fxml/src/javafx/fxml/FXMLLoader.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-fxml/src/javafx/fxml/FXMLLoader.java	Sat Jan 26 08:41:03 2013 -0800
@@ -88,6 +88,11 @@
 import com.sun.javafx.fxml.expression.ExpressionValue;
 import com.sun.javafx.fxml.expression.KeyPath;
 import java.net.MalformedURLException;
+import java.util.Locale;
+import sun.reflect.misc.ConstructorUtil;
+import sun.reflect.misc.FieldUtil;
+import sun.reflect.misc.MethodUtil;
+import sun.reflect.misc.ReflectUtil;
 
 /**
  * Loads an object hierarchy from an XML document.
@@ -762,7 +767,7 @@
 
                         try {
                             if (controllerFactory == null) {
-                                setController(type.newInstance());
+                                setController(ReflectUtil.newInstance(type));
                             } else {
                                 setController(controllerFactory.call(type));
                             }
@@ -823,13 +828,13 @@
             } else if (factory != null) {
                 Method factoryMethod;
                 try {
-                    factoryMethod = type.getMethod(factory);
+                    factoryMethod = MethodUtil.getMethod(type, factory, new Class[] {});
                 } catch (NoSuchMethodException exception) {
                     throw new LoadException(exception);
                 }
 
                 try {
-                    value = factoryMethod.invoke(null);
+                    value = MethodUtil.invoke(factoryMethod, null, new Object [] {});
                 } catch (IllegalAccessException exception) {
                     throw new LoadException(exception);
                 } catch (InvocationTargetException exception) {
@@ -840,7 +845,7 @@
 
                 if (value == null) {
                     try {
-                        value = type.newInstance();
+                        value = ReflectUtil.newInstance(type);
                     } catch (InstantiationException exception) {
                         throw new LoadException(exception);
                     } catch (IllegalAccessException exception) {
@@ -922,7 +927,8 @@
                         loadListener.readInternalAttribute(localName, value);
                     }
 
-                    resources = ResourceBundle.getBundle(value);
+                    resources = ResourceBundle.getBundle(value, Locale.getDefault(), 
+                            FXMLLoader.this.resources.getClass().getClassLoader());
                 } else if (localName.equals(INCLUDE_CHARSET_ATTRIBUTE)) {
                     if (loadListener != null) {
                         loadListener.readInternalAttribute(localName, value);
@@ -1069,7 +1075,7 @@
 
             Constructor<?> constructor = null;
             try {
-                constructor = sourceValueType.getConstructor(sourceValueType);
+                constructor = ConstructorUtil.getConstructor(sourceValueType, new Class[] { sourceValueType });
             } catch (NoSuchMethodException exception) {
                 // No-op
             }
@@ -1077,6 +1083,7 @@
             Object value;
             if (constructor != null) {
                 try {
+                    ReflectUtil.checkPackageAccess(sourceValueType);
                     value = constructor.newInstance(sourceValue);
                 } catch (InstantiationException exception) {
                     throw new LoadException(exception);
@@ -1457,9 +1464,9 @@
         public void handle(Event event) {
             try {
                 if (typed) {
-                    method.invoke(controller, event);
+                    MethodUtil.invoke(method, controller, new Object[] { event });
                 } else {
-                    method.invoke(controller);
+                    MethodUtil.invoke(method, controller, new Object[] {});
                 }
             } catch (InvocationTargetException exception) {
                 throw new RuntimeException(exception);
@@ -1692,7 +1699,7 @@
         defaultClassLoader = Thread.currentThread().getContextClassLoader();
 
         if (defaultClassLoader == null) {
-            defaultClassLoader = ClassLoader.getSystemClassLoader();
+            throw new NullPointerException();
         }
     }
 
@@ -2225,7 +2232,7 @@
 
                 if (initializeMethod != null) {
                     try {
-                        initializeMethod.invoke(controller);
+                        MethodUtil.invoke(initializeMethod, controller, new Object [] {});
                     } catch (IllegalAccessException exception) {
                         // TODO Throw when Initializable is deprecated/removed
                         // throw new LoadException(exception);
@@ -2583,7 +2590,7 @@
             Class<?> type = controllerType;
 
             while (type != Object.class) {
-                Field[] fields = type.getDeclaredFields();
+                Field[] fields = FieldUtil.getDeclaredFields(type);
 
                 for (int i = 0; i < fields.length; i++) {
                     Field field = fields[i];
@@ -2621,6 +2628,7 @@
             Class<?> type = controllerType;
 
             while (type != Object.class) {
+                ReflectUtil.checkPackageAccess(type);
                 Method[] methods = type.getDeclaredMethods();
 
                 for (int i = 0; i < methods.length; i++) {
@@ -2697,6 +2705,7 @@
      * This method now delegates to {@link #getDefaultClassLoader()}.
      */
     public static Class<?> loadType(String className) throws ClassNotFoundException {
+        ReflectUtil.checkPackageAccess(className);
         return Class.forName(className, true, defaultClassLoader);
     }
 
--- a/javafx-fxml/src/javafx/fxml/JavaFXBuilderFactory.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-fxml/src/javafx/fxml/JavaFXBuilderFactory.java	Sat Jan 26 08:41:03 2013 -0800
@@ -25,6 +25,11 @@
 
 package javafx.fxml;
 
+import com.sun.javafx.fxml.BeanAdapter;
+import com.sun.javafx.fxml.builder.JavaFXFontBuilder;
+import com.sun.javafx.fxml.builder.JavaFXImageBuilder;
+import com.sun.javafx.fxml.builder.JavaFXSceneBuilder;
+import com.sun.javafx.fxml.builder.URLBuilder;
 import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -32,6 +37,7 @@
 import java.net.URL;
 import java.util.AbstractMap;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -41,21 +47,18 @@
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableList;
 import javafx.collections.ObservableMap;
 import javafx.scene.Node;
-import javafx.util.Builder;
-import javafx.util.BuilderFactory;
-
-import com.sun.javafx.fxml.BeanAdapter;
-import com.sun.javafx.fxml.builder.*;
-import java.util.Arrays;
 import javafx.scene.Scene;
 import javafx.scene.image.Image;
 import javafx.scene.text.Font;
 import javafx.scene.web.WebView;
+import javafx.util.Builder;
+import javafx.util.BuilderFactory;
+import sun.reflect.misc.ConstructorUtil;
+import sun.reflect.misc.MethodUtil;
 
 /**
  * JavaFX builder factory.
@@ -139,7 +142,7 @@
                     //
                     boolean hasDefaultConstructor;
                     try {
-                        type.getConstructor();
+                        ConstructorUtil.getConstructor(type, new Class[] {});
                         // found!
                         // forces the factory  to return a builder if there is one.
                         // TODO: delete the line below when we are sure that both
@@ -214,7 +217,7 @@
 
         private ObjectBuilder() {
             try {
-                builder = createMethod.invoke(null);
+                builder = MethodUtil.invoke(createMethod, null, NO_ARGS);
             } catch (Exception e) {
                 //TODO
                 throw new RuntimeException("Creation of the builder " + builderClass.getName() + " failed.", e);
@@ -231,7 +234,7 @@
 
             Object res;
             try {
-                res = buildMethod.invoke(builder, NO_ARGS);
+                res = MethodUtil.invoke(buildMethod, builder, NO_ARGS);
                 // TODO:
                 // temporary special case for Node properties until
                 // platform builders are fixed
@@ -312,7 +315,7 @@
                         value = array;
                     }
 
-                    m.invoke(builder, new Object[] {BeanAdapter.coerce(value, type)});
+                    MethodUtil.invoke(m, builder, new Object[] { BeanAdapter.coerce(value, type) });
                 } catch (Exception e) {
                     Logger.getLogger(JavaFXBuilder.class.getName()).log(Level.WARNING,
                         "Method " + m.getName() + " failed", e);
@@ -340,8 +343,8 @@
                 Class<?> target = getTargetClass();
                 String suffix = Character.toUpperCase(propName.charAt(0)) + propName.substring(1);
                 try {
-                    getter = target.getMethod("get"+ suffix, NO_SIG);
-                    setter = target.getMethod("set"+ suffix, getter.getReturnType());
+                    getter = MethodUtil.getMethod(target, "get"+ suffix, NO_SIG);
+                    setter = MethodUtil.getMethod(target, "set"+ suffix, new Class[] { getter.getReturnType() });
                 } catch (Exception x) {
                 }
                 if (getter != null) {
@@ -436,8 +439,8 @@
 
     JavaFXBuilder(Class<?> builderClass) throws NoSuchMethodException, InstantiationException, IllegalAccessException {
         this.builderClass = builderClass;
-        createMethod = builderClass.getMethod("create");
-        buildMethod = builderClass.getMethod("build");
+        createMethod = MethodUtil.getMethod(builderClass, "create", NO_SIG);
+        buildMethod = MethodUtil.getMethod(builderClass, "build", NO_SIG);
         assert Modifier.isStatic(createMethod.getModifiers());
         assert !Modifier.isStatic(buildMethod.getModifiers());
     }
@@ -452,7 +455,7 @@
             name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
         }
 
-        for (Method m : builderClass.getMethods()) {
+        for (Method m : MethodUtil.getMethods(builderClass)) {
             if (m.getName().equals(name)) {
                 return m;
             }
--- a/javafx-ui-common/src/com/sun/javafx/Utils.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-ui-common/src/com/sun/javafx/Utils.java	Sat Jan 26 08:41:03 2013 -0800
@@ -1045,59 +1045,6 @@
         return PlatformUtil.isUnix();
     }
 
-    /**
-     * Utility for loading a class in a manner that will work with multiple
-     * class loaders, as is typically found in OSGI modular applications.
-     * In particular, this method will attempt to just load the class
-     * identified by className. If that fails, it attempts to load the
-     * class using the current thread's context class loader. If that fails,
-     * it attempts to use the class loader of the supplied "instance", and
-     * if it still fails it walks up the class hierarchy of the instance
-     * and attempts to use the class loader of each class in the super-type
-     * hierarchy.
-     *
-     * @param className The name of the class we want to load
-     * @param instance An optional instance used to help find the class to load
-     * @return The class. Cannot return null
-     * @throws ClassNotFoundException If the class cannot be found using any technique.
-     */
-    public static Class<?> loadClass(final String className, final Object instance)
-            throws ClassNotFoundException
-    {
-        try {
-            // Try just loading the class
-            return Class.forName(className);
-        } catch (ClassNotFoundException ex) {
-            // RT-17525 : Use context class loader only if Class.forName fails.
-            if (Thread.currentThread().getContextClassLoader() != null) {
-                try {
-                    return Thread.currentThread().getContextClassLoader().loadClass(className);
-                } catch (ClassNotFoundException ex2) {
-                    // Do nothing, just fall through
-                }
-            }
-
-            // RT-14177: Try looking up the class using the class loader of the
-            //           current class, walking up the list of superclasses
-            //           and checking each of them, before bailing and using
-            //           the context class loader.
-            if (instance != null) {
-                Class<?> currentType = instance.getClass();
-                while (currentType != null) {
-                    try {
-                        return currentType.getClassLoader().loadClass(className);
-                    } catch (ClassNotFoundException ex2) {
-                        currentType = currentType.getSuperclass();
-                    }
-                }
-            }
-
-            // We failed to find the class using any of the above means, so we're going
-            // to just throw the ClassNotFoundException that we caught earlier
-            throw ex;
-        }
-    }
-
     /***************************************************************************
      *                                                                         *
      * Unicode-related utilities                                               *
--- a/javafx-ui-common/src/com/sun/javafx/application/PlatformImpl.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-ui-common/src/com/sun/javafx/application/PlatformImpl.java	Sat Jan 26 08:41:03 2013 -0800
@@ -27,6 +27,8 @@
 
 import com.sun.javafx.css.StyleManager;
 import com.sun.javafx.runtime.SystemProperties;
+
+import java.security.AccessControlContext;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
@@ -175,10 +177,17 @@
                 return;
             }
 
+            final AccessControlContext acc = AccessController.getContext();
             Toolkit.getToolkit().defer(new Runnable() {
                 @Override public void run() {
                     try {
-                        r.run();
+                        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                            @Override
+                            public Void run() {
+                                r.run();
+                                return null;
+                            }
+                        }, acc);
                     } catch (Throwable t) {
                         System.err.println("Exception in runnable");
                         t.printStackTrace();
--- a/javafx-ui-common/src/com/sun/javafx/tk/TKScene.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-ui-common/src/com/sun/javafx/tk/TKScene.java	Sat Jan 26 08:41:03 2013 -0800
@@ -29,6 +29,8 @@
 import com.sun.javafx.sg.PGNode;
 import javafx.scene.input.Dragboard;
 
+import java.security.AccessControlContext;
+
 /**
  * TKScene
  *
@@ -36,6 +38,11 @@
 public interface TKScene {
 
     /**
+     * This method is used to set security context of the Scene.
+     */
+    public void setSecurityContext(AccessControlContext ctx);
+
+    /**
      * Waits until the render thread is available for synchronization
      * from the scene graph. Once this method returns, the caller has
      * the lock, and will continue to hold the lock until releaseSynchronization
--- a/javafx-ui-common/src/com/sun/javafx/tk/TKStage.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-ui-common/src/com/sun/javafx/tk/TKStage.java	Sat Jan 26 08:41:03 2013 -0800
@@ -27,6 +27,8 @@
 import com.sun.javafx.accessible.providers.AccessibleProvider;
 import com.sun.javafx.accessible.providers.AccessibleStageProvider;
 
+import java.security.AccessControlContext;
+
 /**
  * TKStage - Peer interface for a Stage
  *
@@ -34,6 +36,11 @@
 public interface TKStage {
 
     /**
+     * This method is used to set security context of the Stage.
+     */
+    public void setSecurityContext(AccessControlContext ctx);
+
+    /**
      * Listener for this stage peer to pass updates and events back to the stage
      *
      * @param listener The listener provided by the stage
@@ -107,13 +114,6 @@
 
     public void setMaximumSize(int maxWidth, int maxHeight);
 
-
-    /**
-     * This method is used to set security context of the Stage if needed.
-     * It is guaranteed to be called with user code on stack.
-     */
-    public void initSecurityContext();
-
     public void setFullScreen(boolean fullScreen);
 
     // =================================================================================================================
--- a/javafx-ui-common/src/javafx/scene/Scene.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-ui-common/src/javafx/scene/Scene.java	Sat Jan 26 08:41:03 2013 -0800
@@ -27,6 +27,7 @@
 package javafx.scene;
 
 import com.sun.javafx.scene.SceneHelper;
+import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -182,6 +183,8 @@
 
     private int dirtyBits;
 
+    private final AccessControlContext acc = AccessController.getContext();
+
     //Neither width nor height are initialized and will be calculated according to content when this Scene
     //is shown for the first time.
 //    public Scene() {
@@ -662,6 +665,7 @@
 
         impl_peer = windowPeer.createTKScene(isDepthBuffer());
         PerformanceTracker.logEvent("Scene.initPeer TKScene created");
+        impl_peer.setSecurityContext(acc);
         impl_peer.setTKSceneListener(new ScenePeerListener());
         impl_peer.setTKScenePaintListener(new ScenePeerPaintListener());
         impl_peer.setScene(this);
--- a/javafx-ui-common/src/javafx/stage/Stage.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-ui-common/src/javafx/stage/Stage.java	Sat Jan 26 08:41:03 2013 -0800
@@ -976,12 +976,26 @@
             Scene scene = getScene();
             boolean rtl = scene != null && scene.getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT;
 
-            impl_peer = toolkit.createTKStage(getStyle(), isPrimary(),
-                    getModality(), tkStage, rtl);
-            impl_peer.setImportant(isImportant());
+            impl_peer = toolkit.createTKStage(getStyle(), isPrimary(), getModality(), tkStage, rtl);
             peerListener = new StagePeerListener(this, STAGE_ACCESSOR);
             
+           // Insert this into stages so we have a references to all created stages
+            stages.add(this);
+        }
+    }
+
+    
+    /**
+     * @treatAsPrivate implementation detail
+     * @deprecated This is an internal API that is not intended for use and will be removed in the next version
+     */
+    @Deprecated
+    @Override protected void impl_visibleChanged(boolean value) {
+        super.impl_visibleChanged(value);
+
+        if (value) {
             // Finish initialization
+            impl_peer.setImportant(isImportant());
             impl_peer.setResizable(isResizable());
             impl_peer.setFullScreen(isFullScreen());
             impl_peer.setIconified(isIconified());
@@ -998,20 +1012,8 @@
             if (impl_peer != null) {
                 impl_peer.setIcons(platformImages);
             }
+        }
 
-            // Insert this into stages so we have a references to all created stages
-            stages.add(this);
-        }
-    }
-
-    
-    /**
-     * @treatAsPrivate implementation detail
-     * @deprecated This is an internal API that is not intended for use and will be removed in the next version
-     */
-    @Deprecated
-    @Override protected void impl_visibleChanged(boolean value) {
-        super.impl_visibleChanged(value);
         if (!value && (impl_peer != null)) {
             // Remove form active stage list
             stages.remove(this);
--- a/javafx-ui-common/src/javafx/stage/Window.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-ui-common/src/javafx/stage/Window.java	Sat Jan 26 08:41:03 2013 -0800
@@ -24,6 +24,7 @@
  */
 package javafx.stage;
 
+import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Iterator;
@@ -117,6 +118,8 @@
         return iterator;
     }
 
+    private final AccessControlContext acc = AccessController.getContext();
+
     protected Window() {
         // necessary for WindowCloseRequestHandler
         initializeInternalEventDispatcher();
@@ -700,6 +703,8 @@
             Toolkit tk = Toolkit.getToolkit();
             if (impl_peer != null) {
                 if (newVisible) {
+                    impl_peer.setSecurityContext(acc);
+
                     if (peerListener == null) {
                         peerListener = new WindowPeerListener(Window.this);
                     }
@@ -711,12 +716,6 @@
                     // Register pulse listener
                     tk.addStageTkPulseListener(peerBoundsConfigurator);
 
-                    // This method must be called from init or postinit
-                    // to make sure that the runtime knows the security
-                    // context of where this stage was created and
-                    // initialized
-                    impl_peer.initSecurityContext();
-
                     if (getScene() != null) {
                         getScene().impl_initPeer();
                         impl_peer.setScene(getScene().impl_getPeer());
--- a/javafx-ui-controls/src/javafx/scene/control/Control.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-ui-controls/src/javafx/scene/control/Control.java	Sat Jan 26 08:41:03 2013 -0800
@@ -41,7 +41,6 @@
 import javafx.scene.Node;
 import javafx.scene.input.ContextMenuEvent;
 import javafx.scene.layout.Region;
-import com.sun.javafx.Utils;
 import com.sun.javafx.accessible.providers.AccessibleProvider;
 import com.sun.javafx.application.PlatformImpl;
 import com.sun.javafx.beans.annotations.DuplicateInBuilderProperties;
@@ -82,6 +81,59 @@
             PlatformImpl.setDefaultPlatformUserAgentStylesheet();
         }
     }
+
+    /**
+     * Utility for loading a class in a manner that will work with multiple
+     * class loaders, as is typically found in OSGI modular applications.
+     * In particular, this method will attempt to just load the class
+     * identified by className. If that fails, it attempts to load the
+     * class using the current thread's context class loader. If that fails,
+     * it attempts to use the class loader of the supplied "instance", and
+     * if it still fails it walks up the class hierarchy of the instance
+     * and attempts to use the class loader of each class in the super-type
+     * hierarchy.
+     *
+     * @param className The name of the class we want to load
+     * @param instance An optional instance used to help find the class to load
+     * @return The class. Cannot return null
+     * @throws ClassNotFoundException If the class cannot be found using any technique.
+     */
+    static Class<?> loadClass(final String className, final Object instance)
+            throws ClassNotFoundException
+    {
+        try {
+            // Try just loading the class
+            return Class.forName(className);
+        } catch (ClassNotFoundException ex) {
+            // RT-17525 : Use context class loader only if Class.forName fails.
+            if (Thread.currentThread().getContextClassLoader() != null) {
+                try {
+                    return Thread.currentThread().getContextClassLoader().loadClass(className);
+                } catch (ClassNotFoundException ex2) {
+                    // Do nothing, just fall through
+                }
+            }
+
+            // RT-14177: Try looking up the class using the class loader of the
+            //           current class, walking up the list of superclasses
+            //           and checking each of them, before bailing and using
+            //           the context class loader.
+            if (instance != null) {
+                Class<?> currentType = instance.getClass();
+                while (currentType != null) {
+                    try {
+                        return currentType.getClassLoader().loadClass(className);
+                    } catch (ClassNotFoundException ex2) {
+                        currentType = currentType.getSuperclass();
+                    }
+                }
+            }
+
+            // We failed to find the class using any of the above means, so we're going
+            // to just throw the ClassNotFoundException that we caught earlier
+            throw ex;
+        }
+    }
     
     /***************************************************************************
      *                                                                         *
@@ -622,7 +674,7 @@
         }
 
         try {
-            final Class<?> skinClass = Utils.loadClass(skinClassName.get(), this);
+            final Class<?> skinClass = Control.loadClass(skinClassName.get(), this);
             Constructor<?>[] constructors = skinClass.getConstructors();
             Constructor<?> skinConstructor = null;
             for (Constructor<?> c : constructors) {
--- a/javafx-ui-controls/src/javafx/scene/control/PopupControl.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/javafx-ui-controls/src/javafx/scene/control/PopupControl.java	Sat Jan 26 08:41:03 2013 -0800
@@ -41,7 +41,6 @@
 import javafx.scene.Group;
 import javafx.scene.Node;
 import javafx.stage.PopupWindow;
-import com.sun.javafx.Utils;
 import com.sun.javafx.application.PlatformImpl;
 import com.sun.javafx.collections.TrackableObservableList;
 import com.sun.javafx.css.CssError;
@@ -1186,7 +1185,7 @@
             }
 
             try {
-                final Class<?> skinClass = Utils.loadClass(skinClassName.get(), this);
+                final Class<?> skinClass = Control.loadClass(skinClassName.get(), this);
                 Constructor<?>[] constructors = skinClass.getConstructors();
                 Constructor<?> skinConstructor = null;
                 for (Constructor<?> c : constructors) {
--- a/test-stub-toolkit/src/com/sun/javafx/pgstub/StubScene.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/test-stub-toolkit/src/com/sun/javafx/pgstub/StubScene.java	Sat Jan 26 08:41:03 2013 -0800
@@ -27,18 +27,25 @@
 import com.sun.javafx.geom.CameraImpl;
 import com.sun.javafx.geom.PickRay;
 import com.sun.javafx.sg.PGNode;
-import com.sun.javafx.tk.Toolkit;
 import com.sun.javafx.tk.TKScene;
 import com.sun.javafx.tk.TKSceneListener;
 import com.sun.javafx.tk.TKScenePaintListener;
 
 import javafx.scene.input.Dragboard;
 
+import java.security.AccessControlContext;
+
 public class StubScene implements TKScene {
+
     StubStage stage;
     private TKSceneListener listener;
     private Object cursor;
 
+    @Override
+    public void setSecurityContext(AccessControlContext ctx) {
+        // ignore
+    }
+
     public void waitForSynchronization() {
         //ignore
     }
--- a/test-stub-toolkit/src/com/sun/javafx/pgstub/StubStage.java	Thu Jan 24 17:24:26 2013 -0800
+++ b/test-stub-toolkit/src/com/sun/javafx/pgstub/StubStage.java	Sat Jan 26 08:41:03 2013 -0800
@@ -24,6 +24,7 @@
  */
 package com.sun.javafx.pgstub;
 
+import java.security.AccessControlContext;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Queue;
@@ -39,6 +40,7 @@
  * @author Richard Bair
  */
 public class StubStage implements TKStage {
+
     private NotificationSender notificationSender = new NotificationSender();
 
     @Override
@@ -177,7 +179,7 @@
     }
 
     @Override
-    public void initSecurityContext() {
+    public void setSecurityContext(AccessControlContext ctx) {
     }
 
     @Override
@@ -290,7 +292,7 @@
     /**
      * Delete accessible native object corresponding to controls
      * 
-     * @param ac 
+     * @param nativeAcc
      * returns native Object
      */
     @Override public void accessibleDestroyBasicProvider(Object nativeAcc) {