summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorgjoranv <gv@oath.com>2018-04-25 16:29:30 +0200
committergjoranv <gv@oath.com>2018-04-25 17:13:43 +0200
commit4656265d867a2bdcb0967789fdcf5bfea5b5af38 (patch)
treeb1240c72889855e740c58a23d92e3a9741e530eb /vespajlib
parent8f91dcc844a8669aeaae3fadebd564c08bc2ae08 (diff)
Use Constructor.newInstance instead of Class.newInstance.
- The latter is deprecated in Java 9.
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/collections/ListMap.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/collections/ListMap.java b/vespajlib/src/main/java/com/yahoo/collections/ListMap.java
index b601545b43b..e851362a99d 100644
--- a/vespajlib/src/main/java/com/yahoo/collections/ListMap.java
+++ b/vespajlib/src/main/java/com/yahoo/collections/ListMap.java
@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang.builder.ToStringBuilder;
+import java.lang.reflect.InvocationTargetException;
import java.util.*;
/**
@@ -25,7 +26,10 @@ public class ListMap<K, V> {
@SuppressWarnings("unchecked")
public ListMap(@SuppressWarnings("rawtypes") Class<? extends Map> implementation) {
try {
- this.map = implementation.newInstance();
+ this.map = implementation.getDeclaredConstructor().newInstance();
+ } catch (InvocationTargetException e) {
+ // For backwards compatibility from when this method used implementation.newInstance()
+ throw new IllegalArgumentException(e.getCause());
} catch (Exception e) {
throw new IllegalArgumentException(e);
}