@Test(expected = AccessControlException.class) public void securityManagerSetContextClassLoaderInDoPrivileged() throws Exception { final ClassLoader loader = ReflectionHelper.class.getClassLoader(); AccessController.doPrivileged(ReflectionHelper.setContextClassLoaderPA(loader)); fail("It should not be possible to set context class loader even from privileged block via Jersey ReflectionHelper " + "utility"); }
public static PrivilegedAction setContextClassLoaderPA(final ClassLoader classLoader) { return new PrivilegedAction() { @Override public Object run() { Thread.currentThread().setContextClassLoader(classLoader); return null; } }; }
ReflectionHelper { public static PrivilegedAction setContextClassLoaderPA(final ClassLoader classLoader) { return new PrivilegedAction() { @Override public Object run() { Thread.currentThread().setContextClassLoader(classLoader); return null; } }; } }
ReflectionHelper { public static PrivilegedAction setContextClassLoaderPA(final ClassLoader classLoader) { return new PrivilegedAction() { @Override public Object run() { Thread.currentThread().setContextClassLoader(classLoader); return null; } }; } private  ReflectionHelper(); }
ReflectionHelper { public static PrivilegedAction setContextClassLoaderPA(final ClassLoader classLoader) { return new PrivilegedAction() { @Override public Object run() { Thread.currentThread().setContextClassLoader(classLoader); return null; } }; } private  ReflectionHelper(); static Class<?> getDeclaringClass(final AccessibleObject ao); static String objectToString(final Object o); static String methodInstanceToString(final Object o, final Method m); static PrivilegedAction<Class<T>> classForNamePA(final String name); @SuppressWarnings("unchecked") static PrivilegedAction<Class<T>> classForNamePA(final String name, final ClassLoader cl); static PrivilegedAction<ClassLoader> getClassLoaderPA(final Class<?> clazz); static PrivilegedAction<Field[]> getDeclaredFieldsPA(final Class<?> clazz); static PrivilegedAction<Field[]> getAllFieldsPA(final Class<?> clazz); static PrivilegedAction<Collection<? extends Method>> getDeclaredMethodsPA(final Class<?> clazz); static PrivilegedExceptionAction<Class<T>> classForNameWithExceptionPEA(final String name); @SuppressWarnings("unchecked") static PrivilegedExceptionAction<Class<T>> classForNameWithExceptionPEA(final String name, final ClassLoader cl); static PrivilegedAction<ClassLoader> getContextClassLoaderPA(); static PrivilegedAction setContextClassLoaderPA(final ClassLoader classLoader); static PrivilegedAction setAccessibleMethodPA(final Method m); static List<Class<?>> getGenericTypeArgumentClasses(final Type type); static List<ClassTypePair> getTypeArgumentAndClass(final Type type); static boolean isPrimitive(final Type type); static Type[] getTypeArguments(final Type type); static Type getTypeArgument(final Type type, final int index); @SuppressWarnings("unchecked") static Class<T> erasure(final Type type); static boolean isSubClassOf(final Type subType, final Type superType); static boolean isArray(final Type type); static boolean isArrayOfType(final Type type, final Class<?> componentType); static Type getArrayComponentType(final Type type); static Class<?> getArrayForComponentType(final Class<?> c); @SuppressWarnings("unchecked") static PrivilegedAction<Method> getValueOfStringMethodPA(final Class<?> clazz); @SuppressWarnings("unchecked") static PrivilegedAction<Method> getFromStringStringMethodPA(final Class<?> clazz); static PrivilegedAction<Constructor> getStringConstructorPA(final Class<?> clazz); static PrivilegedAction<Constructor<?>[]> getDeclaredConstructorsPA(final Class<?> clazz); static PrivilegedAction<Constructor<?>> getDeclaredConstructorPA(final Class<?> clazz, final Class<?>... params); static Collection<Class<? extends Annotation>> getAnnotationTypes(final AnnotatedElement annotatedElement,
                                                                             final Class<? extends Annotation> metaAnnotation); static boolean isGetter(final Method method); static GenericType genericTypeFor(final Object instance); static boolean isSetter(final Method method); static String getPropertyName(final Method method); static Class<?> theMostSpecificTypeOf(final Set<Type> contractTypes); static Class[] getParameterizedClassArguments(final DeclaringClassInterfacePair p); static Type[] getParameterizedTypeArguments(final DeclaringClassInterfacePair p); static DeclaringClassInterfacePair getClass(final Class<?> concrete, final Class<?> iface); static ClassTypePair resolveGenericType(final Class concreteClass, final Class declaringClass,
                                                   final Class rawResolvedType, final Type genericResolvedType); static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv); static PrivilegedAction<Method> findMethodOnClassPA(final Class<?> c, final Method m); static PrivilegedAction<Method[]> getMethodsPA(final Class<?> c); static Method findOverridingMethodOnClass(final Class<?> clazz, final Method method); static OsgiRegistry getOsgiRegistryInstance(); static InputStream getResourceAsStream(final ClassLoader loader, final Class<?> originClass, final String name); static Class<?> getRawClass(Type type); }
