diff options
author | gjoranv <gv@oath.com> | 2018-05-03 13:16:08 +0200 |
---|---|---|
committer | gjoranv <gv@oath.com> | 2018-05-03 15:31:51 +0200 |
commit | 45412aa2ca2eed6aee8a36473fa435e32bebed6b (patch) | |
tree | 3a3fd53ac3d8ef52025dbe512e1e1ccde54e0fde | |
parent | e239b38f254c8f63f0e14038ca61358f68396868 (diff) |
Java 9: Class.newInstance() is deprecated.
2 files changed, 9 insertions, 14 deletions
diff --git a/chain/src/test/java/com/yahoo/component/chain/dependencies/ordering/ChainBuilderTest.java b/chain/src/test/java/com/yahoo/component/chain/dependencies/ordering/ChainBuilderTest.java index 7e74a732893..07ac302f1f3 100644 --- a/chain/src/test/java/com/yahoo/component/chain/dependencies/ordering/ChainBuilderTest.java +++ b/chain/src/test/java/com/yahoo/component/chain/dependencies/ordering/ChainBuilderTest.java @@ -27,9 +27,7 @@ import static org.junit.Assert.assertTrue; @SuppressWarnings({"rawtypes", "unchecked"}) public class ChainBuilderTest { - private void addAtoG(ChainBuilder chainBuilder) - throws IllegalAccessException, InstantiationException { - + private void addAtoG(ChainBuilder chainBuilder) throws ReflectiveOperationException { List<Class<? extends ChainedComponent>> componentTypes = new ArrayList<>(); componentTypes.add(A.class); @@ -43,7 +41,7 @@ public class ChainBuilderTest { permute(componentTypes); for (Class<? extends ChainedComponent> searcherClass : componentTypes) { - chainBuilder.addComponent(searcherClass.newInstance()); + chainBuilder.addComponent(searcherClass.getDeclaredConstructor().newInstance()); } } @@ -58,7 +56,7 @@ public class ChainBuilderTest { } @Test - public void testRegular() throws InstantiationException, IllegalAccessException { + public void testRegular() throws Exception { ChainBuilder chainBuilder = createDependencyHandler(); addAtoG(chainBuilder); @@ -72,8 +70,7 @@ public class ChainBuilderTest { } @Test - public void testCycle() - throws InstantiationException, IllegalAccessException { + public void testCycle() throws Exception { ChainBuilder chainBuilder = createDependencyHandler(); @@ -139,8 +136,7 @@ public class ChainBuilderTest { } @Test - public void testAfterAll1() - throws InstantiationException, IllegalAccessException { + public void testAfterAll1() throws Exception { ChainBuilder chainBuilder = createDependencyHandler(); ChainedComponent afterAll1 = new AfterAll(); chainBuilder.addComponent(afterAll1); @@ -151,8 +147,7 @@ public class ChainBuilderTest { } @Test - public void testAfterAll2() - throws InstantiationException, IllegalAccessException { + public void testAfterAll2() throws Exception { ChainBuilder chainBuilder = createDependencyHandler(); addAtoG(chainBuilder); ChainedComponent afterAll1 = new AfterAll(); @@ -241,7 +236,7 @@ public class ChainBuilderTest { static class AfterProvidesNothing extends NoopComponent { } - public static class NoopComponent extends ChainedComponent { + static class NoopComponent extends ChainedComponent { } } diff --git a/jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/core/FelixFrameworkIntegrationTest.java b/jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/core/FelixFrameworkIntegrationTest.java index 6dec6cb444b..7995def7045 100644 --- a/jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/core/FelixFrameworkIntegrationTest.java +++ b/jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/core/FelixFrameworkIntegrationTest.java @@ -196,7 +196,7 @@ public class FelixFrameworkIntegrationTest { private static int callClass(Bundle bundle, String className) throws Exception { Class<?> certClass = bundle.loadClass(className); assertNotNull(certClass); - Callable<Integer> cert = (Callable<Integer>)certClass.newInstance(); + Callable<Integer> cert = (Callable<Integer>)certClass.getDeclaredConstructor().newInstance(); assertNotNull(cert); return cert.call(); } @@ -214,7 +214,7 @@ public class FelixFrameworkIntegrationTest { assertEquals(Arrays.asList(expectedBundles), actual); felix.startBundles(bundles, false); if (className != null) { - assertNotNull(bundles.get(0).loadClass(className).newInstance()); + assertNotNull(bundles.get(0).loadClass(className).getDeclaredConstructor().newInstance()); } } finally { felix.stop(); |