ab3709
Index: xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java
ab3709
===================================================================
ab3709
--- xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java	(revision 1538849)
ab3709
+++ xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java	(revision 1538850)
ab3709
@@ -25,8 +25,6 @@
ab3709
 import java.lang.reflect.Method;
ab3709
 import java.lang.reflect.Modifier;
ab3709
 import java.lang.reflect.Type;
ab3709
-import java.security.AccessController;
ab3709
-import java.security.PrivilegedAction;
ab3709
 import java.util.ArrayList;
ab3709
 import java.util.Arrays;
ab3709
 import java.util.Collections;
ab3709
@@ -1011,12 +1009,7 @@
ab3709
     }
ab3709
 
ab3709
     private static void setAccessible(final AccessibleObject accessibleObject) {
ab3709
-        AccessController.doPrivileged(new PrivilegedAction<Object>() {
ab3709
-            public Object run() {
ab3709
-                accessibleObject.setAccessible(true);
ab3709
-                return null;
ab3709
-            }
ab3709
-        });
ab3709
+        accessibleObject.setAccessible(true);
ab3709
     }
ab3709
 
ab3709
     private static String toParameterList(Class[] parameterTypes) {
ab3709
Index: xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java
ab3709
===================================================================
ab3709
--- xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java	(revision 1538849)
ab3709
+++ xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java	(revision 1538850)
ab3709
@@ -24,11 +24,7 @@
ab3709
 
ab3709
 public abstract class SunURLClassPath implements ClassPath {
ab3709
     public static ClassLoader getContextClassLoader() {
ab3709
-        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
ab3709
-            public Object run() {
ab3709
-                return Thread.currentThread().getContextClassLoader();
ab3709
-            }
ab3709
-        });
ab3709
+        return Thread.currentThread().getContextClassLoader();
ab3709
     }
ab3709
 
ab3709
     private java.lang.reflect.Field ucpField;
ab3709
Index: xbean-classloader/src/main/java/org/apache/xbean/classloader/JarFileClassLoader.java
ab3709
===================================================================
ab3709
--- xbean-classloader/src/main/java/org/apache/xbean/classloader/JarFileClassLoader.java	(revision 1539052)
ab3709
+++ xbean-classloader/src/main/java/org/apache/xbean/classloader/JarFileClassLoader.java	(revision 1539053)
ab3709
@@ -20,12 +20,7 @@
ab3709
 import java.io.File;
ab3709
 import java.net.URL;
ab3709
 import java.net.URI;
ab3709
-import java.security.AccessControlContext;
ab3709
-import java.security.AccessController;
ab3709
 import java.security.CodeSource;
ab3709
-import java.security.PrivilegedAction;
ab3709
-import java.security.PrivilegedExceptionAction;
ab3709
-import java.security.PrivilegedActionException;
ab3709
 import java.security.cert.Certificate;
ab3709
 import java.util.Collection;
ab3709
 import java.util.Enumeration;
ab3709
@@ -49,7 +44,6 @@
ab3709
     private static final URL[] EMPTY_URLS = new URL[0];
ab3709
 
ab3709
     private final UrlResourceFinder resourceFinder = new UrlResourceFinder();
ab3709
-    private final AccessControlContext acc;
ab3709
 
ab3709
     /**
ab3709
      * Creates a JarFileClassLoader that is a child of the system class loader.
ab3709
@@ -58,7 +52,6 @@
ab3709
      */
ab3709
     public JarFileClassLoader(String name, URL[] urls) {
ab3709
         super(name, EMPTY_URLS);
ab3709
-        this.acc = AccessController.getContext();
ab3709
         addURLs(urls);
ab3709
     }
ab3709
 
ab3709
@@ -70,13 +63,11 @@
ab3709
      */
ab3709
     public JarFileClassLoader(String name, URL[] urls, ClassLoader parent) {
ab3709
         super(name, EMPTY_URLS, parent);
ab3709
-        this.acc = AccessController.getContext();
ab3709
         addURLs(urls);
ab3709
     }
ab3709
 
ab3709
     public JarFileClassLoader(String name, URL[] urls, ClassLoader parent, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses) {
ab3709
         super(name, EMPTY_URLS, parent, inverseClassLoading, hiddenClasses, nonOverridableClasses);
ab3709
-        this.acc = AccessController.getContext();
ab3709
         addURLs(urls);
ab3709
     }
ab3709
 
ab3709
@@ -88,19 +79,16 @@
ab3709
      */
