geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1539056 - in /geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath: SunURLClassPath.java TomcatClassPath.java
Date Tue, 05 Nov 2013 16:53:32 GMT
Author: gawor
Date: Tue Nov  5 16:53:32 2013
New Revision: 1539056

URL: http://svn.apache.org/r1539056
Log:
XBEAN-255: Remove doPrivleged blocks

Modified:
    geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java
    geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/TomcatClassPath.java

Modified: geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java?rev=1539056&r1=1539055&r2=1539056&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java
(original)
+++ geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/SunURLClassPath.java
Tue Nov  5 16:53:32 2013
@@ -19,10 +19,9 @@ package org.apache.xbean.classpath;
 import java.io.File;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 
 public abstract class SunURLClassPath implements ClassPath {
+
     public static ClassLoader getContextClassLoader() {
         return Thread.currentThread().getContextClassLoader();
     }
@@ -64,20 +63,9 @@ public abstract class SunURLClassPath im
     private java.lang.reflect.Field getUcpField() throws Exception {
         if (ucpField == null) {
             // Add them to the URLClassLoader's classpath
-            ucpField = (java.lang.reflect.Field) AccessController.doPrivileged(new PrivilegedAction()
{
-                public Object run() {
-                    java.lang.reflect.Field ucp = null;
-                    try {
-                        ucp = URLClassLoader.class.getDeclaredField("ucp");
-                        ucp.setAccessible(true);
-                    } catch (Exception e2) {
-                        e2.printStackTrace();
-                    }
-                    return ucp;
-                }
-            });
+            ucpField = URLClassLoader.class.getDeclaredField("ucp");
+            ucpField.setAccessible(true);
         }
-
         return ucpField;
     }
 

Modified: geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/TomcatClassPath.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/TomcatClassPath.java?rev=1539056&r1=1539055&r2=1539056&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/TomcatClassPath.java
(original)
+++ geronimo/xbean/trunk/xbean-classpath/src/main/java/org/apache/xbean/classpath/TomcatClassPath.java
Tue Nov  5 16:53:32 2013
@@ -20,8 +20,6 @@ import java.io.File;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 
 public class TomcatClassPath extends SunURLClassPath {
 
@@ -140,36 +138,19 @@ public class TomcatClassPath extends Sun
      * @return URLClassLoader.addURL method instance
      */
     private Method getAddURLMethod() throws Exception {
-        return (Method) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                Method method = null;
-                try {
-                    Class clazz = URLClassLoader.class;
-                    method = clazz.getDeclaredMethod("addURL", new Class[]{URL.class});
-                    method.setAccessible(true);
-                    return method;
-                } catch (Exception e2) {
-                    e2.printStackTrace();
-                }
-                return method;
-            }
-        });
+        Method method = null;
+        Class clazz = URLClassLoader.class;
+        method = clazz.getDeclaredMethod("addURL", new Class[]{URL.class});
+        method.setAccessible(true);
+        return method;
     }
 
     private Method getAddRepositoryMethod() throws Exception {
-        return (Method) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                Method method = null;
-                try {
-                    Class clazz = getClassLoader().getClass();
-                    method = clazz.getDeclaredMethod("addRepository", new Class[]{String.class});
-                    method.setAccessible(true);
-                    return method;
-                } catch (Exception e2) {
-                    throw (IllegalStateException) new IllegalStateException("Unable to find
or access the addRepository method in StandardClassLoader").initCause(e2);
-                }
-            }
-        });
+        Method method = null;
+        Class clazz = getClassLoader().getClass();
+        method = clazz.getDeclaredMethod("addRepository", new Class[]{String.class});
+        method.setAccessible(true);
+        return method;
     }
 
 }



Mime
View raw message