modules/fxml/src/main/java/javafx/fxml/FXMLLoader.java

Print this page
rev 8615 : RT-39977: Replace sun.security.util.SecurityConstants with java.lang.RuntimePermission


  78 import com.sun.javafx.beans.IDProperty;
  79 import com.sun.javafx.fxml.BeanAdapter;
  80 import com.sun.javafx.fxml.LoadListener;
  81 import com.sun.javafx.fxml.ParseTraceElement;
  82 import com.sun.javafx.fxml.PropertyNotFoundException;
  83 import com.sun.javafx.fxml.expression.Expression;
  84 import com.sun.javafx.fxml.expression.ExpressionValue;
  85 import com.sun.javafx.fxml.expression.KeyPath;
  86 import java.net.MalformedURLException;
  87 import java.security.AccessController;
  88 import java.security.AllPermission;
  89 import java.security.PrivilegedAction;
  90 import java.util.EnumMap;
  91 import java.util.Locale;
  92 import java.util.StringTokenizer;
  93 import sun.reflect.CallerSensitive;
  94 import sun.reflect.Reflection;
  95 import sun.reflect.misc.ConstructorUtil;
  96 import sun.reflect.misc.MethodUtil;
  97 import sun.reflect.misc.ReflectUtil;
  98 import sun.security.util.SecurityConstants;
  99 
 100 /**
 101  * Loads an object hierarchy from an XML document.
 102  * @since JavaFX 2.0
 103  */
 104 public class FXMLLoader {





 105     // Abstract base class for elements
 106     private abstract class Element {
 107         public final Element parent;
 108 
 109         public Object value = null;
 110         private BeanAdapter valueAdapter = null;
 111 
 112         public final LinkedList<Attribute> eventHandlerAttributes = new LinkedList<Attribute>();
 113         public final LinkedList<Attribute> instancePropertyAttributes = new LinkedList<Attribute>();
 114         public final LinkedList<Attribute> staticPropertyAttributes = new LinkedList<Attribute>();
 115         public final LinkedList<PropertyElement> staticPropertyElements = new LinkedList<PropertyElement>();
 116 
 117         public Element() {
 118             parent = current;
 119         }
 120 
 121         public boolean isCollection() {
 122             // Return true if value is a list, or if the value's type defines
 123             // a default property that is a list
 124             boolean collection;


3034             return true;
3035         }
3036         ClassLoader acl = to;
3037         do {
3038             acl = acl.getParent();
3039             if (from == acl) {
3040                 return false;
3041             }
3042         } while (acl != null);
3043         return true;
3044     }
3045 
3046     private static ClassLoader getDefaultClassLoader(Class caller) {
3047         if (defaultClassLoader == null) {
3048             final SecurityManager sm = System.getSecurityManager();
3049             if (sm != null) {
3050                 final ClassLoader callerClassLoader = (caller != null) ?
3051                         caller.getClassLoader() :
3052                         null;
3053                 if (needsClassLoaderPermissionCheck(callerClassLoader, FXMLLoader.class.getClassLoader())) {
3054                     sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
3055                 }
3056             }
3057             return Thread.currentThread().getContextClassLoader();
3058         }
3059         return defaultClassLoader;
3060     }
3061 
3062     /**
3063      * Returns the default class loader.
3064      * @since JavaFX 2.1
3065      */
3066     @CallerSensitive
3067     public static ClassLoader getDefaultClassLoader() {
3068         final SecurityManager sm = System.getSecurityManager();
3069         final Class caller = (sm != null) ?
3070                 Reflection.getCallerClass() :
3071                 null;
3072         return getDefaultClassLoader(caller);
3073     }
3074 




  78 import com.sun.javafx.beans.IDProperty;
  79 import com.sun.javafx.fxml.BeanAdapter;
  80 import com.sun.javafx.fxml.LoadListener;
  81 import com.sun.javafx.fxml.ParseTraceElement;
  82 import com.sun.javafx.fxml.PropertyNotFoundException;
  83 import com.sun.javafx.fxml.expression.Expression;
  84 import com.sun.javafx.fxml.expression.ExpressionValue;
  85 import com.sun.javafx.fxml.expression.KeyPath;
  86 import java.net.MalformedURLException;
  87 import java.security.AccessController;
  88 import java.security.AllPermission;
  89 import java.security.PrivilegedAction;
  90 import java.util.EnumMap;
  91 import java.util.Locale;
  92 import java.util.StringTokenizer;
  93 import sun.reflect.CallerSensitive;
  94 import sun.reflect.Reflection;
  95 import sun.reflect.misc.ConstructorUtil;
  96 import sun.reflect.misc.MethodUtil;
  97 import sun.reflect.misc.ReflectUtil;

  98 
  99 /**
 100  * Loads an object hierarchy from an XML document.
 101  * @since JavaFX 2.0
 102  */
 103 public class FXMLLoader {
 104 
 105     // Indicates permission to get the ClassLoader
 106     private static final RuntimePermission GET_CLASSLOADER_PERMISSION =
 107         new RuntimePermission("getClassLoader");
 108 
 109     // Abstract base class for elements
 110     private abstract class Element {
 111         public final Element parent;
 112 
 113         public Object value = null;
 114         private BeanAdapter valueAdapter = null;
 115 
 116         public final LinkedList<Attribute> eventHandlerAttributes = new LinkedList<Attribute>();
 117         public final LinkedList<Attribute> instancePropertyAttributes = new LinkedList<Attribute>();
 118         public final LinkedList<Attribute> staticPropertyAttributes = new LinkedList<Attribute>();
 119         public final LinkedList<PropertyElement> staticPropertyElements = new LinkedList<PropertyElement>();
 120 
 121         public Element() {
 122             parent = current;
 123         }
 124 
 125         public boolean isCollection() {
 126             // Return true if value is a list, or if the value's type defines
 127             // a default property that is a list
 128             boolean collection;


3038             return true;
3039         }
3040         ClassLoader acl = to;
3041         do {
3042             acl = acl.getParent();
3043             if (from == acl) {
3044                 return false;
3045             }
3046         } while (acl != null);
3047         return true;
3048     }
3049 
3050     private static ClassLoader getDefaultClassLoader(Class caller) {
3051         if (defaultClassLoader == null) {
3052             final SecurityManager sm = System.getSecurityManager();
3053             if (sm != null) {
3054                 final ClassLoader callerClassLoader = (caller != null) ?
3055                         caller.getClassLoader() :
3056                         null;
3057                 if (needsClassLoaderPermissionCheck(callerClassLoader, FXMLLoader.class.getClassLoader())) {
3058                     sm.checkPermission(GET_CLASSLOADER_PERMISSION);
3059                 }
3060             }
3061             return Thread.currentThread().getContextClassLoader();
3062         }
3063         return defaultClassLoader;
3064     }
3065 
3066     /**
3067      * Returns the default class loader.
3068      * @since JavaFX 2.1
3069      */
3070     @CallerSensitive
3071     public static ClassLoader getDefaultClassLoader() {
3072         final SecurityManager sm = System.getSecurityManager();
3073         final Class caller = (sm != null) ?
3074                 Reflection.getCallerClass() :
3075                 null;
3076         return getDefaultClassLoader(caller);
3077     }
3078