ab3709
     public JarFileClassLoader(String name, URL[] urls, ClassLoader[] parents) {
ab3709
         super(name, EMPTY_URLS, parents);
ab3709
-        this.acc = AccessController.getContext();
ab3709
         addURLs(urls);
ab3709
     }
ab3709
 
ab3709
     public JarFileClassLoader(String name, URL[] urls, ClassLoader[] parents, boolean inverseClassLoading, Collection hiddenClasses, Collection nonOverridableClasses) {
ab3709
         super(name, EMPTY_URLS, parents, inverseClassLoading, hiddenClasses, nonOverridableClasses);
ab3709
-        this.acc = AccessController.getContext();
ab3709
         addURLs(urls);
ab3709
     }
ab3709
 
ab3709
     public JarFileClassLoader(String name, URL[] urls, ClassLoader[] parents, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses) {
ab3709
         super(name, EMPTY_URLS, parents, inverseClassLoading, hiddenClasses, nonOverridableClasses);
ab3709
-        this.acc = AccessController.getContext();
ab3709
         addURLs(urls);
ab3709
     }
ab3709
 
ab3709
@@ -115,12 +103,7 @@
ab3709
      * {@inheritDoc}
ab3709
      */
ab3709
     public void addURL(final URL url) {
ab3709
-        AccessController.doPrivileged(new PrivilegedAction() {
ab3709
-            public Object run() {
ab3709
-                resourceFinder.addUrl(url);
ab3709
-                return null;
ab3709
-            }
ab3709
-        }, acc);
ab3709
+        resourceFinder.addUrl(url);
ab3709
     }
ab3709
 
ab3709
     /**
ab3709
@@ -128,12 +111,7 @@
ab3709
      * @param urls the URLs to add
ab3709
      */
ab3709
     protected void addURLs(final URL[] urls) {
ab3709
-        AccessController.doPrivileged(new PrivilegedAction() {
ab3709
-            public Object run() {
ab3709
-                resourceFinder.addUrls(urls);
ab3709
-                return null;
ab3709
-            }
ab3709
-        }, acc);
ab3709
+        resourceFinder.addUrls(urls);
ab3709
     }
ab3709
 
ab3709
     /**
ab3709
@@ -148,11 +126,7 @@
ab3709
      * {@inheritDoc}
ab3709
      */
ab3709
     public URL findResource(final String resourceName) {
ab3709
-        return (URL) AccessController.doPrivileged(new PrivilegedAction() {
ab3709
-            public Object run() {
ab3709
-                return resourceFinder.findResource(resourceName);
ab3709
-            }
ab3709
-        }, acc);
ab3709
+        return resourceFinder.findResource(resourceName);
ab3709
     }
ab3709
 
ab3709
     /**
ab3709
@@ -164,11 +138,7 @@
ab3709
         Enumeration parentResources = super.findResources(resourceName);
ab3709
 
ab3709
         // get the classes from my urls
ab3709
-        Enumeration myResources = (Enumeration) AccessController.doPrivileged(new PrivilegedAction() {
ab3709
-            public Object run() {
ab3709
-                return resourceFinder.findResources(resourceName);
ab3709
-            }
ab3709
-        }, acc);
ab3709
+        Enumeration myResources = resourceFinder.findResources(resourceName);
ab3709
 
ab3709
         // join the two together
ab3709
         Enumeration resources = new UnionEnumeration(parentResources, myResources);
ab3709
@@ -196,11 +166,7 @@
ab3709
         }
ab3709
 
ab3709
         // get a resource handle to the library
ab3709
-        ResourceHandle resourceHandle = (ResourceHandle) AccessController.doPrivileged(new PrivilegedAction() {
ab3709
-            public Object run() {
ab3709
-                return resourceFinder.getResource(resourceName);
ab3709
-            }
ab3709
-        }, acc);
ab3709
+        ResourceHandle resourceHandle = resourceFinder.getResource(resourceName);
ab3709
 
ab3709
         if (resourceHandle == null) {
ab3709
             return null;
ab3709
@@ -220,62 +186,53 @@
ab3709
      * {@inheritDoc}
ab3709
      */
