From 8c878b45dee35c5e3d57e838513d9d4d475e9d02 Mon Sep 17 00:00:00 2001 From: chiba Date: Sat, 4 Apr 2009 17:05:51 +0000 Subject: [PATCH] for fixing JASSIST-75 git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@475 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- .../javassist/util/proxy/SerializedProxy.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/javassist/util/proxy/SerializedProxy.java b/src/main/javassist/util/proxy/SerializedProxy.java index af866efe..5092e992 100644 --- a/src/main/javassist/util/proxy/SerializedProxy.java +++ b/src/main/javassist/util/proxy/SerializedProxy.java @@ -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 { -- 2.39.5