ConfigSuite: Instantiate class via getDeclaredConstructor()
ErrorProne reports a warning [1] about bypassing exception checking by instantiation with direct call to #newInstance. It also mentions that #newInstance is to be deprecated from Java 9. [1] http://errorprone.info/bugpattern/ClassNewInstance Change-Id: Id20631933bce8ab320dd5e321336bad9e181cfa0
This commit is contained in:
@@ -120,7 +120,7 @@ public class ConfigSuite extends Suite {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createTest() throws Exception {
|
public Object createTest() throws Exception {
|
||||||
Object test = getTestClass().getJavaClass().newInstance();
|
Object test = getTestClass().getJavaClass().getDeclaredConstructor().newInstance();
|
||||||
parameterField.set(test, callConfigMethod(configMethod));
|
parameterField.set(test, callConfigMethod(configMethod));
|
||||||
if (nameField != null) {
|
if (nameField != null) {
|
||||||
nameField.set(test, name);
|
nameField.set(test, name);
|
||||||
|
|||||||
Reference in New Issue
Block a user