ab3709
     protected Class findClass(final String className) throws ClassNotFoundException {
ab3709
-        try {
ab3709
-            return (Class) AccessController.doPrivileged(new PrivilegedExceptionAction() {
ab3709
-                public Object run() throws ClassNotFoundException {
ab3709
-                    // first think check if we are allowed to define the package
ab3709
-                    SecurityManager securityManager = System.getSecurityManager();
ab3709
-                    if (securityManager != null) {
ab3709
-                        String packageName;
ab3709
-                        int packageEnd = className.lastIndexOf('.');
ab3709
-                        if (packageEnd >= 0) {
ab3709
-                            packageName = className.substring(0, packageEnd);
ab3709
-                            securityManager.checkPackageDefinition(packageName);
ab3709
-                        }
ab3709
-                    }
ab3709
+        // first think check if we are allowed to define the package
ab3709
+        SecurityManager securityManager = System.getSecurityManager();
ab3709
+        if (securityManager != null) {
ab3709
+            String packageName;
ab3709
+            int packageEnd = className.lastIndexOf('.');
ab3709
+            if (packageEnd >= 0) {
ab3709
+                packageName = className.substring(0, packageEnd);
ab3709
+                securityManager.checkPackageDefinition(packageName);
ab3709
+            }
ab3709
+        }
ab3709
 
ab3709
+        // convert the class name to a file name
ab3709
+        String resourceName = className.replace('.', '/') + ".class";
ab3709
 
ab3709
-                    // convert the class name to a file name
ab3709
-                    String resourceName = className.replace('.', '/') + ".class";
ab3709
+        // find the class file resource
ab3709
+        ResourceHandle resourceHandle = resourceFinder.getResource(resourceName);
ab3709
+        if (resourceHandle == null) {
ab3709
+            throw new ClassNotFoundException(className);
ab3709
+        }
ab3709
 
ab3709
-                    // find the class file resource
ab3709
-                    ResourceHandle resourceHandle = resourceFinder.getResource(resourceName);
ab3709
-                    if (resourceHandle == null) {
ab3709
-                        throw new ClassNotFoundException(className);
ab3709
-                    }
ab3709
+        byte[] bytes;
ab3709
+        Manifest manifest;
ab3709
+        try {
ab3709
+            // get the bytes from the class file
ab3709
+            bytes = resourceHandle.getBytes();
ab3709
+            
ab3709
+            // get the manifest for defining the packages
ab3709
+            manifest = resourceHandle.getManifest();
ab3709
+        } catch (IOException e) {
ab3709
+            throw new ClassNotFoundException(className, e);
ab3709
+        }
ab3709
 
ab3709
-                    byte[] bytes;
ab3709
-                    Manifest manifest;
ab3709
-                    try {
ab3709
-                        // get the bytes from the class file
ab3709
-                        bytes = resourceHandle.getBytes();
ab3709
+        // get the certificates for the code source
ab3709
+        Certificate[] certificates = resourceHandle.getCertificates();
ab3709
+        
ab3709
+        // the code source url is used to define the package and as the security context for the class
ab3709
+        URL codeSourceUrl = resourceHandle.getCodeSourceUrl();
ab3709
 
ab3709
-                        // get the manifest for defining the packages
ab3709
-                        manifest = resourceHandle.getManifest();
ab3709
-                    } catch (IOException e) {
ab3709
-                        throw new ClassNotFoundException(className, e);
ab3709
-                    }
ab3709
+        // define the package (required for security)
ab3709
+        definePackage(className, codeSourceUrl, manifest);
ab3709
 
ab3709
-                    // get the certificates for the code source
ab3709
-                    Certificate[] certificates = resourceHandle.getCertificates();
ab3709
-
ab3709
-                    // the code source url is used to define the package and as the security context for the class
ab3709
-                    URL codeSourceUrl = resourceHandle.getCodeSourceUrl();
ab3709
-
ab3709
-                    // define the package (required for security)
ab3709
-                    definePackage(className, codeSourceUrl, manifest);
ab3709
-
ab3709
-                    // this is the security context of the class
ab3709
-                    CodeSource codeSource = new CodeSource(codeSourceUrl, certificates);
ab3709
-
ab3709
-                    // load the class into the vm
ab3709
-                    Class clazz = defineClass(className, bytes, 0, bytes.length, codeSource);
ab3709
-                    return clazz;
ab3709
-                }
ab3709
-            }, acc);
ab3709
-        } catch (PrivilegedActionException e) {
ab3709
-            throw (ClassNotFoundException) e.getException();
ab3709
-        }
ab3709
+        // this is the security context of the class
ab3709
+        CodeSource codeSource = new CodeSource(codeSourceUrl, certificates);
ab3709
+        
ab3709
+        // load the class into the vm
ab3709
+        Class clazz = defineClass(className, bytes, 0, bytes.length, codeSource);
ab3709
+        return clazz;
ab3709
     }
ab3709
 
