Class.newInstance()
is marked deprecated. Documentation does not suggest any alternatives. How are we meant to create instances now?
To quote Java 9's javadoc :
The call
clazz.newInstance()
can be replaced by
clazz.getDeclaredConstructor().newInstance()
Class.getDeclaredConstructor(...).newInstance(...)
有关原因的说明,请参阅Google errorprone的文档 (例如)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.