Fixed usage of deprecated APIs

This commit is contained in:
Obique PSWG
2017-12-20 10:10:12 -06:00
parent 47be819c01
commit 7e10fb8754
4 changed files with 11 additions and 15 deletions

View File

@@ -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);
}

View File

@@ -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 {

View File

@@ -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);
}

View File

@@ -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);