8073361: Missing doPrivileged in com.sun.xml.internal.bind.v2.ClassFactory

Reviewed-by: mullan, mkos
This commit is contained in:
Mandy Chung 2015-02-25 14:51:12 -08:00
parent 1f3b999b98
commit 8c3edc1d57

View File

@ -30,6 +30,8 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.logging.Level; import java.util.logging.Level;
@ -85,19 +87,25 @@ public final class ClassFactory {
if(consRef!=null) if(consRef!=null)
cons = consRef.get(); cons = consRef.get();
if(cons==null) { if(cons==null) {
try { cons = AccessController.doPrivileged(new PrivilegedAction<Constructor<T>>() {
cons = clazz.getDeclaredConstructor(emptyClass); @Override
} catch (NoSuchMethodException e) { public Constructor<T> run() {
logger.log(Level.INFO,"No default constructor found on "+clazz,e); try {
NoSuchMethodError exp; return clazz.getDeclaredConstructor(emptyClass);
if(clazz.getDeclaringClass()!=null && !Modifier.isStatic(clazz.getModifiers())) { } catch (NoSuchMethodException e) {
exp = new NoSuchMethodError(Messages.NO_DEFAULT_CONSTRUCTOR_IN_INNER_CLASS.format(clazz.getName())); logger.log(Level.INFO,"No default constructor found on "+clazz,e);
} else { NoSuchMethodError exp;
exp = new NoSuchMethodError(e.getMessage()); if(clazz.getDeclaringClass()!=null && !Modifier.isStatic(clazz.getModifiers())) {
exp = new NoSuchMethodError(Messages.NO_DEFAULT_CONSTRUCTOR_IN_INNER_CLASS
.format(clazz.getName()));
} else {
exp = new NoSuchMethodError(e.getMessage());
}
exp.initCause(e);
throw exp;
}
} }
exp.initCause(e); });
throw exp;
}
int classMod = clazz.getModifiers(); int classMod = clazz.getModifiers();