diff options
author | gjoranv <gv@oath.com> | 2018-04-30 15:18:27 +0200 |
---|---|---|
committer | gjoranv <gv@oath.com> | 2018-04-30 15:24:29 +0200 |
commit | 667b92cdcb8c06d5a8285ac59141a890ae9f0f3c (patch) | |
tree | 8f3d340903aad65d754a5eaf2b24a5083de98e7f /logserver/src/main/java/com | |
parent | c57701c0cefd8c0198844d97d40c037698de39cf (diff) |
Fix usage of apis deprecated from Java 9.
+ rewrite if to switch-case.
Diffstat (limited to 'logserver/src/main/java/com')
-rw-r--r-- | logserver/src/main/java/com/yahoo/logserver/AbstractPluginLoader.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/logserver/src/main/java/com/yahoo/logserver/AbstractPluginLoader.java b/logserver/src/main/java/com/yahoo/logserver/AbstractPluginLoader.java index 619643a32b6..db2ed6b0b83 100644 --- a/logserver/src/main/java/com/yahoo/logserver/AbstractPluginLoader.java +++ b/logserver/src/main/java/com/yahoo/logserver/AbstractPluginLoader.java @@ -5,6 +5,7 @@ import com.yahoo.log.LogLevel; import com.yahoo.plugin.Plugin; import com.yahoo.plugin.SystemPropertyConfig; +import java.lang.reflect.InvocationTargetException; import java.util.logging.Logger; /** @@ -20,8 +21,8 @@ public abstract class AbstractPluginLoader implements PluginLoader { protected void loadFromClass(Class<? extends Plugin> pluginClass) { Plugin plugin; try { - plugin = (Plugin) pluginClass.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + plugin = pluginClass.getDeclaredConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { log.log(LogLevel.ERROR, pluginClass.getName() + ": load failed: " + e); throw new RuntimeException(e); } |