INTERNAL
Override from ContainerPolicy. Need to maintain the comparator in the
new instance
try {
if (m_comparator != null) {
Object[] arguments = new Object[] { m_comparator };
Class[] constructClass = new Class[] { Comparator.class };
Constructor constructor = null;
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
constructor = (Constructor)AccessController.doPrivileged(new PrivilegedGetConstructorFor(getContainerClass(), constructClass, false));
return AccessController.doPrivileged(new PrivilegedInvokeConstructor(constructor, arguments));
} catch (PrivilegedActionException exception) {
throw QueryException.couldNotInstantiateContainerClass(getContainerClass(), exception.getException());
}
} else {
constructor = PrivilegedAccessHelper.getConstructorFor(getContainerClass(), constructClass, false);
return PrivilegedAccessHelper.invokeConstructor(constructor, arguments);
}
} else {
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
return AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(getContainerClass()));
} catch (PrivilegedActionException exception) {
throw QueryException.couldNotInstantiateContainerClass(getContainerClass(), exception.getException());
}
} else {
return PrivilegedAccessHelper.newInstanceFromClass(getContainerClass());
}
}
} catch (Exception ex) {
throw QueryException.couldNotInstantiateContainerClass(getContainerClass(), ex);
}