From 195562435b8aa793e2589973f50274e6b866b6f1 Mon Sep 17 00:00:00 2001 From: "Ray J. Greenwell" Date: Sat, 21 Mar 2026 15:55:45 -0700 Subject: [PATCH] Fix Class.newInstance() deprecation warnings. --- .../main/java/com/threerings/crowd/data/PlaceConfig.java | 2 +- .../java/com/threerings/crowd/server/PlaceManager.java | 2 +- .../threerings/presents/server/InvocationManager.java | 9 ++++----- .../com/threerings/presents/server/PresentsServer.java | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/threerings/crowd/data/PlaceConfig.java b/core/src/main/java/com/threerings/crowd/data/PlaceConfig.java index 86514c464..d8d8e7c4b 100644 --- a/core/src/main/java/com/threerings/crowd/data/PlaceConfig.java +++ b/core/src/main/java/com/threerings/crowd/data/PlaceConfig.java @@ -56,7 +56,7 @@ public abstract class PlaceConfig extends SimpleStreamableObject log.warning("Providing backwards compatibility. PlaceConfig." + "createController() should be overridden directly."); try { - return (PlaceController)cclass.newInstance(); + return (PlaceController)cclass.getConstructor().newInstance(); } catch (Exception e) { log.warning("Failed to instantiate controller class '" + cclass + "'.", e); return null; diff --git a/core/src/main/java/com/threerings/crowd/server/PlaceManager.java b/core/src/main/java/com/threerings/crowd/server/PlaceManager.java index 4df0e0881..3b75d0b31 100644 --- a/core/src/main/java/com/threerings/crowd/server/PlaceManager.java +++ b/core/src/main/java/com/threerings/crowd/server/PlaceManager.java @@ -461,7 +461,7 @@ public class PlaceManager protected PlaceObject createPlaceObject () { try { - return getPlaceObjectClass().newInstance(); + return getPlaceObjectClass().getConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/core/src/main/java/com/threerings/presents/server/InvocationManager.java b/core/src/main/java/com/threerings/presents/server/InvocationManager.java index ba27f78cf..0723d0cb5 100644 --- a/core/src/main/java/com/threerings/presents/server/InvocationManager.java +++ b/core/src/main/java/com/threerings/presents/server/InvocationManager.java @@ -155,13 +155,12 @@ public class InvocationManager // create a marshaller instance and initialize it T marsh; try { - marsh = mclass.newInstance(); + marsh = mclass.getConstructor().newInstance(); marsh.init(_invoid, invCode, _standaloneClient == null ? null : _standaloneClient.getInvocationDirector()); - } catch (IllegalAccessException ie) { - throw new RuntimeException(ie); - } catch (InstantiationException ie) { - throw new RuntimeException(ie); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | + InstantiationException ee) { + throw new RuntimeException(ee); } // register the dispatcher diff --git a/core/src/main/java/com/threerings/presents/server/PresentsServer.java b/core/src/main/java/com/threerings/presents/server/PresentsServer.java index 5b0d4bdaa..561df3911 100644 --- a/core/src/main/java/com/threerings/presents/server/PresentsServer.java +++ b/core/src/main/java/com/threerings/presents/server/PresentsServer.java @@ -113,7 +113,7 @@ public class PresentsServer try { log.info("Invoking test module", "mod", testmod); Class tmclass = Class.forName(testmod); - Runnable trun = (Runnable)tmclass.newInstance(); + Runnable trun = (Runnable)tmclass.getConstructor().newInstance(); trun.run(); } catch (Exception e) { log.warning("Unable to invoke test module '" + testmod + "'.", e);