try {
Class clazz = type.getClassIWant();
Constructor c = clazz.getConstructor(Integer.TYPE,SomeOther.class,Integer.TYPE,Date.class);
return (Benchmark)c.newInstance(samples,dao,days,from);
}
catch (NoSuchMethodException e) {
throw new ServletException(e);
}
catch (InstantiationException e) {
throw new ServletException(e);
}
catch (IllegalAccessException e) {
throw new ServletException(e);
}
catch (InvocationTargetException e) {
throw new ServletException(e);
}
- Why aren’t constructors part of interfaces?
- Why are there so many stupid exceptions I have to catch?
- Why is this any “safer” than SomeClass.new(samples,dao,days,from)? The net effect is the same, but I’ve just added a pile of steaming shit to my codebase for no benefit?
- Don’t even tell me to replace this with some Spring XML bullshit. Angle brackets are like crack with none of the benefits (which I guess makes them cigarettes?)
7 months ago