]> source.dussan.org Git - javassist.git/commitdiff
for fixing JASSIST-75
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Sat, 4 Apr 2009 17:05:51 +0000 (17:05 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Sat, 4 Apr 2009 17:05:51 +0000 (17:05 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@475 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/util/proxy/SerializedProxy.java

index af866efe5a015321390f7f4b95f5364b96e3b3b5..5092e9927f4ae3badee9ed509d2e105e621e2126 100644 (file)
@@ -17,6 +17,10 @@ package javassist.util.proxy;
 
 import java.io.Serializable;
 import java.io.ObjectStreamException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.security.ProtectionDomain;
 
 /**
  * A proxy object is converted into an instance of this class
@@ -52,9 +56,18 @@ class SerializedProxy implements Serializable {
      * @return loaded class
      * @throws ClassNotFoundException for any error
      */
-    protected Class loadClass(String className) throws ClassNotFoundException {
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        return cl.loadClass(className);
+    protected Class loadClass(final String className) throws ClassNotFoundException {
+        try {
+            return (Class)AccessController.doPrivileged(new PrivilegedExceptionAction(){
+                public Object run() throws Exception{
+                    ClassLoader cl = Thread.currentThread().getContextClassLoader();
+                    return Class.forName(className, true, cl);
+                }
+            });
+        }
+        catch (PrivilegedActionException pae) {
+            throw new RuntimeException("cannot load the class: " + className, pae.getException());
+        }
     }
 
     Object readResolve() throws ObjectStreamException {