ReflectionHelper { public static PrivilegedAction setContextClassLoaderPA(final ClassLoader classLoader) { return new PrivilegedAction() { @Override public Object run() { Thread.currentThread().setContextClassLoader(classLoader); return null; } }; } private  ReflectionHelper(); static Class<?> getDeclaringClass(final AccessibleObject ao); static String objectToString(final Object o); static String methodInstanceToString(final Object o, final Method m); static PrivilegedAction<Class<T>> classForNamePA(final String name); @SuppressWarnings("unchecked") static PrivilegedAction<Class<T>> classForNamePA(final String name, final ClassLoader cl); static PrivilegedAction<ClassLoader> getClassLoaderPA(final Class<?> clazz); static PrivilegedAction<Field[]> getDeclaredFieldsPA(final Class<?> clazz); static PrivilegedAction<Field[]> getAllFieldsPA(final Class<?> clazz); static PrivilegedAction<Collection<? extends Method>> getDeclaredMethodsPA(final Class<?> clazz); static PrivilegedExceptionAction<Class<T>> classForNameWithExceptionPEA(final String name); @SuppressWarnings("unchecked") static PrivilegedExceptionAction<Class<T>> classForNameWithExceptionPEA(final String name, final ClassLoader cl); static PrivilegedAction<ClassLoader> getContextClassLoaderPA(); static PrivilegedAction setContextClassLoaderPA(final ClassLoader classLoader); static PrivilegedAction setAccessibleMethodPA(final Method m); static List<Class<?>> getGenericTypeArgumentClasses(final Type type); static List<ClassTypePair> getTypeArgumentAndClass(final Type type); static boolean isPrimitive(final Type type); static Type[] getTypeArguments(final Type type); static Type getTypeArgument(final Type type, final int index); @SuppressWarnings("unchecked") static Class<T> erasure(final Type type); static boolean isSubClassOf(final Type subType, final Type superType); static boolean isArray(final Type type); static boolean isArrayOfType(final Type type, final Class<?> componentType); static Type getArrayComponentType(final Type type); static Class<?> getArrayForComponentType(final Class<?> c); @SuppressWarnings("unchecked") static PrivilegedAction<Method> getValueOfStringMethodPA(final Class<?> clazz); @SuppressWarnings("unchecked") static PrivilegedAction<Method> getFromStringStringMethodPA(final Class<?> clazz); static PrivilegedAction<Constructor> getStringConstructorPA(final Class<?> clazz); static PrivilegedAction<Constructor<?>[]> getDeclaredConstructorsPA(final Class<?> clazz); static PrivilegedAction<Constructor<?>> getDeclaredConstructorPA(final Class<?> clazz, final Class<?>... params); static Collection<Class<? extends Annotation>> getAnnotationTypes(final AnnotatedElement annotatedElement,
                                                                             final Class<? extends Annotation> metaAnnotation); static boolean isGetter(final Method method); static GenericType genericTypeFor(final Object instance); static boolean isSetter(final Method method); static String getPropertyName(final Method method); static Class<?> theMostSpecificTypeOf(final Set<Type> contractTypes); static Class[] getParameterizedClassArguments(final DeclaringClassInterfacePair p); static Type[] getParameterizedTypeArguments(final DeclaringClassInterfacePair p); static DeclaringClassInterfacePair getClass(final Class<?> concrete, final Class<?> iface); static ClassTypePair resolveGenericType(final Class concreteClass, final Class declaringClass,
                                                   final Class rawResolvedType, final Type genericResolvedType); static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv); static PrivilegedAction<Method> findMethodOnClassPA(final Class<?> c, final Method m); static PrivilegedAction<Method[]> getMethodsPA(final Class<?> c); static Method findOverridingMethodOnClass(final Class<?> clazz, final Method method); static OsgiRegistry getOsgiRegistryInstance(); static InputStream getResourceAsStream(final ClassLoader loader, final Class<?> originClass, final String name); static Class<?> getRawClass(Type type);  }