refactor to remove deprecation warning for newInstance

This commit is contained in:
thzero 2022-07-04 17:23:03 -05:00
parent 08b76e0b7e
commit 78df43569a

View File

@ -1,5 +1,6 @@
package net.sf.openrocket.document; package net.sf.openrocket.document;
import java.lang.reflect.InvocationTargetException;
import java.util.EventListener; import java.util.EventListener;
import java.util.EventObject; import java.util.EventObject;
import java.util.List; import java.util.List;
@ -350,11 +351,13 @@ public class Simulation implements ChangeSource, Cloneable {
SimulationEngine simulator; SimulationEngine simulator;
try { try {
simulator = simulationEngineClass.newInstance(); simulator = simulationEngineClass.getConstructor().newInstance();
} catch (InstantiationException e) { } catch (InstantiationException e) {
throw new IllegalStateException("Cannot instantiate simulator.", e); throw new IllegalStateException("Cannot instantiate simulator.", e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new IllegalStateException("Cannot access simulator instance?! BUG!", e); throw new IllegalStateException("Cannot access simulator instance?! BUG!", e);
} catch (InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
} }
SimulationConditions simulationConditions = options.toSimulationConditions(); SimulationConditions simulationConditions = options.toSimulationConditions();