summaryrefslogtreecommitdiffstats
path: root/config-lib
diff options
context:
space:
mode:
authorgjoranv <gjoranv@gmail.com>2017-06-09 21:45:54 +0200
committerGitHub <noreply@github.com>2017-06-09 21:45:54 +0200
commit2af698629318873b3167cbad30081d2994e9df91 (patch)
treecee60f69b779ea5639a327a44451a109838f07ad /config-lib
parent8a36fd2b7b35aa2127293c363179b176b5e5c313 (diff)
parentca9699c40b5187a7b67a09f71a5e3f1d58de2310 (diff)
Merge pull request #2692 from yahoo/gjoranv/set-default-config-ctor-private
Set the default constructor on config classes private.
Diffstat (limited to 'config-lib')
-rw-r--r--config-lib/src/main/java/com/yahoo/config/InnerNodeVector.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/config-lib/src/main/java/com/yahoo/config/InnerNodeVector.java b/config-lib/src/main/java/com/yahoo/config/InnerNodeVector.java
index 72ca0138a53..eec2d3cd500 100644
--- a/config-lib/src/main/java/com/yahoo/config/InnerNodeVector.java
+++ b/config-lib/src/main/java/com/yahoo/config/InnerNodeVector.java
@@ -1,6 +1,8 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.List;
/**
@@ -38,9 +40,11 @@ public class InnerNodeVector<NODE extends InnerNode> extends NodeVector<NODE> {
@SuppressWarnings("unchecked")
protected NODE createNew() {
try {
- return (NODE) defaultNode.getClass().newInstance();
- } catch (IllegalAccessException | InstantiationException ex) {
- throw new ConfigurationRuntimeException(ex);
+ Constructor<? extends InnerNode> ctor = defaultNode.getClass().getDeclaredConstructor();
+ ctor.setAccessible(true);
+ return (NODE) ctor.newInstance();
+ } catch (InvocationTargetException | IllegalAccessException | InstantiationException | NoSuchMethodException e) {
+ throw new ConfigurationRuntimeException(e);
}
}