From 40372dffa966a42e8e59a4936f302beecadd076b Mon Sep 17 00:00:00 2001 From: yeikel Date: Tue, 6 Feb 2024 21:51:48 -0500 Subject: [PATCH] refactor: remove usage of `class.newInstance()` deprecated method --- src/main/java/io/vertx/core/impl/VertxImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/vertx/core/impl/VertxImpl.java b/src/main/java/io/vertx/core/impl/VertxImpl.java index a2dc87dd434..485a04babb8 100644 --- a/src/main/java/io/vertx/core/impl/VertxImpl.java +++ b/src/main/java/io/vertx/core/impl/VertxImpl.java @@ -63,6 +63,7 @@ import java.io.InputStream; import java.lang.ref.Cleaner; import java.lang.ref.WeakReference; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -740,7 +741,13 @@ public Future deployVerticle(Verticle verticle, DeploymentOptions option @Override public Future deployVerticle(Class verticleClass, DeploymentOptions options) { - return deployVerticle((Callable) verticleClass::newInstance, options); + + try { + final var verticle = verticleClass.getDeclaredConstructor().newInstance(); + return deployVerticle(verticle, options); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + throw new RuntimeException(e); + } } @Override