answer = ((Class) answer).newInstance();
ref = new NamedWeakReference(answer, className);
factories.set(posn-1, ref); // replace Class object or null
return answer;
} catch (ClassNotFoundException e) {
NamingException ne =
new NamingException("No longer able to load " + className);
ne.setRootCause(e);
throw ne;
} catch (InstantiationException e) {
NamingException ne =
new NamingException("Cannot instantiate " + answer);
ne.setRootCause(e);
throw ne;
} catch (IllegalAccessException e) {
NamingException ne = new NamingException("Cannot access " + answer);
ne.setRootCause(e);
throw ne;
}
}
}