Merge pull request #1517 from thzero/simulationdeprecation

Refactor to remove deprecation warning for newInstance
This commit is contained in:
SiboVG 2022-07-05 01:06:53 +02:00 committed by GitHub
commit ffb78446c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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