CSR :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
JDK-8155516 :
|
|
JDK-8155872 :
|
|
JDK-8159330 :
|
|
JDK-8168681 :
|
A DESCRIPTION OF THE REQUEST : Please, deprecate Class.newInstance in JDK7 and add alternative method newObjectInstance which will declare exception correctly. (or by wrapping exception or by adding generic throws clause) JUSTIFICATION : Class.newInstance violate checked exception definition. It's' allows undeclared checked excetion to be actually throwed, which is in contradiction with rules of language and cause errors. See also comments to See also http://bugs.sun.com/view_bug.do?bug_id=5066799 related bugs: http://bugs.sun.com/view_bug.do?bug_id=6195208 http://bugs.sun.com/view_bug.do?bug_id=4233093 they 'fixed' by specifing fundamentally incorrect behaviour in documentation, which is not fix of problem. ---------- BEGIN SOURCE ---------- next code frtagment >>public class X >> { >> >> public X() throws Exception >> { >> throw new Exception("hi!"); >> } >> >> public static void f() { >> try { >> X x = X.class.newInstance(); >> } catch (InstantiationException ex) { >> System.err.println("instantiation exception"); >> ex.printStackTrace(); >> } catch (IllegalAccessException ex) { >> System.err.println("illegal access exception"); >> ex.printStackTrace(); >> } >> } >> >> } >> will throw checked exception X from function X.f(), which is not declare one. ---------- END SOURCE ----------
|