ab3709
     private void definePackage(String className, URL jarUrl, Manifest manifest) {
ab3709
Index: xbean-classpath/src/main/java/org/apache/xbean/classpath/TomcatClassPath.java
ab3709
===================================================================
ab3709
--- xbean-classpath/src/main/java/org/apache/xbean/classpath/TomcatClassPath.java	(revision 1539055)
ab3709
+++ xbean-classpath/src/main/java/org/apache/xbean/classpath/TomcatClassPath.java	(revision 1539056)
ab3709
@@ -20,8 +20,6 @@
ab3709
 import java.lang.reflect.Method;
ab3709
 import java.net.URL;
ab3709
 import java.net.URLClassLoader;
ab3709
-import java.security.AccessController;
ab3709
-import java.security.PrivilegedAction;
ab3709
 
ab3709
 public class TomcatClassPath extends SunURLClassPath {
ab3709
 
ab3709
@@ -140,36 +138,19 @@
ab3709
      * @return URLClassLoader.addURL method instance
ab3709
      */
ab3709
     private Method getAddURLMethod() throws Exception {
ab3709
-        return (Method) AccessController.doPrivileged(new PrivilegedAction() {
ab3709
-            public Object run() {
ab3709
-                Method method = null;
ab3709
-                try {
ab3709
-                    Class clazz = URLClassLoader.class;
ab3709
-                    method = clazz.getDeclaredMethod("addURL", new Class[]{URL.class});
ab3709
-                    method.setAccessible(true);
ab3709
-                    return method;
ab3709
-                } catch (Exception e2) {
ab3709
-                    e2.printStackTrace();
ab3709
-                }
ab3709
-                return method;
ab3709
-            }
ab3709
-        });
ab3709
+        Method method = null;
ab3709
+        Class clazz = URLClassLoader.class;
ab3709
+        method = clazz.getDeclaredMethod("addURL", new Class[]{URL.class});
ab3709
+        method.setAccessible(true);
ab3709
+        return method;
ab3709
     }
ab3709
 
ab3709
     private Method getAddRepositoryMethod() throws Exception {
ab3709
-        return (Method) AccessController.doPrivileged(new PrivilegedAction() {
ab3709
-            public Object run() {
ab3709
-                Method method = null;
ab3709
-                try {
ab3709
-                    Class clazz = getClassLoader().getClass();
ab3709
-                    method = clazz.getDeclaredMethod("addRepository", new Class[]{String.class});
ab3709
-                    method.setAccessible(true);
ab3709
-                    return method;
ab3709
-                } catch (Exception e2) {
ab3709
-                    throw (IllegalStateException) new IllegalStateException("Unable to find or access the addRepository method in StandardClassLoader").initCause(e2);
ab3709
-                }
ab3709
-            }
ab3709
-        });
ab3709
+        Method method = null;
ab3709
+        Class clazz = getClassLoader().getClass();
ab3709
+        method = clazz.getDeclaredMethod("addRepository", new Class[]{String.class});
ab3709
+        method.setAccessible(true);
ab3709
+        return method;
ab3709
     }
ab3709
 
ab3709
 }
ab3709
Index: xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java
ab3709
===================================================================
ab3709
--- xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java	(revision 1539055)
ab3709
+++ xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java	(revision 1539056)
ab3709
@@ -19,10 +19,9 @@
ab3709
 import java.io.File;
ab3709
 import java.net.URL;
ab3709
 import java.net.URLClassLoader;
ab3709
-import java.security.AccessController;
ab3709
-import java.security.PrivilegedAction;
ab3709
 
ab3709
 public abstract class SunURLClassPath implements ClassPath {
ab3709
+
ab3709
     public static ClassLoader getContextClassLoader() {
ab3709
         return Thread.currentThread().getContextClassLoader();
ab3709
     }
ab3709
@@ -64,20 +63,9 @@
ab3709
     private java.lang.reflect.Field getUcpField() throws Exception {
ab3709
         if (ucpField == null) {
ab3709
             // Add them to the URLClassLoader's classpath
ab3709
-            ucpField = (java.lang.reflect.Field) AccessController.doPrivileged(new PrivilegedAction() {
ab3709
-                public Object run() {
ab3709
-                    java.lang.reflect.Field ucp = null;
ab3709
-                    try {
ab3709
-                        ucp = URLClassLoader.class.getDeclaredField("ucp");
ab3709
-                        ucp.setAccessible(true);
ab3709
-                    } catch (Exception e2) {
ab3709
-                        e2.printStackTrace();
ab3709
-                    }
ab3709
-                    return ucp;
ab3709
-                }
ab3709
-            });
ab3709
+            ucpField = URLClassLoader.class.getDeclaredField("ucp");
ab3709
+            ucpField.setAccessible(true);
ab3709
         }
ab3709
-
ab3709
         return ucpField;
ab3709
     }
ab3709