Fix Class.newInstance() deprecation warnings.

This commit is contained in:
Ray J. Greenwell
2026-03-21 15:55:45 -07:00
parent 4ddc4e2f8a
commit 195562435b
4 changed files with 7 additions and 8 deletions
@@ -56,7 +56,7 @@ public abstract class PlaceConfig extends SimpleStreamableObject
log.warning("Providing backwards compatibility. PlaceConfig." + log.warning("Providing backwards compatibility. PlaceConfig." +
"createController() should be overridden directly."); "createController() should be overridden directly.");
try { try {
return (PlaceController)cclass.newInstance(); return (PlaceController)cclass.getConstructor().newInstance();
} catch (Exception e) { } catch (Exception e) {
log.warning("Failed to instantiate controller class '" + cclass + "'.", e); log.warning("Failed to instantiate controller class '" + cclass + "'.", e);
return null; return null;
@@ -461,7 +461,7 @@ public class PlaceManager
protected PlaceObject createPlaceObject () protected PlaceObject createPlaceObject ()
{ {
try { try {
return getPlaceObjectClass().newInstance(); return getPlaceObjectClass().getConstructor().newInstance();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -155,13 +155,12 @@ public class InvocationManager
// create a marshaller instance and initialize it // create a marshaller instance and initialize it
T marsh; T marsh;
try { try {
marsh = mclass.newInstance(); marsh = mclass.getConstructor().newInstance();
marsh.init(_invoid, invCode, _standaloneClient == null ? marsh.init(_invoid, invCode, _standaloneClient == null ?
null : _standaloneClient.getInvocationDirector()); null : _standaloneClient.getInvocationDirector());
} catch (IllegalAccessException ie) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException |
throw new RuntimeException(ie); InstantiationException ee) {
} catch (InstantiationException ie) { throw new RuntimeException(ee);
throw new RuntimeException(ie);
} }
// register the dispatcher // register the dispatcher
@@ -113,7 +113,7 @@ public class PresentsServer
try { try {
log.info("Invoking test module", "mod", testmod); log.info("Invoking test module", "mod", testmod);
Class<?> tmclass = Class.forName(testmod); Class<?> tmclass = Class.forName(testmod);
Runnable trun = (Runnable)tmclass.newInstance(); Runnable trun = (Runnable)tmclass.getConstructor().newInstance();
trun.run(); trun.run();
} catch (Exception e) { } catch (Exception e) {
log.warning("Unable to invoke test module '" + testmod + "'.", e); log.warning("Unable to invoke test module '" + testmod + "'.", e);