mirror of
https://github.com/ProjectSWGCore/pswgcommon.git
synced 2026-01-15 23:04:19 -05:00
Fixed usage of deprecated APIs
This commit is contained in:
@@ -117,7 +117,7 @@ public class Pair<T, S> implements Encodable, Persistable {
|
||||
// Try making our own persistable
|
||||
if (obj == null && Persistable.class.isAssignableFrom(klass)) {
|
||||
try {
|
||||
obj = klass.newInstance();
|
||||
obj = klass.getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,6 @@ public class FileLogWrapper implements LogWrapper {
|
||||
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLog(LogLevel level, String str) {
|
||||
try {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -208,7 +209,7 @@ public class NetBuffer {
|
||||
}
|
||||
|
||||
public boolean getBoolean() {
|
||||
return getByte() == 1 ? true : false;
|
||||
return getByte() == 1;
|
||||
}
|
||||
|
||||
public String getAscii() {
|
||||
@@ -302,12 +303,12 @@ public class NetBuffer {
|
||||
if (Encodable.class.isAssignableFrom(type)) {
|
||||
Object instance = null;
|
||||
try {
|
||||
instance = type.newInstance();
|
||||
instance = type.getConstructor().newInstance();
|
||||
((Encodable) instance).decode(this);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
|
||||
|
||||
return instance;
|
||||
} else if (Integer.class.isAssignableFrom(type) || Integer.TYPE.isAssignableFrom(type))
|
||||
return getInt();
|
||||
@@ -336,11 +337,11 @@ public class NetBuffer {
|
||||
|
||||
try {
|
||||
for (int i = 0; i < size; i++) {
|
||||
T instance = type.newInstance();
|
||||
T instance = type.getConstructor().newInstance();
|
||||
instance.decode(this);
|
||||
list.add(instance);
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
|
||||
@@ -383,9 +384,9 @@ public class NetBuffer {
|
||||
public <T extends Encodable> T getEncodable(Class<T> type) {
|
||||
T instance = null;
|
||||
try {
|
||||
instance = type.newInstance();
|
||||
instance = type.getConstructor().newInstance();
|
||||
instance.decode(this);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ public enum PacketType {
|
||||
return null;
|
||||
Class <? extends SWGPacket> c = type.c;
|
||||
try {
|
||||
return c.newInstance();
|
||||
return c.getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
Log.e("Packet: [%08X] %s", crc, c.getName());
|
||||
Log.e(e);
|
||||
|
||||
Reference in New Issue
Block a user