Replace deprecated call to Call.newInstance()

This commit is contained in:
0xboobface 2018-11-14 14:16:20 +01:00
parent 9bcf7523b1
commit e3001cb242
1 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package ctbrec.io; package ctbrec.io;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -52,7 +53,7 @@ public class ModelJsonAdapter extends JsonAdapter<Model> {
} else if(key.equals("type")) { } else if(key.equals("type")) {
type = reader.nextString(); type = reader.nextString();
Class<?> modelClass = Class.forName(Optional.ofNullable(type).orElse(ChaturbateModel.class.getName())); Class<?> modelClass = Class.forName(Optional.ofNullable(type).orElse(ChaturbateModel.class.getName()));
model = (Model) modelClass.newInstance(); model = (Model) modelClass.getDeclaredConstructor().newInstance();
} else if(key.equals("streamUrlIndex")) { } else if(key.equals("streamUrlIndex")) {
streamUrlIndex = reader.nextInt(); streamUrlIndex = reader.nextInt();
model.setStreamUrlIndex(streamUrlIndex); model.setStreamUrlIndex(streamUrlIndex);
@ -67,7 +68,7 @@ public class ModelJsonAdapter extends JsonAdapter<Model> {
} else { } else {
reader.skipValue(); reader.skipValue();
} }
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new IOException("Couldn't instantiate model class [" + type + "]", e); throw new IOException("Couldn't instantiate model class [" + type + "]", e);
} }
} }