Author: alessio.soldano(a)jboss.com
Date: 2013-07-17 12:01:22 -0400 (Wed, 17 Jul 2013)
New Revision: 17795
Modified:
common/trunk/src/main/java/org/jboss/ws/common/JavaUtils.java
Log:
Adding privileged block for getting TCCL
Modified: common/trunk/src/main/java/org/jboss/ws/common/JavaUtils.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/JavaUtils.java 2013-07-17 15:58:01 UTC
(rev 17794)
+++ common/trunk/src/main/java/org/jboss/ws/common/JavaUtils.java 2013-07-17 16:01:22 UTC
(rev 17795)
@@ -31,6 +31,8 @@
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.HashSet;
@@ -135,7 +137,7 @@
public static Class<?> loadJavaType(String typeName, ClassLoader classLoader)
throws ClassNotFoundException
{
if (classLoader == null)
- classLoader = Thread.currentThread().getContextClassLoader();
+ classLoader = getContextClassLoader();
Class<?> javaType = primitiveNames.get(typeName);
if (javaType == null)
@@ -146,6 +148,24 @@
return javaType;
}
+
+ private static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
/**
* True if the given type name is the source notation of a primitive or array of
which.
Show replies by date